Jump to content

Newbie Debugging Question: Unexpected T_ELSE


Ethan05

Recommended Posts

I'm pretty new to PHP and I was messing around with a prefab login script to use for my website. I came across a syntax error that I can't make sense of:

 

Parse error: syntax error, unexpected T_ELSE in [siteurl]/login.php on line 71

 

Offending code:

64 setcookie(cvc123, $_POST['pass'], $hour);
65 //
66 //redirect
67 header("Location: members.php");
68 }
69 }
70 }
71 else;
72 {

 

I've tried looking around at my semicolons and brackets, but everything checks out. What am I missing?

 

Thanks,

Ethan

Link to comment
Share on other sites

Okay:

 

60 // if login is good add a cookie
61     $_POST['username'] = stripslashes($_POST['username']);
62     $hour = time() + 3600;
63     setcookie(usernamecv, $_POST['username'], $hour);
64     setcookie(cvc123, $_POST['pass'], $hour);
65     //
66     //redirect
67     header("Location: members.php");
68     }
69   }
70 }
71 else
72 {
73 // if they are not logged in
74 ?>
75
76     <form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
77          <table border="0">
78             <tbody>
79                    <tr>
80                      <td colspan="2">
81                      <h1>Login</h1>
82                      </td>
83                  </tr>
84                  <tr>
85                      <td>Username:</td>
86                      <td><input type="text" maxlength="40" name="username" /></td>
87                  </tr>
88                  <tr>
89                      <td>Password:</td>
90                        <td><input type="password" maxlength="50" name="pass" /></td>
91                    </tr>
92                    <tr>
93                        <td align="right" colspan="2"><input type="submit" value="Login" name="submit" /></td>
94                  </tr>
95              </tbody>
96          </table>
97      </form>
98     <?php
99 }
100
101 ?>
102    </body>
103 </html>

Link to comment
Share on other sites

60<?php
// if login is good add a cookie
61     $_POST['username'] = stripslashes($_POST['username']);
62     $hour = time() + 3600;
63     setcookie(usernamecv, $_POST['username'], $hour);
64     setcookie(cvc123, $_POST['pass'], $hour);
65     //
66     //redirect
67     header("Location: members.php");
68     }
69   }
70 }
71 else
72 {
73 // if they are not logged in
74  echo 
75
76     "<form method="post" action=" $_SERVER['PHP_SELF']">
77          <table border="0">
78             <tbody>
79                    <tr>
80                      <td colspan="2">
81                      <h1>Login</h1>
82                      </td>
83                  </tr>
84                  <tr>
85                      <td>Username:</td>
86                      <td><input type="text" maxlength="40" name="username" /></td>
87                  </tr>
88                  <tr>
89                      <td>Password:</td>
90                        <td><input type="password" maxlength="50" name="pass" /></td>
91                    </tr>
92                    <tr>
93                        <td align="right" colspan="2"><input type="submit" value="Login" name="submit" /></td>
94                  </tr>
95              </tbody>
96          </table>
97      </form>";?>
98     
99 
100
101 
102    </body>
103 </html>

Link to comment
Share on other sites

<?php
23    {
    //if the login form is submitted
    if (isset($_POST['submit']));
    {
    // if form has been submitted
    // makes sure they filled it in
    if(!$_POST['username'] | !$_POST['pass'])
    {
    die('You did not fill in a required field.');
    }
    // checks it against the database

    if (!get_magic_quotes_gpc())
    {
    $_POST['email'] = addslashes($_POST['email']);
    }
    $check = mysql_query("SELECT * FROM phpbb_users WHERE username = '".$_POST['username']."'") or die(mysql_error());
    //Gives error if user doesn't exist
    $check2 = mysql_num_rows($check);
    if ($check2 == 0)
    {
    die('That user does not exist in our database. <a href=add.php>Click Here to Register</a>');
    }
    while($info = mysql_fetch_array( $check ))
    {
    $_POST['pass'] = stripslashes($_POST['pass']);
    $info['password'] = stripslashes($info['password']);
    $_POST['pass'] = phpbb_hash($_POST['pass']);

    //gives error if the password is wrong
    if ($_POST['pass'] != $info['password'])
    {
    die('Incorrect password, please try again.');
    }
else
{
// if login is good add a cookie
     $_POST['username'] = stripslashes($_POST['username']);
     $hour = time() + 3600;
     setcookie(*******, $_POST['username'], $hour);
     setcookie(*****, $_POST['pass'], $hour);
     //
     //redirect
     header("Location: members.php");
     }
   }
}
70 else
?>

 

Sorry, lines not labeled except for the first and last... I'm using a text editor because I don't have access to anything else on this machine currently.

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.