0

Hi,

i have a registration form, where the user enters username, email, designation and organisation. on clicking register button, the data in this form should get saved into database.

The code is as follows, when i executed it for the 1st time, data was saved properly, but when executed next time, the data is not getting stored in the database, but the username appears in the last echo statement. i am not able to figure out what is happening. can anyone help me in finding out where iam going wrong...

Thanks..

//passing the inputs from the form to php
$username = $_POST['username'];
$email =$_POST['email'];
$designation=$_POST['designation'];
$organisation=$_POST['organisation'];

//inserting into database table users
$sql = "INSERT INTO users values('','$username','$email','$designation','$organisation')";
$sqlres = mysql_query($sql);

echo (" data saved into database ".$username);
3
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by puvi
0

by any chance do we need to use while loop..if so how??

0

There is no wrong in the above code.. But if you post the actual form code with the above means, i can easily help you...

0
<?php
ini_set('error_reporting',E_ALL); 
ini_set('display_errors','Off'); 
ini_set('log_errors','Off'); 
?>

<html>
<head>
</head>
<body>
<?php
	if(!isset($_POST['register']))
	{
	?>

	<form method="post" name="myform" action="reg.php" onSubmit="return Validate(this);" />

	 <div style="position:absolute;left:250px;top:60px">
	<p>
	<table>
	<tr>
		<th colspan=2><b>Register</b></td>
	</tr>
	<tr>
		<td>User Name:</td><td> <input type="text" name="username" />*</td>
	</tr>
	
	<tr>
		<td>Email: </td><td><input type="text" name="email"/>*</td>
	</tr>
	<tr>
		<td>Confirm Email: </td><td><input type="text" name="cemail"/>*</td>
	</tr>
	<tr>
		<td>Designation: </td><td><input type="text" name="designation" />*</td>
	</tr>
	<tr>
		<td>Organisation: </td><td><input type="text" name="organisation" /></td>
	</tr>
</table>
	
	</p>
	</div>
</form>
<?php
}
?>
</body>
</html>
<?php 
	
		if($_REQUEST['register'] == "Register")
		{
			$link = mysql_connect("xxx","xxx","xxx");
			mysql_select_db("xxx",$link);
				
			 $username = $_POST['username'];
			 $email =$_POST['email'];
			 $designation=$_POST['designation'];
			 $organisation=$_POST['organisation'];
			 $password = $username;
             
			 $emarketing = $_POST['emarketing'];
			 $vmarketing =$_POST['vmarketing'];
			 
			 $esales=$_POST['esales'];
			 $vsales=$_POST['vsales'];
			 
			 $ebo = $_POST['ebo'];
			 $vbo =$_POST['vbo'];
			 
			 $eadmin=$_POST['eadmin'];
			 $vadmin=$_POST['vadmin'];
			//$subject = "This is your protostar auto generated password";
			
			//$headers = "protostar.com";
			
			
		   $sql = "INSERT INTO users values('','$username','$password','$email','1','','','$designation','$organisation')";
		   $sqlres = mysql_query($sql);
		   
		   /*$sql="SELECT userID FROM users WHERE username='".$username."'";
		   $userid = mysql_query($sql);
		   
		   $sql = "INSERT INTO marketing values('','$userid','$emarketing','$vmarketing')";
		   $sqlres = mysql_query($sql);
		   
		   $sql = "INSERT INTO sales values('','$userid','$esales','$vsales')";
		   $sqlres = mysql_query($sql);
		   
		   $sql = "INSERT INTO business_overview values('','$userid','$ebo','$vbo')";
		   $sqlres = mysql_query($sql);
		   
		   $sql = "INSERT INTO admin values('','$userid','$eadmin','$vadmin')";
		   $sqlres = mysql_query($sql);*/
		   
		   
		   echo (" data saved into database ".$username);
	}


?>

Edited by puvi: n/a

0

hey dragonbaki..pls go thru the code n proof check for me..thanks

0

hi all..can anyone locate any issue in this code..pls bring to my notice..

0

Hi puvi,

It seems there is no issues in your php code. Did u checked that you set AUTO INCREMENT value to the id of your mysql table ?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.