Page 1 of 1

Processing Login with DB

Posted: Sat Feb 04, 2006 9:39 pm
by nickman013
Hello,

I have a login form that gets processed to see if the user and password match up and exist in the DB.

this is my processor

Code: Select all

<? 
error_reporting(E_ALL); 
$username= "muot_users";  
$password= "users";  
$database= "muot_users";  
mysql_connect('localhost',$username,$password) or die(mysql_error());  
mysql_select_db($database) or die(mysql_error()); 
exit();
session_start();   
if (empty($_POST['user']) || empty($_POST['pass']))  
header("Location:/newsite/login/login1.php");
//rather than checking for a particular user, check if the user exists in a database 
$query = "SELECT * FROM users where username = '".mysql_real_escape_string($_POST['user'])."' AND `password` = password('".mysql_real_escape_string($_POST['pass'])."')"; 
$result = mysql_query($query); 
if (!$result) die(mysql_error()); 
if(mysql_num_rows($result) < 0) 
//if ($_POST['user'] == 'nicky' && $_POST['pass'] == 'nickypass')  
{  
$_SESSION['log'] = true;  
//echo '<meta http-equiv="refresh" content="0;url=secure_page.php">';  
}  
else  
?>
I am getting this parse error
Parse error: parse error, unexpected T_STRING in /home/muot/public_html/newsite/login/login.php on line 11
Line 11 is
header("Location:/newsite/login/login1.php");

Posted: Sat Feb 04, 2006 9:43 pm
by josh
This code parses just fine for me.

Posted: Sat Feb 04, 2006 9:46 pm
by nickman013
It must have been hidden characters, becasue I copy and pasted it from this forum , and it parsed for me too.

But, it just comes up as a white page, nothing on it.

Posted: Sat Feb 04, 2006 9:50 pm
by josh
That's because of your call to exit(); which I asked you to put in there so we could focus on your database connection part, remove that and you should be good.

Posted: Sat Feb 04, 2006 9:58 pm
by nickman013
Ok, now i get this
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where username = 'mmm' AND `password` = password('mmm')' at line 1

Posted: Sun Feb 05, 2006 3:25 pm
by nickman013
I solved it, but I used a different script.

I was searching on hotscripts and came across a very GOOD tutorial.

It worked perfect.

If anybody out there is looking for a MYSQL/ PHP login member system definately go to this tutorial.

:arrow: http://codewalkers.com/tutorials/82/