Jump to content


Photo

Login Form


  • Please log in to reply
2 replies to this topic

#1 webdogjcn

webdogjcn
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts

Posted 14 May 2006 - 01:57 PM

Here is the coding for the login form:
<?php
$name="";
$lock="";
$database="";

$user=$_POST['username'];
$pass=$_POST['password'];

mysql_connect(localhost,$name,$lock);
@mysql_select_db($database) or die( "Unable to select database");
$sql="SELECT user_name FROM user_info WHERE user_name='$user' and password=’$pass’”;
$r = mysql_query($sql);
if(!$r) {
$err=mysql_error();
print $err;
exit();
}
if(mysql_affected_rows()==0){
print "no such login in the system. please try again.";
exit();
}
else{
print "successfully logged into system.";
//HOW WOULD I GET IT TO REDIRECT AND INCLUDE SOME VARIABLE VALUES IN THE URL?
exit;
}
?>

returns the error:

Parse error: parse error, unexpected T_STRING in /home/www/altgames.awardspace.com/login.php on line 19

when I try to login. Also (as you will see in the comment string above), how would I go about refirecting the URL and include information such as username, for creating a member page? EG [a href=\"http://mypage.com/user.htm?name=blah&pass=true\" target=\"_blank\"]http://mypage.com/user.htm?name=blah&pass=true[/a]


#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 14 May 2006 - 02:06 PM

You already have a thread going about exactly the same thing - [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=93366\" target=\"_blank\"]http://www.phpfreaks.com/forums/index.php?showtopic=93366[/a]

Please DO NOT post the same problem more than once. Continue the thread you started since that'll ensure that the solution ends up in one place where anybody can find it.

And - did you follow any of the advice given in the responses to the earlier thread? Those smart quotes are still there: whether you wrote it in Notepad or not, change them to a normal quote.
Legend has it that reading the manual never killed anyone.
My site

#3 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 14 May 2006 - 02:06 PM

you need:

mysql_connect('localhost',$name,$lock);

and for your second question you just need to use 'header' to redirect the browser, providing that nothing has up to that point been output:

header("Location: http://mypage.com/user.htm?name=$user&pass=true");
exit;

"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users