viv Posted May 5, 2007 Share Posted May 5, 2007 Hey - me again and i've fixed quite a bit but I'm in a tight spot again. Parse error: syntax error, unexpected T_ELSE in /home/arcadias/public_html/checkform.php on line 11 Can anyone help me sort out this connection issue at the front? Total newbie here so any help is appreciated. LOGIN.PHP routine ------------------ <?php session_start(); { $dbh=mysql_connect ("localhost", "arcadias_bank", "<***>") or die ('I cannot connect to the database because: ' . mysql_error()); }else { if ($_POST['_submit_check']) { if ($form_errors = validate_form()) { show_form($form_errors); } else { process_form(0); } } else { show_form(); } } function show_form($errors = '') { print '<form name="authForm" method="POST" action="'.$_SERVER['PHP_SELF'].'">'; if ($errors) { print '<span style="color:red"><ul><li><b>'; print implode('</b></li><li><b>',$errors); print '</b></li></ul></span>'; } print 'userto'; print '<input type="text" name="userto" value="'; print htmlentities($_POST[userID]) . '"> <br />'; print 'password'; print '<input type="password" name="password" value="'; print htmlentities($_POST[password]) . '"> <br />'; print '<input type="submit" name="login" value="Login" />'; print '<input type="hidden" name="_submit_check" value="1"/>'; print '</form>'; print '<a href="index.php">Click</a> here if you want to leave this form.'; } function validate_form() { $errors = array(); $userid=$_POST['Username']; $passwd=$_POST['Password']; /************************************************** ************************** * Check username and password in database * ************************************************** **************************/ // ..... connect to data base $text = ""; $text = $db->get_var("SELECT * FROM authorized_users WHERE userid='$userfrom' AND passwd=sha1('$passwd')") ; if ($text == "") { $errors[] = 'Enter a valid username and password!'; } return $errors; } function process_form($logged_in) { if ($logged_in == 0) { // Add the username to the session $_SESSION['username'] = $_POST['username']; } print 'You are logged in as: <b>'.$_SESSION['username'].'</b>'.str_repeat(' ', 10).'<a href="logout.php">Logout</a><br />'; print '<p>You can continue processing as a logged-in user ............</p>'; } ?> LOGOUT.PHP routine: ------------------- <?php session_start(); unset($_SESSION['username']); print '<p>You are logged out.</p>'; ?> Link to comment https://forums.phpfreaks.com/topic/50153-solved-t_else-syntax-error/ Share on other sites More sharing options...
map200uk Posted May 5, 2007 Share Posted May 5, 2007 { why do you have that after <?php ?? Link to comment https://forums.phpfreaks.com/topic/50153-solved-t_else-syntax-error/#findComment-246283 Share on other sites More sharing options...
paul2463 Posted May 5, 2007 Share Posted May 5, 2007 LOGIN.PHP routine ------------------ <?php session_start(); // WHERE IS THE IF STATEMENT FROM HERE???????????? // you cant have an ELSE statement without an "IF" statement first { $dbh=mysql_connect ("localhost", "arcadias_bank", "<***>") or die ('I cannot connect to the database because: ' . mysql_error()); }else { if ($_POST['_submit_check']) { if ($form_errors = validate_form()) { show_form($form_errors); } else { process_form(0); } } else { show_form(); } } function show_form($errors = '') { print '<form name="authForm" method="POST" action="'.$_SERVER['PHP_SELF'].'">'; if ($errors) { print '<span style="color:red"><ul><li><b>'; print implode('</b></li><li><b>',$errors); print '</b></li></ul></span>'; } print 'userto'; print '<input type="text" name="userto" value="'; print htmlentities($_POST[userID]) . '"> <br />'; print 'password'; print '<input type="password" name="password" value="'; print htmlentities($_POST[password]) . '"> <br />'; print '<input type="submit" name="login" value="Login" />'; print '<input type="hidden" name="_submit_check" value="1"/>'; print '</form>'; print '<a href="index.php">Click</a> here if you want to leave this form.'; } function validate_form() { $errors = array(); $userid=$_POST['Username']; $passwd=$_POST['Password']; /************************************************** ************************** * Check username and password in database * ************************************************** **************************/ // ..... connect to data base $text = ""; $text = $db->get_var("SELECT * FROM authorized_users WHERE userid='$userfrom' AND passwd=sha1('$passwd')") ; if ($text == "") { $errors[] = 'Enter a valid username and password!'; } return $errors; } function process_form($logged_in) { if ($logged_in == 0) { // Add the username to the session $_SESSION['username'] = $_POST['username']; } print 'You are logged in as: <b>'.$_SESSION['username'].'</b>'.str_repeat(' ', 10).'<a href="logout.php">Logout</a><br />'; print '<p>You can continue processing as a logged-in user ............</p>'; } ?> LOGOUT.PHP routine: ------------------- <?php session_start(); unset($_SESSION['username']); print '<p>You are logged out.</p>'; ?> Link to comment https://forums.phpfreaks.com/topic/50153-solved-t_else-syntax-error/#findComment-246284 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.