This is my php code
<?php
if( $_POST )
{
$con = mysql_connect('localhost','','');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('stay', $con);
// escape variables for security
$firstname = mysql_real_escape_string($_POST['uname']);
$lastname = mysql_real_escape_string($_POST['uemail']);
$password = mysql_real_escape_string($_POST['upass']);
$rpassword = mysql_real_escape_string($_POST['urpass']);
echo $sql = "INSERT INTO reg(name,email,pass,rpass)VALUES ('$firstname',
'$lastname', '$password','$rpassword')";
if (!$db_selected)
{
die ('Can\'t use stay : ' . mysql_error());
}
else
{
mysql_query($sql,$con);
}
mysql_close($con);
}
?>
I want to perform insert operation using POST. The problem is of access to the database in phpMyAdmin named as stay. I am uploading the screen shot too.
Your user cannot be blank in row
$con = mysql_connect('localhost','','');
Check it out, probbably it's 'root' if you have a newly installed xampp/wampp server
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.