logged_with_bugmenot Posted June 18, 2007 Share Posted June 18, 2007 Hi guys another signup script, I've been reading here for a few hours now and still can't solve my problem so I decided to post here. Anyways the problem is the data isn't getting to the mysql here's my code by the way the signup is more of a add user script and is only available once someone has signed in: http://privatepaste.com/d915cqIufh Quote Link to comment https://forums.phpfreaks.com/topic/56031-very-simple-singup-script/ Share on other sites More sharing options...
aniesh82 Posted June 18, 2007 Share Posted June 18, 2007 You did not specify the action page on the form. <form method="post" name="frmadd" id="frmadd"> Change to : <form method="post" name="frmadd" id="frmadd" action="NameOFactionPAge.php"> The user name and password to connect to your mysql database is available on the page. It may be misused. So please delete the page as soon as possible. Quote Link to comment https://forums.phpfreaks.com/topic/56031-very-simple-singup-script/#findComment-276729 Share on other sites More sharing options...
logged_with_bugmenot Posted June 18, 2007 Author Share Posted June 18, 2007 Ah, I tried adding that but didn't help and my login script doesn't specify a action and continues to work. I made another script which directly inserts a name and password with no form and that worked so I think it has to be something with my syntax, any other ideas? Quote Link to comment https://forums.phpfreaks.com/topic/56031-very-simple-singup-script/#findComment-276734 Share on other sites More sharing options...
aniesh82 Posted June 18, 2007 Share Posted June 18, 2007 Please use the following lines of code: <?php if ($_POST['user'] != NULL && $_POST['pass'] != NULL ) { /* Please add the two lines of code to connect to your MySql and select MySql Database */ $user = $_POST['user']; $pass = $_POST['pass']; $query=mysql_query("INSERT INTO users_logins (user_id, user_password) VALUES ('$user', PASSWORD('$pass'))") or die('Error' . mysql_error()); mysql_close($con); } ?> <h1>Login successful</h1> <form method="post" name="frmadd" id="frmadd" action="action.php"> <input name="user" type="text" id="user"> <input name="pass" type="password" id="pass"> <input type="submit" name="btnadd" value="Add"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/56031-very-simple-singup-script/#findComment-276736 Share on other sites More sharing options...
logged_with_bugmenot Posted June 18, 2007 Author Share Posted June 18, 2007 Still no go, I thought that would be right to. *looks for something to blame* Quote Link to comment https://forums.phpfreaks.com/topic/56031-very-simple-singup-script/#findComment-276739 Share on other sites More sharing options...
aniesh82 Posted June 18, 2007 Share Posted June 18, 2007 Did you add the lines for connecting to MySql and select Database. Are you sure that database and table with the same name exists ? Also please check after submit the form, it goes to the same page. One change needed: 1. Change the action page with name of your action page The you assign the sql query to a variable and prints it: $sql ="INSERT INTO users_logins (user_id, user_password) VALUES ('$user', PASSWORD('$pass'))"; echo $sql; exit(); $query=mysql_query($sql); Quote Link to comment https://forums.phpfreaks.com/topic/56031-very-simple-singup-script/#findComment-276744 Share on other sites More sharing options...
aniesh82 Posted June 18, 2007 Share Posted June 18, 2007 Add this lines to check whether your program makes successful connection with database $con = mysql_connect('mysql2.freehostia.com','greval5_greval5','somepassword') or die("Couldnot connect to MySql"); mysql_select_db("greval5_greval5",$con) or die("Couldnot select Database"); Quote Link to comment https://forums.phpfreaks.com/topic/56031-very-simple-singup-script/#findComment-276746 Share on other sites More sharing options...
logged_with_bugmenot Posted June 18, 2007 Author Share Posted June 18, 2007 I made the action the same script (main.php) and also changed the query with the most current line you gave me and it did not return the error and the echo was: INSERT INTO users_logins (user_id, user_password) VALUES ('john', PASSWORD('smith')) also the tables do exist because I'm able to login using the users i created through phpmyadmin sql interface... very odd... Quote Link to comment https://forums.phpfreaks.com/topic/56031-very-simple-singup-script/#findComment-276765 Share on other sites More sharing options...
aniesh82 Posted June 18, 2007 Share Posted June 18, 2007 Please copy the line of text and run using phpmyadmin INSERT INTO users_logins (user_id, user_password) VALUES ('john', PASSWORD('smith')) Quote Link to comment https://forums.phpfreaks.com/topic/56031-very-simple-singup-script/#findComment-276775 Share on other sites More sharing options...
logged_with_bugmenot Posted June 18, 2007 Author Share Posted June 18, 2007 I ran INSERT INTO users_logins (user_id, user_password) VALUES ('john', PASSWORD('smith')) and it added the user: Full Texts user_id user_password Edit Delete cross 46c3909c48c7e704 Edit Delete sam 7888350b26333e97 Edit Delete john 1dacdbf749f8f2a9 somewhere it mustn't be inserting anything. Quote Link to comment https://forums.phpfreaks.com/topic/56031-very-simple-singup-script/#findComment-276780 Share on other sites More sharing options...
aniesh82 Posted June 18, 2007 Share Posted June 18, 2007 The records added successfully => john 1dacdbf749f8f2a9 Quote Link to comment https://forums.phpfreaks.com/topic/56031-very-simple-singup-script/#findComment-276785 Share on other sites More sharing options...
logged_with_bugmenot Posted June 18, 2007 Author Share Posted June 18, 2007 Yeah, but I want to add it through the script this was through phpmyadmin really odd Quote Link to comment https://forums.phpfreaks.com/topic/56031-very-simple-singup-script/#findComment-276792 Share on other sites More sharing options...
aniesh82 Posted June 18, 2007 Share Posted June 18, 2007 I think some connection problem still existing. Could you replace the sql query with this ? $sql = 'SELECT * FROM users_logins"; $re = mysql_query($sql); echo "Th e number of Records ".mysql_num_rows($re); If the connection is established, then it will output the number of records in user_logins table. Quote Link to comment https://forums.phpfreaks.com/topic/56031-very-simple-singup-script/#findComment-276813 Share on other sites More sharing options...
logged_with_bugmenot Posted June 18, 2007 Author Share Posted June 18, 2007 Hmm, it outputs "Th e number of Records 3" this is weird Quote Link to comment https://forums.phpfreaks.com/topic/56031-very-simple-singup-script/#findComment-276834 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.