quelle Posted July 25, 2011 Share Posted July 25, 2011 On 25th and 29 th line <?php include('includes/functions.php'); session_start(); if(isset($_POST['login'])){ if(isset($_POST['username'])){ if(isset($_POST['password'])){ $query = mysql_query('SELECT * FROM users WHERE Username = $_POST["username"]') or die(mysql_error()); $user = mysql_fetch_array($query); if($_POST['password'] == $user['Password']){ echo "Uspješan login!"; $_SESSION['user'] = $user['username']; header('Location: index.php'); } else { echo "Provjerite login detalje!"; include('login.php'); } } else { echo "Password netačan!"; include('login.php'); } else { echo "Username netačan!"; include('login.php'); } else { echo "Niste ispunili sve podatke!"; include('login.php'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/242703-t_else-syntax-error/ Share on other sites More sharing options...
phpSensei Posted July 25, 2011 Share Posted July 25, 2011 Theres a syntax error inside your query, your missing a closing bracket also on one of the ELSE try this <?php include('includes/functions.php'); session_start(); if(isset($_POST['login'])){ if(isset($_POST['username'])){ if(isset($_POST['password'])){ $query = mysql_query('SELECT * FROM users WHERE Username = "'.$_POST["username"].'"') or die(mysql_error()); $user = mysql_fetch_array($query); if($_POST['password'] == $user['Password']){ echo "Uspješan login!"; $_SESSION['user'] = $user['username']; header('Location: index.php'); } else { echo "Provjerite login detalje!"; include('login.php'); } } else { echo "Password netačan!"; include('login.php'); } } else { echo "Username netačan!"; } include('login.php'); } else { echo "Niste ispunili sve podatke!"; include('login.php'); } ?> ?> Quote Link to comment https://forums.phpfreaks.com/topic/242703-t_else-syntax-error/#findComment-1246588 Share on other sites More sharing options...
quelle Posted July 25, 2011 Author Share Posted July 25, 2011 Nah, query works fine, even on ur way but im still having the syntax problem Quote Link to comment https://forums.phpfreaks.com/topic/242703-t_else-syntax-error/#findComment-1246614 Share on other sites More sharing options...
phpSensei Posted July 25, 2011 Share Posted July 25, 2011 Nah, query works fine, even on ur way but im still having the syntax problem What was the error ouput after you tried my code? Quote Link to comment https://forums.phpfreaks.com/topic/242703-t_else-syntax-error/#findComment-1246619 Share on other sites More sharing options...
quelle Posted July 25, 2011 Author Share Posted July 25, 2011 Sorry for a late reply, i slept here on my desk havent sleep whole night btw the error was Parse error: syntax error, unexpected T_ELSE in D:\xampp\htdocs\CMSSITE\admin\dologin.php on line 25 Quote Link to comment https://forums.phpfreaks.com/topic/242703-t_else-syntax-error/#findComment-1246667 Share on other sites More sharing options...
trq Posted July 25, 2011 Share Posted July 25, 2011 Check your curly braces. Simple syntax errors should not require the help of a forum. If you still can't find the error, post your current code. Quote Link to comment https://forums.phpfreaks.com/topic/242703-t_else-syntax-error/#findComment-1246670 Share on other sites More sharing options...
quelle Posted July 25, 2011 Author Share Posted July 25, 2011 Well i checked, and i posted it in first post Quote Link to comment https://forums.phpfreaks.com/topic/242703-t_else-syntax-error/#findComment-1246672 Share on other sites More sharing options...
SpaceLama Posted July 25, 2011 Share Posted July 25, 2011 Tell us what is line 25? You need to count your {}... do you have as many opening as closing? This is why you get the error at first place. Get your strings without an variable within '' and not within "". Quote Link to comment https://forums.phpfreaks.com/topic/242703-t_else-syntax-error/#findComment-1246675 Share on other sites More sharing options...
hoponhiggo Posted July 25, 2011 Share Posted July 25, 2011 Looks to me like you dont have enough closing curly braces. There seem to be a few in the top half of your code that arent being closed. Quote Link to comment https://forums.phpfreaks.com/topic/242703-t_else-syntax-error/#findComment-1246676 Share on other sites More sharing options...
trq Posted July 25, 2011 Share Posted July 25, 2011 Well i checked, and i posted it in first post We need to see your current code. if you haven't changed your code since your first post you need to re-read the replies already given. Quote Link to comment https://forums.phpfreaks.com/topic/242703-t_else-syntax-error/#findComment-1246679 Share on other sites More sharing options...
teynon Posted July 25, 2011 Share Posted July 25, 2011 You're logic is heavily faltered and you appear to be taking no ones advice. Look at your code: else { echo "Password netačan!"; include('login.php'); } else { echo "Username netačan!"; include('login.php'); } else { echo "Niste ispunili sve podatke!"; include('login.php'); } You have three elses in line. else { } else {} else {} Tell me this doesn't work and i'll tell you to take hike. <?php include('includes/functions.php'); session_start(); if(isset($_POST['login'])) { if(isset($_POST['username'])) { if(isset($_POST['password'])){ $query = mysql_query('SELECT * FROM users WHERE Username = $_POST["username"]') or die(mysql_error()); $user = mysql_fetch_array($query); if ($_POST['password'] == $user['Password']) { echo "Uspješan login!"; $_SESSION['user'] = $user['username']; header('Location: index.php'); } else { echo "Provjerite login detalje!"; include('login.php'); } } else { echo "Password netačan!"; include('login.php'); } } else { echo "Username netačan!"; include('login.php'); } } else { echo "Niste ispunili sve podatke!"; include('login.php'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/242703-t_else-syntax-error/#findComment-1246685 Share on other sites More sharing options...
the182guy Posted July 25, 2011 Share Posted July 25, 2011 Try using the Notepad++ editor to write your code, it is great for quickly finding syntax errors like this because you can have it show you which IF's are connected to which ELSE's etc, and you can click a brace and it will highlight the corresponding closing brace. if(isset($_POST['login'])){ On another note I'm guessing your login variable is the form's submit button? If so then you have a compatibility problem with IE. See Why isset post is not compatible with Internet Explorer. Quote Link to comment https://forums.phpfreaks.com/topic/242703-t_else-syntax-error/#findComment-1246691 Share on other sites More sharing options...
teynon Posted July 25, 2011 Share Posted July 25, 2011 While what the 182guy said is true, the form could be submitted using the enter key, I disagree with using ($_SERVER['REQUEST_METHOD'] == 'POST'). I think you should simply create a hidden form field. IE <input type="hidden" name="formSubmitted" value="1"> Then check it like: if (isset($_POST['formSubmitted'])) { } Quote Link to comment https://forums.phpfreaks.com/topic/242703-t_else-syntax-error/#findComment-1246697 Share on other sites More sharing options...
quelle Posted July 25, 2011 Author Share Posted July 25, 2011 dAMN im really a cock sucker lolz, i closed brackets for else and didnt for whole if lol thanks tenyon for pointing out mistakes btw u said I disagree with using ($_SERVER['REQUEST_METHOD'] == 'POST'). I think you should simply create a hidden form field. IE <input type="hidden" name="formSubmitted" value="1"> Then check it like: if (isset($_POST['formSubmitted'])) { } Can u indicate where i used that method? Quote Link to comment https://forums.phpfreaks.com/topic/242703-t_else-syntax-error/#findComment-1246711 Share on other sites More sharing options...
teynon Posted July 25, 2011 Share Posted July 25, 2011 quelle, i'm refering to the link in the182guy's post. Quote Link to comment https://forums.phpfreaks.com/topic/242703-t_else-syntax-error/#findComment-1246712 Share on other sites More sharing options...
quelle Posted July 26, 2011 Author Share Posted July 26, 2011 Try using the Notepad++ editor to write your code, it is great for quickly finding syntax errors like this because you can have it show you which IF's are connected to which ELSE's etc, and you can click a brace and it will highlight the corresponding closing brace. if(isset($_POST['login'])){ On another note I'm guessing your login variable is the form's submit button? If so then you have a compatibility problem with IE. See Why isset post is not compatible with Internet Explorer. Since im using firefox i didnt notice it yet but thanks for ur help Quote Link to comment https://forums.phpfreaks.com/topic/242703-t_else-syntax-error/#findComment-1247094 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.