Jump to content


Photo

login code error


  • Please log in to reply
5 replies to this topic

#1 Jay2391

Jay2391
  • Members
  • PipPipPip
  • Advanced Member
  • 167 posts
  • LocationMichigan

Posted 20 September 2006 - 03:48 AM

I hace a DB with a table

table fields are

userID
user
pass
email

I am getting this error???


Parse error: syntax error, unexpected $end in /home/jreina88/public_html/natgal/login.php on line 59

that is the last line ...

can some one help this is the code



this is the code!!!!

<? session_start() ?>
<HTML>
<HEAD>
<TITLE>Login</TITLE>
</HEAD>
<BODY>
<H2>Login</H2>

<?php

    $links = "<A HREF='main.php'>Click here to proceed to the main page</A><BR><BR><A HREF='logout.php'>Click here to log out.</A>";

if($user && $pass){
      if ($logged_in_user == $user) {
echo $user.", you are already logged in.<BR><BR>";
echo $links;
exit;
}

$db=mysql_connect ("localhost", "ID", "pass")
or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db("database name");


$result = mysql_query("SELECT * FROM tablename WHERE user = '".$user."' AND password = PASSWORD('".$pass."')");

    if (!$result) {
echo "Sorry, there has been a technical hitch. We cannot enter your details.";
exit;
}

    if(mysql_num_rows($result) > 0 ){
    $logged_in_user = $user;
    session_register("logged_in_user");
            echo "Welcome, ".$logged_in_user.". <br><br>";
            echo $links;
            exit;
    }

  else {
    echo "Invalid login. Please try again.<br><br>";
  }
// else if ($user || $pass) {
//     echo "Please fill in both fields.<BR><BR>";
// }
?>


<FORM METHOD=POST ACTION="login.php">
Your username:
<INPUT NAME="user" TYPE=TEXT MAXLENGTH=20 SIZE=20>
<BR>
Your password:
<INPUT NAME="pass" TYPE=PASSWORD MAXLENGTH=10 SIZE=10>
<BR>
<INPUT TYPE=SUBMIT VALUE="Login">
</FORM>
</BODY>
</HTML>

#2 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 20 September 2006 - 03:53 AM

r u giving all source the error says its on 59 and theres only 49 there if i am correct

#3 Jay2391

Jay2391
  • Members
  • PipPipPip
  • Advanced Member
  • 167 posts
  • LocationMichigan

Posted 20 September 2006 - 04:13 AM

I am giving you what i have .... I just do not see it...frustrating

#4 btherl

btherl
  • Staff Alumni
  • Advanced Member
  • 3,893 posts
  • LocationAustralia

Posted 20 September 2006 - 04:22 AM

Here, you open two { but only close with one } .. this could be the problem:

   if($user && $pass){
       if ($logged_in_user == $user) {
         echo $user.", you are already logged in.<BR><BR>";
         echo $links;
         exit;
   }


#5 BillyBoB

BillyBoB
  • Members
  • PipPipPip
  • Advanced Member
  • 630 posts

Posted 20 September 2006 - 04:25 AM

<FORM METHOD=POST ACTION="login.php">
Your username:
<INPUT NAME="user" TYPE=TEXT MAXLENGTH=20 SIZE=20>
<BR>
Your password:
<INPUT NAME="pass" TYPE=PASSWORD MAXLENGTH=10 SIZE=10>
<BR>
<INPUT TYPE=SUBMIT VALUE="Login">
</FORM>

should be

<FORM METHOD="POST" ACTION="login.php">
 Your username:
 <INPUT NAME="user" TYPE="TEXT" MAXLENGTH="20" SIZE="20">
 <BR>
 Your password:
 <INPUT NAME="pass" TYPE="PASSWORD" MAXLENGTH="10" SIZE="10">
 <BR>
 <INPUT TYPE="SUBMIT" VALUE="Login">
 </FORM>

just try this

sorry for telling u it was only 49 i was counting them up cuz my explorer was messing up i hate it like XP well really its my comp

#6 Jay2391

Jay2391
  • Members
  • PipPipPip
  • Advanced Member
  • 167 posts
  • LocationMichigan

Posted 20 September 2006 - 02:09 PM

I apreciate that i will try that tonite at home ;D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users