Jump to content

login code error


Jay2391

Recommended Posts

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>
Link to comment
Share on other sites

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

[code]  if($user && $pass){
      if ($logged_in_user == $user) {
        echo $user.", you are already logged in.<BR><BR>";
        echo $links;
        exit;
  }[/code]
Link to comment
Share on other sites

<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
[code]

<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>[/code]

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
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.