Jump to content

Script Error


Drezard

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
Link to comment
https://forums.phpfreaks.com/topic/20701-script-error/
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
Link to comment
https://forums.phpfreaks.com/topic/20701-script-error/#findComment-91578
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...
Link to comment
https://forums.phpfreaks.com/topic/20701-script-error/#findComment-91590
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 :)
Link to comment
https://forums.phpfreaks.com/topic/20701-script-error/#findComment-91612
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]
Link to comment
https://forums.phpfreaks.com/topic/20701-script-error/#findComment-91630
Share on other sites

Archived

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

×
×
  • 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.