waelkd Posted August 15, 2010 Share Posted August 15, 2010 hello , could anyone please point me on how can i read the data i input from an html page to appear on the mysql front server. ive print screen my problem this is the signup page ,where i input the user name and password here's the signup page html code """<html> <head> </head> <body> <h1>Personal Info</h1> <form name="form" method="post" action="SignUp.php"> <p>UserName:<input type="text" name="usrn" /></p> <p>Password:<input type="password" name="pass" /></p> <p><input type="submit" value="Sign Up"/> <input type="submit" value="Clear" /></p> </form> </body> </html> """"" and this is the mysqlserver ,where i want the username and password i entered to show here's the php code i wrote """"<?php $usr=$_POST["usrn"]; $pass=$_POST["pass"]; $db=mysql_connect("localhost","root",""); mysql_select_db("realestate",$db); $q="insert into Customer Values('$usr','$pass')"; mysql_query($q); mysql_close(); ?>""""" i would really appreciate any help from you guys. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/210768-php-and-mysql-front-question/ Share on other sites More sharing options...
wildteen88 Posted August 15, 2010 Share Posted August 15, 2010 From the screenshot you posted of MySQL Front it is showing that you have created a database called signup with a table called username, which contains 3 fields called id, username and password However in your code you're using the database realestate, mysql_select_db("realestate",$db) and adding the username/password to the Customer table. $q="insert into Customer Values('$usr','$pass')" You sure this is the correct database/table to use? Quote Link to comment https://forums.phpfreaks.com/topic/210768-php-and-mysql-front-question/#findComment-1099481 Share on other sites More sharing options...
waelkd Posted August 15, 2010 Author Share Posted August 15, 2010 i reedited the mysql ,removed the id tab, now its only username and password and i reedited the code <?php $usr=$_POST["usrn"]; $pass=$_POST["pass"]; $db=mysql_connect("localhost","root",""); mysql_select_db("SignUp",$db); $q="SignUP('$usr','$pass')"; mysql_query($q); mysql_close(); ?> but it still doesnt work. ive been working on this part all day long , i just want the username and password i enter in the signup page to appear in the mysql .ahh this is frustrating. and appreciate ur help Quote Link to comment https://forums.phpfreaks.com/topic/210768-php-and-mysql-front-question/#findComment-1099496 Share on other sites More sharing options...
wildteen88 Posted August 15, 2010 Share Posted August 15, 2010 Your query is invalid. The correct way to insert values into a mysql table would be INSERT INTO table_name VALUES ('value1', 'value2' etc). or INSERT INTO table_name SET field1='value1, field2='value2', etc So to insert the username/password into the signup table. You'd write the query as $q="INSERT INTO signup VALUES ('$usr', '$pass')"; To perform the query you'd pass the variable $p to mysql_query. mysql_query($q); if you query is not working, then run mysql_error to get the error message from the last executed query. mysql_query($q) or trigger_error("Error with query: $q<br />Error: " . mysql_error(), E_USER_ERROR); Quote Link to comment https://forums.phpfreaks.com/topic/210768-php-and-mysql-front-question/#findComment-1099499 Share on other sites More sharing options...
waelkd Posted August 15, 2010 Author Share Posted August 15, 2010 i did what u said and still nothing, emm any new idea's?? <?php $usr=$_POST["usrn"]; $pass=$_POST["pass"]; $db=mysql_connect("localhost","root",""); mysql_select_db("SignUp",$db); $q="INSERT INTO SignUp VALUES ('$usr', '$pass')"; mysql_query($q); mysql_close(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/210768-php-and-mysql-front-question/#findComment-1099506 Share on other sites More sharing options...
wildteen88 Posted August 15, 2010 Share Posted August 15, 2010 You have filled in your form first and submitted it? If it's still not inserting then change mysql_query($q); to mysql_query($q) or trigger_error("Error with query: $q<br />Error: " . mysql_error(), E_USER_ERROR); Your code is correct and should be inserting something into your database. In MySQL Front make sure you refreshing the table view each time you add a new record. Quote Link to comment https://forums.phpfreaks.com/topic/210768-php-and-mysql-front-question/#findComment-1099509 Share on other sites More sharing options...
Pikachu2000 Posted August 15, 2010 Share Posted August 15, 2010 Your table name and database name are not `SignUp`, they're `signup`. Which leads to another question, why name the table the same as the database? That's going to get confusing . . . Quote Link to comment https://forums.phpfreaks.com/topic/210768-php-and-mysql-front-question/#findComment-1099519 Share on other sites More sharing options...
waelkd Posted August 15, 2010 Author Share Posted August 15, 2010 i followed Pikachu2000 comemnt about SignUp and signup and it worked, now the problem am having is the username and password taken could only be numerical , need to change them to alaphabatic, but i think it wont be very hard figuring how to do it. anyways thx so much wildteen and Pikachu2000 i really really apreciate ur help. Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/210768-php-and-mysql-front-question/#findComment-1099643 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.