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 Link to comment https://forums.phpfreaks.com/topic/20701-script-error/ 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 Link to comment https://forums.phpfreaks.com/topic/20701-script-error/#findComment-91578 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 Link to comment https://forums.phpfreaks.com/topic/20701-script-error/#findComment-91585 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... Link to comment https://forums.phpfreaks.com/topic/20701-script-error/#findComment-91590 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 :) Link to comment https://forums.phpfreaks.com/topic/20701-script-error/#findComment-91612 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 Link to comment https://forums.phpfreaks.com/topic/20701-script-error/#findComment-91615 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] Link to comment https://forums.phpfreaks.com/topic/20701-script-error/#findComment-91630 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.