EMpty the Post variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
harsha
Forum Contributor
Posts: 103
Joined: Thu Jul 11, 2002 1:35 am
Location: Bengaluru (Bangalore) > Karnataka > India

EMpty the Post variables

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
Post Reply