Click here to Skip to main content
Sign Up to vote bad
good
See more: PHP
hi,
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';
}
?>
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
Posted 27 Jun '12 - 1:05
Edited 27 Jun '12 - 3:32


2 solutions

<input type="text" name="email" id="email" value="" />
 
or
 
$_POST['first_name']
  Permalink  
$fname = '';
 
if( isset($_POST['Submit'])) {
$fname = $_POST['first_name'];
 
Name :* <input id="first_name" name="first_name" type="text" style="width:150px;" value="<?php echo htmlentities($fname) ?>" />
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 239
1 OriginalGriff 173
2 Maciej Los 135
3 Mahesh Bailwal 104
4 Aarti Meswania 98
0 Sergey Alexandrovich Kryukov 10,214
1 OriginalGriff 7,819
2 CPallini 4,181
3 Rohan Leuva 3,522
4 Maciej Los 3,089


Advertise | Privacy | Mobile
Web04 | 2.6.130523.1 | Last Updated 31 Jul 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid