0

when i'm creating register form database was connected but cant able to store the values from form into mysql

3
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by Dragonbaki
0
<?php
$con = mysql_connect("localhost","root","" );
mysql_select_db("test",$con);
$name=$_REQUEST['name'];
$username=$_REQUEST['username'];
$pass1=$_REQUEST['pass1'];
$pass2=$_REQUEST['pass2'];
$email=$_REQUEST['email'];
$number=$_REQUEST['number'];
if(($_REQUEST['pass1'])==($_REQUEST['pass2']))
{
$sql="INSERT INTO register(name,username,pass1,pass2,email,number)VALUES ('".$name."','".$username."','".$pass1."','".$pass2."','".$email."','".$number."')"; 
$res=mysql_query($sql,$con) or die(mysql_error());
}
else
{
echo "Passwords aren't identical";
}

header("location:login.php");

?>

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

0

Ok.. Try this code by replacing insert statement.. It surely works..

$sql="INSERT INTO register(name,username,pass1,pass2,email,number)VALUES ('$name','$username','$pass1','$pass2','$email','$number')";

and additionally use exit; after echo statement in else part. This will automatically terminates the execution if condition not satisfied. Because, we should not use any output command before calling header() function..

Hope you can understand and solve your issue. If still probs, please let me know..

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

0

Fine Shenba... If you have any issues, dont worry... We are here... Feel free to communicate with us...

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.