Jump to content

Archived

This topic is now archived and is closed to further replies.

Jay2391

login code error

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>

Share this post


Link to post
Share on other sites
I am giving you what i have .... I just do not see it...frustrating

Share this post


Link to post
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]

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

×

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.