Jump to content

Archived

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

Drezard

Script Error

Recommended Posts

This script doesnt seem to work for some reason. I cant understand why.

Heres the error:
[QUOTE]
Parse error: syntax error, unexpected T_BOOLEAN_AND in C:\Program Files\xampp\htdocs\login_form.php on line 24
[/QUOTE]

Here's the code:

[CODE]
<?php
// initialize a session
session_start();
?>
<html>
<head></head>
<body>

<?php
if (!isset($_SESSION['login']) && !isset($_POST['user'])) {
    // if no data, print the form
?>
    <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
      Username:<input type="text" name='user'><br>
  Password:<input type="text" name='pass'><br>
        <input type="submit" name="submit">
    </form>
<?php
}
else if (!isset($_SESSION['login'])) {
    // if a session does not exist but the form has been submitted
    // check to see if the form has all required values
    // create a new session
    if (empty($_POST['user'])) && {empty($_POST['pass'])) {
  echo "Please insert your username";
  echo "Please insert your password";
        }
    if (empty($_POST['user'])) {
      echo "Please insert your username";
    }
if (empty($_POST['pass'])) {
  echo "Please insert your username";
  }
 
}
?>
</body>
</html>
[/CODE]

Thanks, Daniel

Share this post


Link to post
Share on other sites
right here
[quote]    // if a session does not exist but the form has been submitted
    // check to see if the form has all required values
    // create a new session
    if (empty($_POST['user'][b][color=red][size=12pt])[/size][/color][/b]) && [b][color=red][size=12pt]{[/size][/color][/b]empty($_POST['pass'])) {[/quote]

get rid of the two characters marked in red

Share this post


Link to post
Share on other sites
I have repaired that problem but it still gives me the same error.

Can u think of anything else?

- Cheers, Daniel

Share this post


Link to post
Share on other sites
You have 3 if statements back to back....

[code]  if (empty($_POST['user'])) && {empty($_POST['pass'])) {
  echo "Please insert your username";
  echo "Please insert your password";
        }
    if (empty($_POST['user'])) {
      echo "Please insert your username";
    }
if (empty($_POST['pass'])) {
  echo "Please insert your username";
  }[/code]

I dont think you can do that.


use
if...
esle if...
esle...

Share this post


Link to post
Share on other sites
<?php
// initialize a session
session_start();
?>
<html>
<head></head>
<body>

<?php
if (!isset($_SESSION['login']) && !isset($_POST['user'])) {
    // if no data, print the form
?>
    <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
      Username:<input type="text" name='user'><br>
  Password:<input type="text" name='pass'><br>
        <input type="submit" name="submit">
    </form>
<?php
}
else if (!isset($_SESSION['login']))
{
    // if a session does not exist but the form has been submitted
    // check to see if the form has all required values
    // create a new session
  if (empty($_POST['user']) && (empty($_POST['pass'])))
{
echo "Please insert your username";
echo "Please insert your password";
}
  if (empty($_POST['user']))
  {
      echo "Please insert your username";
  }
if (empty($_POST['pass']))
  {
  echo "Please insert your username";
}
}
?>
</body>
</html>


Just use this code.. where you are doing mistake is unnecessary paranthesis closing brackets and Open curl braces.at the end of the line 24 i added one closing paranthesis.

cheers :)

Share this post


Link to post
Share on other sites
The problem is still with the original row

Try copying and pasting this into it...

[code=php:0]
if ((empty($_POST['user'])) && (empty($_POST['pass']))) {
[/code]

Regards
Huggie

Share this post


Link to post
Share on other sites
Try this:
[code]<?php
// initialize a session
session_start();
?>
<html>
<head></head>
<body>

<?php
// if no data, print the form
if (!isset($_SESSION['login']) && !isset($_POST['user']))
{
?>
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
  Username:<input type="text" name='user'><br />
  Password:<input type="text" name='pass'><br />
  <input type="submit" name="submit">
</form>
<?php
}
else if (!isset($_SESSION['login']))
{
    // if a session does not exist but the form has been submitted
    // check to see if the form has all required values
    // create a new session
    if (empty($_POST['user']) && empty($_POST['pass']))
    {
    echo "Please insert your username<br />";
        echo "Please insert your password<br />";
    }
    elseif (empty($_POST['user']))
    {
        echo "Please insert your username<br />";
    }
elseif (empty($_POST['pass']))
    {
  echo "Please insert your username<br />";
}
}
?>
</body>
</html>[/code]

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.