jimlawrnc Posted November 14, 2007 Share Posted November 14, 2007 When i run the following <html> <head> <title>Add New User</title> </head> <body> <?php if(isset($_POST['add'])) { include 'config/config.php'; include 'config/opendb.php'; $username = $_POST['username']; $fname = $_POST['fname']; $lname = $_POST['lname']; $password = $_POST['password']; $email = $_POST['email']; $passwordHash = sha1($_POST['password']); //Add the new user to the table $query = "INSERT INTO members (username, fname, lname, user_password, email) VALUES ('$username', '$fname', '$lname', '$passwordHash', '$email')"; mysql_query($query) or die (mysql_error()); print $query; echo "New user added"; } else { ?> <br/> <br/> <center> <font face='verdana, arial, helvetica' size='2' align='center'>Enter the requested Username and Password </font> <form method="post"> <table width="400" border="0" cellspacing="1" cellpadding="2" > <tr> <td width="100" ><font face='verdana, arial, helvetica' size='2' align='center'>Username</font></td> <td><input name="username" type="text" id="username"></td> </tr> <tr> <td width="100"><font face='verdana, arial, helvetica' size='2' align='center'>Password</td> <td><input name="password" type="text" id="password"></font></td> </tr> <tr> <td width="100" ><font face='verdana, arial, helvetica' size='2' align='center'>First Name</font></td> <td><input name="username" type="text" id="fname"></td> </tr> <tr> <td width="100" ><font face='verdana, arial, helvetica' size='2' align='center'>Last Name</font></td> <td><input name="username" type="text" id="lname"></td> </tr> <tr> <td width="100" ><font face='verdana, arial, helvetica' size='2' align='center'>E-mail</font></td> <td><input name="username" type="text" id="email"></td> </tr> <tr> <td width="100"> </td> <td> </td> </tr> <tr> <td width="100"> </td> <td><font face='verdana, arial, helvetica' size='2' align='center'><input name="add" type="submit" id="add" value="Add New User"></font></td> </tr> </table> </form></center> <? } ?> </body> </html> the table gets updated with the username bring the email address and the password getting the hashed password. the other fields are empty Printed to the screen INSERT INTO members (username, fname, lname, user_password, email) VALUES ('[email protected]', '', '', '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8', '')New user added Any ideas? Link to comment https://forums.phpfreaks.com/topic/77253-solved-baffled-with-this-script/ Share on other sites More sharing options...
PyraX Posted November 14, 2007 Share Posted November 14, 2007 yeah change the names of you form fields so the matchup Link to comment https://forums.phpfreaks.com/topic/77253-solved-baffled-with-this-script/#findComment-391104 Share on other sites More sharing options...
pocobueno1388 Posted November 14, 2007 Share Posted November 14, 2007 Most of your form fields are named "username", then you have the "id" attribute as the name, you want to switch that. So, you form should look like this: <center> <font face='verdana, arial, helvetica' size='2' align='center'>Enter the requested Username and Password </font> <form method="post"> <table width="400" border="0" cellspacing="1" cellpadding="2" > <tr> <td width="100" ><font face='verdana, arial, helvetica' size='2' align='center'>Username</font></td> <td><input name="username" type="text" id="username"></td> </tr> <tr> <td width="100"><font face='verdana, arial, helvetica' size='2' align='center'>Password</td> <td><input name="password" type="text" id="password"></font></td> </tr> <tr> <td width="100" ><font face='verdana, arial, helvetica' size='2' align='center'>First Name</font></td> <td><input name="fname" type="text" id="fname"></td> </tr> <tr> <td width="100" ><font face='verdana, arial, helvetica' size='2' align='center'>Last Name</font></td> <td><input name="lname" type="text" id="lname"></td> </tr> <tr> <td width="100" ><font face='verdana, arial, helvetica' size='2' align='center'>E-mail</font></td> <td><input name="email" type="text" id="email"></td> </tr> <tr> <td width="100"> </td> <td> </td> </tr> <tr> <td width="100"> </td> <td><font face='verdana, arial, helvetica' size='2' align='center'><input name="add" type="submit" id="add" value="Add New User"></font></td> </tr> </table> </form></center> Link to comment https://forums.phpfreaks.com/topic/77253-solved-baffled-with-this-script/#findComment-391105 Share on other sites More sharing options...
jimlawrnc Posted November 14, 2007 Author Share Posted November 14, 2007 you can tell my day ha been to long thanks Link to comment https://forums.phpfreaks.com/topic/77253-solved-baffled-with-this-script/#findComment-391106 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.