Drezard Posted September 14, 2006 Share Posted September 14, 2006 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 sessionsession_start();?><html><head></head><body><?phpif (!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 Quote Link to comment Share on other sites More sharing options...
Zane Posted September 14, 2006 Share Posted September 14, 2006 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 Quote Link to comment Share on other sites More sharing options...
Drezard Posted September 14, 2006 Author Share Posted September 14, 2006 I have repaired that problem but it still gives me the same error. Can u think of anything else?- Cheers, Daniel Quote Link to comment Share on other sites More sharing options...
laide234 Posted September 14, 2006 Share Posted September 14, 2006 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... Quote Link to comment Share on other sites More sharing options...
joshi_v Posted September 14, 2006 Share Posted September 14, 2006 <?php// initialize a sessionsession_start();?><html><head></head><body><?phpif (!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 :) Quote Link to comment Share on other sites More sharing options...
HuggieBear Posted September 14, 2006 Share Posted September 14, 2006 The problem is still with the original rowTry copying and pasting this into it...[code=php:0]if ((empty($_POST['user'])) && (empty($_POST['pass']))) {[/code]RegardsHuggie Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted September 14, 2006 Share Posted September 14, 2006 Try this:[code]<?php// initialize a sessionsession_start();?><html><head></head><body><?php// if no data, print the formif (!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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.