Jump to content

php and mysql front question


waelkd

Recommended Posts

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

 

signuppage.jpg

 

 

 

 

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

sqlfront.jpg

 

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

i reedited the mysql ,removed the id tab, now its only username and password

 

sqlfront1.jpg

 

 

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

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

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();

?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.