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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.