Jump to content

insert not working


ohdang888

Recommended Posts

this code dies not have any errors, and its create blank rows(except for the "id" column), but why isn't it inserting info???


$username = $_POST["username"];
  $email = $_POST["email"];
  $password = $_POST["password1"];
  
  $sql="INSERT INTO `user` (`username`, `password`, `email`) VALUES ( '$username', '$email', '$password')";
  
  mysql_query($sql) or die ( mysql_error());
  }	
?>

<html>
<form name=”reg” method=”post” enctype=”application/x-www-form-urlencoded”>
username: <input type=”text” name=”username” /><br /><?php echo $error[’userexists’]; echo $error[’usernameinput’]; ?>
email: <input type=”text” name=”email” /><br />
password1: <input type=”password” name=”password1” /><br/>
password2: <input type=”password” name=”password2” /><br/>
<input type=submit name=”submit” value=”submit” /><br> 
</form>

Link to comment
https://forums.phpfreaks.com/topic/85901-insert-not-working/
Share on other sites

you have your values all mixed up, you need to make sure it looks like the database

 

say your DB looks like

 

username password email

 

then your query needs to look like

$sql="INSERT INTO `user` (`username`, `password`, `email`) VALUES ( '$username', '$password', '$email')";

 

yours looks like

$sql="INSERT INTO `user` (`username`, `password`, `email`) VALUES ( '$username', '$email', '$password')";

Link to comment
https://forums.phpfreaks.com/topic/85901-insert-not-working/#findComment-438565
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.