What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Sign up & SQL table problem

Sign up & SQL table problem
Author: Message:
zaher1988
Senior Member
****

Avatar
Inseperable

Posts: 699
Reputation: 10
36 / Male / Flag
Joined: Jun 2005
Status: Away
O.P. Sign up & SQL table problem
Hey!

i'm working on a simple sign up form. that's consisted to 4 pages, 2 html and 2 php

signup.htm make.php login.htm getin.php

and using a server running PHP, mySQL, and phpMyAdmin. i have created a mySQL table which will store the user's name and password when they create it. and, logged on to phpMyAdmin, and select the database. My database is called "easyflas_testdb". Inside the database, i made  a table, called it "users" and have 4 columns for it.

id - INT (auto increment, primary)
username - text
password -  text
email -  text

so i made the user and password, i setup the host and the database!. all are fine till now

and then i went ahead and start making my signup form which starts with the page signup.htm and has this code:

<form action="make.php" method="post">
Username Desired: <input type="text" name="username" size="10">
Password Desired: <input type="password" name="password" size="10">
E-mail: <input type="text" name="email" size="10">
<input type="submit" value="submit" name="submit">
</form>


then i started with my make.php page which will post the info to the SQL data base, make.php has this code:


<?
$conn = mysql_connect("localhost","MYUSER","PASSWORD");


$db = mysql_select_db("easyflas_testdb");

$username = $_POST["username"];
$password = $_POST["password"];
$email = $_POST["email"];


$result= MYSQL_QUERY("INSERT INTO users (id, username, password, email)".
   "VALUES ('NULL', '$username', '$password', '$email')");
   
echo "Your name and password have been submitted into our database :)";
?>


ok done from this test it and no errors it says "Your name and password have been submitted into our database"

but these info are not submited into the TABLE! i checked it times and times, and still telling me that it was submited , but it's not actually.

now i tried anyway to signin using info i used in the signup page using this page login.htm which has this code:

<form action="getin.php" method="post">
Username: <input type="text" name="username" size="10">
Password: <input type="password" name="password" size="10">
<input type="submit" value="submit" name="submit">
</form>


and followed by the page getin.php which is :

<?
$conn = mysql_connect("localhost","MYUSER","PASSWORD");
$db = mysql_select_db("easyflas_testdb");

$username = $_POST["username"];
$password = $_POST["password"];

$result = MYSQL_QUERY("SELECT * from users WHERE username='$username'and password='$password'")
   or die ("Name and password not found or not matched");

$worked = mysql_fetch_array($result);

$username = $worked[username];
$password = $worked[password];
$email = $worked[email];


if($worked)
   echo "Welcome $user! Your e-mail address is $email";
?>



but it's telling"Name and password not found or not matched" me though i also tried to enter these info manually from inside the phpAdmin page! not using the form , so in both cases it's not working .


so please if anybody knows what may be happening i will be thankfull for him:)

thanks in advance


This post was edited on 09-16-2005 at 03:15 PM by zaher1988.
09-16-2005 12:42 PM
Profile E-Mail PM Web Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
Joined: Mar 2002
RE: Sign up & SQL table problem
Maybe you should add the "or die()" error handling to the mysql_connect() and mysql_select_db() lines as well as the mysql_query() in make.php. That should help you debug the scripts.

BTW, it looks like you have a typo in make.php...

$db = mysql_select_db("easyflas_testdp");
09-16-2005 02:32 PM
Profile PM Web Find Quote Report
zaher1988
Senior Member
****

Avatar
Inseperable

Posts: 699
Reputation: 10
36 / Male / Flag
Joined: Jun 2005
Status: Away
O.P. RE: Sign up & SQL table problem
quote:
Originally posted by WDZ
BTW, it looks like you have a typo in make.php...

$db = mysql_select_db("easyflas_testdp");

no hehe it's just by mistake , on the server it's correct :)
09-16-2005 02:56 PM
Profile E-Mail PM Web Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: Sign up & SQL table problem
code:
$result=mysql_query("INSERT INTO users(`id`,`username`,`password`,`email`) VALUES ('', '" . $username . "', '" . $password . "', '" . $email . "')");
09-16-2005 06:27 PM
Profile E-Mail PM Find Quote Report
zaher1988
Senior Member
****

Avatar
Inseperable

Posts: 699
Reputation: 10
36 / Male / Flag
Joined: Jun 2005
Status: Away
O.P. RE: Sign up & SQL table problem
Well i found the submited info in the table but they were like this

" . $username . " " . $password . " " . $email . "

This post was edited on 09-16-2005 at 07:13 PM by zaher1988.
09-16-2005 07:10 PM
Profile E-Mail PM Web Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: Sign up & SQL table problem
Place:
code:
error_reporting(E_ALL);

at the top of the scripts to see all the errors. And do:
code:
print mysql_error();

After the query's to see the errors.

btw: there's missing a space after AND in your second query
09-16-2005 07:16 PM
Profile E-Mail PM Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: Sign up & SQL table problem
That's strange...attach the php files here, i think you may have made a copy / paste error...^o)
09-16-2005 07:17 PM
Profile E-Mail PM Find Quote Report
zaher1988
Senior Member
****

Avatar
Inseperable

Posts: 699
Reputation: 10
36 / Male / Flag
Joined: Jun 2005
Status: Away
O.P. RE: Sign up & SQL table problem
Here's the files :)

.rar File Attachment: php.rar (778 bytes)
This file has been downloaded 127 time(s).
09-16-2005 07:25 PM
Profile E-Mail PM Web Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: Sign up & SQL table problem
I see 3 database names...

In your post you say it's easyflas_testdb, in the php files it's easyflas_spoonodb and spoono_db. Are you sure that's correct!

Besides that, you are making a lot of thinking mistakes. The first:

code:
<?
error_reporting(E_ALL);

//replace username and password with your mysql name and password
$conn = mysql_connect("localhost","easyflas_zaher19","okk");

//select the database
$db = mysql_select_db("easyflas_spoonodb");

$username = $_POST["username"];
$password = $_POST["password"];
$email = $_POST["email"];

//insert the values
$result=mysql_query("INSERT INTO users(`id`,`username`,`password`,`email`) VALUES ('', '" . $username . "', '" . $password . "', '" . $email . "')");
   
if($result) {
   echo "Your name and password have been submitted into our database :)";
}
else {
   echo "Error while inserting: " . mysql_error();
}
?>

The second:
code:
<?
error_reporting(E_ALL);

$conn = mysql_connect("localhost","eastflas_zaher19","okk");
$db = mysql_select_db("spoono_db");

$username = $_POST["username"];
$password = $_POST["password"];

$result = mysql_query("SELECT * from users WHERE username='" . $username . "' ABD password='" . $password . "'")
   or die ("Error in your query: " . mysql_error());

if(mysql_num_rows($result) > 0) {
   $worked = mysql_fetch_array($result);
   
   $username = $worked['username'];
   $password = $worked['password'];
   $email = $worked['email'];
   
   echo "Welcome $user! Your e-mail address is $email";
}
else {
   echo "No username / password match found!";
}
?>


And off course first look at the database names. This should work...
09-17-2005 09:22 AM
Profile E-Mail PM Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On