Page 1 of 1

EMpty the Post variables

Posted: Fri Feb 04, 2005 8:36 am
by harsha

Code: Select all

<?
	if(isset($_POSTї'confirm']))
		{
			$sg_refinedVals = $_POST;

			if(!empty($sg_refinedVals))
				{
					$sg_dbQuery = "INSERT INTO sg_users ".
					"(user_name, user_type, user_password, user_email, user_organisation, user_phone,  user_extension, user_address, user_city, user_country, user_postal_code) ".
					"values('{$sg_refinedValsї'name']}', 1, PASSWORD('{$sg_refinedValsї'email']}'), '{$sg_refinedValsї'email']}', '{$sg_refinedValsї'org']}', '{$sg_refinedValsї'phone']}', '{$sg_refinedValsї'extension']}', '".addslashes($sg_refinedValsї'address'])."', '{$sg_refinedValsї'city']}', {$sg_refinedValsї'country']}, '{$sg_refinedValsї'zip']}')";
				
					if(sg_db_query($sg_dbQuery) == FALSE)
						{
							echo "<h1  align="center">";
							echo "User Registration was successful, <br>a email will be sent to the email adddress<br>";
							echo "for confirmation containing all the login information";
							echo "</h1>";
							//echo (defined("SG_DB_QUERY_ERROR"))? SG_DB_QUERY_ERROR : "DATABASE ERROR";
						}
				}
			else
				{
					echo "<h1 class="t1">";
					echo "User Registration was successful, <br>a email will be sent to the email adddress<br>";
					echo "for confirmation containing all the login information";
					echo "</h1>";
				}
		}
?>
Hi all
I use script for new user registration and in that I use the same same page that is form action is php_self

and the script is common for Submit preview and confirm and Greeting saying "User REgistration successful" and when I refresh the page the
the database scolds me for the duplicate entry I know this problem that I need to flush $_POST data so that I can check the condition of empty($_POST) and skip the database insert how do I flush the $_POST values while the page loads.

Posted: Fri Feb 04, 2005 8:49 am
by feyd
refreshing an already submitted page where table fields are marked as unique will generate a duplicate record error. This is normal, and should be expected. I don't see an issue other than you not sanitizing the submitted data and looking for a button to tell you if the form is being submitted.