bobicles2 Posted April 16, 2010 Share Posted April 16, 2010 i have a HTML form to register users to my website, when i fill the form out however, the username and email are not send to the database...although the password is...below is the php code and ive enclosed the form as well as a screenshot of my database incase thats the problem, where am i going wrong! php is cracking my brains thanks rob <?php $con = mysql_connect("localhost","?????","??????"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("teamrend_rwowen", $con); $sql="INSERT INTO Members (Username, Password, Email) VALUES ('$_POST[username]','$_POST[Password]','$_POST[Email]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "Thank You, You are now a registered user"; mysql_close($con) ?> <form name="form2" method="post" action="registerphp.php"> <td><table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#DBDBDB"> <tr> <td colspan="3"><p align="center"><strong>Please Register </strong></p> <p> </p></td> </tr> <tr> <td width="78">Username </td> <td width="6">:</td> <td width="294"><input type="text" name="Username" id="Username"/></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input type="text" name="Password" id="Password" /></td> </tr> <tr> <td>Email</td> <td>:</td> <td><input type="text" name="Email" id="Email" /></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Submit" /></td> </tr> </table></td> </form> Here is my database set up[, and below is a screenshot of my attemps to register. the ID auto increments as normal, the username and email stays blank but for some reason password goes in just fine Quote Link to comment https://forums.phpfreaks.com/topic/198798-inserting-into-table/ Share on other sites More sharing options...
ChemicalBliss Posted April 16, 2010 Share Posted April 16, 2010 Quite strange, try: 1. putting single quotes arround your array key strings, eg; ['Username'] ['Password'] ['Email']. 2. Make sure they are getting to the script: print_r($_POST); -cb- Quote Link to comment https://forums.phpfreaks.com/topic/198798-inserting-into-table/#findComment-1043371 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.