A
Anonymous
Guest
I have a small script that tries to match the username and password ($_POST[Username], $_POST[Password]) submitted from a form to a row in a MySQL table.
This is my script. When it executes, there are no errors, but it just gives me a blank page, when it should really say either "Welcome..." or "there was an error". I did insert a row already into my table and I *am* inputting the right username and password. What's wrong?
This is my script. When it executes, there are no errors, but it just gives me a blank page, when it should really say either "Welcome..." or "there was an error". I did insert a row already into my table and I *am* inputting the right username and password. What's wrong?
Code:
<?php
$Success=0;
$M_Conn=mysql_connect (localhost,"root","some_pass");
mysql_select_db ("member_area",$M_Conn);
$SQL="SELECT Username,Password,Full_name,Email_address,Age FROM Members WHERE Username='$_POST[Username]' AND Password='$_POST[Password]'";
$Fulltable=mysql_query($SQL,$M_Conn);
if (mysql_num_rows($Fulltable) == 1) {
/* Found a match. Now retrieve the data from the proper row. */
$Row=mysql_fetch_array($Fulltable);
$Success=1;
}
if ($Success != 0) {
$HTML="<html><head><title>Logged in</title></head><body><h1>Welcome</h1>";
$HTML .= "Welcome, $Row['Full_name'].<br>Your email address is $Row['Email_address'].<br>";
$HTML .= "You are $Row['Age'].</body></html>"
echo $HTML;
}
else {
$HTML="<html><head><title>Error</title></head><body>There was an error signing in - make sure that you supplied";
$HTML="the right username and password.</body></html>";
echo $HTML;
}
mysql_close($M_Conn);
?>