|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today! |
|
#1
|
|||
|
|||
|
problem wit log in
Could anyone help me with this problem. I'm new to php so dont really know wot i'm doing!! I'm trying to log on
My code is below <?PHP print_r($HTTP_POST_VARS); $username = $HTTP_POST_VARS['username']; $password = $HTTP_POST_VARS['password']; $connection=mysql_connect("localhost","pp","mm") or die('Could not connect to the database server'); $rs = mysql_select_db("test", $connection) or die ("Unable to select database."); $sql="select from firsttimevoter where username='" . $HTTP_POST_VARS['username'] . "' and password= password('" . $HTTP_POST_VARS['password'] . "')"; print $sql; $rs = mysql_query($sql, $connection) or die (mysql_error()); #get number of rows that match username and password $num=mysql_numrows($rs); #if there is a match the log in is authenticated if($num!=0) { $msg="Welcome $username - your log-in succeeded!"; } else #return to login page { header("Location:$HTTP_REFERER"); exit();} ?> <HTML> <HEAD><TITLE>Log-In authenticated</TITLE></HEAD><BODY> <?php echo($msg); ?></BODY> </HTML> THe following is coming up Array ( [username] => bob [password] => bob ) select from firsttimevoter where username='bob' and password= password('bob')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 'from firsttimevoter where username='bob' and password= password Any help would be greatly appreciated |
|
#2
|
|||
|
|||
|
RE: problem wit log in
You need to tell MySQL which field you want to select. For example
> select username, password from ... or > select * from ... I think that should fix your problem... |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > problem wit log in |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|