TheJoey Posted September 21, 2009 Share Posted September 21, 2009 hey im trying to create a simple login where the username and admin are fixed and i was hopeing to do it similar to this <?php session_start(); $name = $_POST['username']; $pass = $_POST['password']; if $name = 'admin' && $pass = 'admin' { $_SESSION['success'] = true; header("location: success.php"); } else { header("location: nsuccess.php"); } ?> cant seem to get this to work. Link to comment https://forums.phpfreaks.com/topic/174967-solved-simple-login/ Share on other sites More sharing options...
ozestretch Posted September 21, 2009 Share Posted September 21, 2009 What is it not doing? Link to comment https://forums.phpfreaks.com/topic/174967-solved-simple-login/#findComment-922129 Share on other sites More sharing options...
TheJoey Posted September 21, 2009 Author Share Posted September 21, 2009 Parse error: syntax error, unexpected T_IF in php.php on line 5 im getting that Link to comment https://forums.phpfreaks.com/topic/174967-solved-simple-login/#findComment-922133 Share on other sites More sharing options...
ozestretch Posted September 21, 2009 Share Posted September 21, 2009 needs to be enclosed <?php session_start(); $name = $_POST['username']; $pass = $_POST['password']; if ($name = 'admin' && $pass = 'admin') { $_SESSION['success'] = true; header("location: success.php"); } else { header("location: nsuccess.php"); } ?> Link to comment https://forums.phpfreaks.com/topic/174967-solved-simple-login/#findComment-922134 Share on other sites More sharing options...
TheJoey Posted September 21, 2009 Author Share Posted September 21, 2009 it seems to always give me the success.php page even if password is wrong Link to comment https://forums.phpfreaks.com/topic/174967-solved-simple-login/#findComment-922138 Share on other sites More sharing options...
ozestretch Posted September 21, 2009 Share Posted September 21, 2009 My bad... double == if ($name == 'admin' && $pass == 'admin') Link to comment https://forums.phpfreaks.com/topic/174967-solved-simple-login/#findComment-922141 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.