cfgcjm Posted January 21, 2008 Share Posted January 21, 2008 I'm trying to write a simple registration script but i can't get it to write to my database...any ideas? <?php require ('mysql.php'); if (isset ($_POST['submit'])) { $username = $_POST['username']; $psend=$_POST['password']; $password = md5 ($_POST['password']); $first_name=$_POST['first_name']; $last_name=$_POST['last_name']; $email=$_POST['email']; $interest=$_POST['interest']; $food=$_POST['food']; $sport=$_POST['sport']; $add_sql = "INSERT INTO users (users_id, username, password, first_name, last_name, email, interest, fav_food, sport) VALUES (0, '$username', '$password', '$first_name', '$last_name', '$email', '$interest', '$food', '$sport')"; } ?> Link to comment https://forums.phpfreaks.com/topic/86977-solved-registration-script/ Share on other sites More sharing options...
Nhoj Posted January 21, 2008 Share Posted January 21, 2008 <?php $add_sql = "INSERT INTO users (users_id, username, password, first_name, last_name, email, interest, fav_food, sport) VALUES (0, '$username', '$password', '$first_name', '$last_name', '$email', '$interest', '$food', '$sport')"; ?> Should be: <?php mysql_query("INSERT INTO users (users_id, username, password, first_name, last_name, email, interest, fav_food, sport) VALUES (0, '$username', '$password', '$first_name', '$last_name', '$email', '$interest', '$food', '$sport')"); ?> Also, you should definately look into SQL-Injection as you are wide open to it... Link to comment https://forums.phpfreaks.com/topic/86977-solved-registration-script/#findComment-444731 Share on other sites More sharing options...
cfgcjm Posted January 21, 2008 Author Share Posted January 21, 2008 still doesn't post to the database ??? Link to comment https://forums.phpfreaks.com/topic/86977-solved-registration-script/#findComment-444734 Share on other sites More sharing options...
Nhoj Posted January 21, 2008 Share Posted January 21, 2008 cfgcjm, Double check everything, ensure you are properly able to even establish a connection to the database in the mysql.php file which is included at the top. Also, be sure your query is valid, make sure the column names and everything also line up. Link to comment https://forums.phpfreaks.com/topic/86977-solved-registration-script/#findComment-444735 Share on other sites More sharing options...
teng84 Posted January 21, 2008 Share Posted January 21, 2008 mysql_query("INSERT INTO users (users_id, username, password, first_name, last_name, email, interest, fav_food, sport) VALUES (0, '$username', '$password', '$first_name', '$last_name', '$email', '$interest', '$food', '$sport')") or die(mysql_error()); try to see the error( add error reporting ) Link to comment https://forums.phpfreaks.com/topic/86977-solved-registration-script/#findComment-444737 Share on other sites More sharing options...
cfgcjm Posted January 21, 2008 Author Share Posted January 21, 2008 it showed just a blank window...no error, in both FF and IE however when i submit the form which is register.php it changes the address to accept.php (which is correct) but it is appended as this: http://digiconmediagroup.com/Homeplate/portal/accept.php?username=brinser&password1=1234&password2=1234&fname=chris&interest=food&lname=Miller&food=hotdog&[email protected]&sport=football&submit=submit ...the form data Link to comment https://forums.phpfreaks.com/topic/86977-solved-registration-script/#findComment-444739 Share on other sites More sharing options...
Nhoj Posted January 21, 2008 Share Posted January 21, 2008 You're using if (isset ($_POST['submit'])) { and a bunch of $_POST variables... The url you gave us indicates you're using method="get" on the html form itself... Change the method to "post" and it should work. Link to comment https://forums.phpfreaks.com/topic/86977-solved-registration-script/#findComment-444741 Share on other sites More sharing options...
revraz Posted January 21, 2008 Share Posted January 21, 2008 Assuming the users_id is a auto_increment field, don't enter 0 into it. Looks like you have a form method = GET somewhere. Link to comment https://forums.phpfreaks.com/topic/86977-solved-registration-script/#findComment-444743 Share on other sites More sharing options...
cfgcjm Posted January 21, 2008 Author Share Posted January 21, 2008 Wow...i actually never specified a method...my bad on the near pointless post Link to comment https://forums.phpfreaks.com/topic/86977-solved-registration-script/#findComment-444744 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.