Pain Posted October 15, 2011 Share Posted October 15, 2011 Im trying to build mysql php user registration. For some reason i cannot insert values into my database. <?php $submit = $_POST['submit']; $fullname = strip_tags($_POST['fullname']); $username = strip_tags($_POST['username']); $password = strip_tags($_POST['password']); // Connect the database $connection = mysql_connect("bla", "bla", "bla") or die ("Could not connect"); mysql_select_db("my_db", $connection); // mysql query $query = "INSERT INTO users VALUES (''. 'fullname', 'username', 'password')"; mysql_query($query); echo "You have successfully registered"; ?> Any help spotting the error would be appreciated! Link to comment https://forums.phpfreaks.com/topic/249174-user-registration/ Share on other sites More sharing options...
litebearer Posted October 15, 2011 Share Posted October 15, 2011 hint: '$fullname' NOT 'fullname' etc Link to comment https://forums.phpfreaks.com/topic/249174-user-registration/#findComment-1279582 Share on other sites More sharing options...
Pain Posted October 15, 2011 Author Share Posted October 15, 2011 Oops, i didn't put entire script. <?php // Header echo "<h1>Register</h1>"; $submit = $_POST['submit']; $fullname = strip_tags($_POST['fullname']); $username = strip_tags($_POST['username']); $password = strip_tags($_POST['password']); // Connect the database $connection = mysql_connect("blabla", "blabla", "blabla") or die ("Could not connect"); mysql_select_db("866075_db", $connection); // Mysql query $query = "INSERT INTO users VALUES (''. '$fullname', '$username', '$password')"; mysql_query($query); echo "You have successfully registered"; ?> <html> <form action="register.php" method="POST" /> <table> <tr> <td> Name: </td> <td> <input type="text" name="fullname" value="<?php echo $fullname;?>"/> </td> </tr> <tr> <td> Username: </td> <td> <input type="text" name="username" /> </td> </tr> <tr> <td> Password: </td> <td> <input type="password" name="password" /> </td> </tr> </table> <input type="submit" name="submit" value="Register" /> </html> Link to comment https://forums.phpfreaks.com/topic/249174-user-registration/#findComment-1279583 Share on other sites More sharing options...
Pain Posted October 15, 2011 Author Share Posted October 15, 2011 maybe i should add [code] <?php ... if ($submit) { ... } else { echo "error"; } ... ?> and it would be something like: <?php ... if ($submit) { // Connect the database $connection = mysql_connect("blabla", "blabla", "blabla") or die ("Could not connect"); mysql_select_db("866075_db", $connection); // mysql query $query = "INSERT INTO users VALUES (''. '$fullname', '$username', '$password')"; mysql_query($query); echo "You have successfully registered"; } else { echo "Something went wrong"; } ... ?> Link to comment https://forums.phpfreaks.com/topic/249174-user-registration/#findComment-1279585 Share on other sites More sharing options...
Pain Posted October 15, 2011 Author Share Posted October 15, 2011 I have fixed that, thank you. Link to comment https://forums.phpfreaks.com/topic/249174-user-registration/#findComment-1279587 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.