防止PHP中的数据丢失 [英] Prevent data loss in php

查看:79
本文介绍了防止PHP中的数据丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


Freinds我遇到了一个问题,
提交我的PHP表单后.清除所有文本框值.

但我希望这不会发生.

我的PHP代码...


Freinds i am getting a problem that
after submiting my php form. its clear all textbox value.

but i want it should not be happen.

My PHP Code...

<?php <br mode="hold" /?>session_start();

if(isset($_POST['Submit'])) {


   if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) {
		// Insert you code for processing the form here, e.g emailing the submission, entering it into a database. 
		//echo 'Thank you. Your message said "'.$_POST['message'].'"';
	echo 'Thank you. Your message said "';
	$_SESSION['first_name'] = $_POST['first_name'];
    $_SESSION['last_name'] = $_POST['last_name'];
	$_SESSION['account_name'] = $_POST['account_name'];
	$_SESSION['webtolead_email1'] = $_POST['webtolead_email1'];
	$_SESSION['phone'] = $_POST['phone'];
	$_SESSION['product'] = $_POST['product'];
	$_SESSION['description'] = $_POST['description'];
	header( 'Location:http://localhost/MySQL/test.php' ) ;
	unset($_SESSION['security_code']);

    } 
   else {
		 //Insert your code for showing an error message here
		/*echo "<script>alert('Please correct code.....')</script>";*/
	
		
	echo 'Sorry, you have provided an invalid security code';
		//header( 'Location:http://localhost/MySQL/captcha.php' ) ;
	   }
} 
else {
echo 'Sorry, you have provided andasfasdfadfasdfasdde';
}
?>


我的html代码..........


My html code..........

<form action="form.php" method="post">
		<label for="name">Name: </label><input type="text" name="name" id="name" /><br />
		<label for="email">Email: </label><input type="text" name="email" id="email" /><br />
		<label for="message">Message: </label><textarea rows="5" cols="30" name="message" id="message"></textarea><br />
		<img src="CaptchaSecurityImages.php?width=100&height=40&characters=5" /><br />
		<label for="security_code">Security Code: </label><input id="security_code" name="security_code" type="text" /><br />
		<input type="submit" name="submit" value="Submit" />
	</form>


我想在同一页面中进行重定向,但出现错误时,不能清除所有数据...

任何帮助将不胜枚举..

感谢


i want to redirect in same page but while error it should not be clear all data...

any help will be greatly appriciated..

thanks

推荐答案

_POST ['Submit'])){ if(
_POST['Submit'])) { if(


_SESSION ['security_code'] ==
_SESSION['security_code'] ==


_POST ['security_code']&&!empty(
_POST['security_code'] && !empty(


这篇关于防止PHP中的数据丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆