ntroycondo Posted June 21, 2010 Share Posted June 21, 2010 I am creating a (my first )very simple php/mysql application. This is probably a very basic question. Any and all help is thanked in advance. I have a working login script but want to make it better by having specific static 'admin' username redirect to a different page than any other username in the DB. So i need my $username==admin to do something besides just echo some text back. Here's what i currently have in place: if ($username==$dbusername&&$password==$dbpassword) { echo "Welcome!"; } else echo "Incorrect password!"; } else die("User does not exist"); Link to comment https://forums.phpfreaks.com/topic/205386-simple-admin-logon-and-redirect/ Share on other sites More sharing options...
inversesoft123 Posted June 21, 2010 Share Posted June 21, 2010 $getuser="SELECT * from pf_table where username='$user' and password='$password'"; $getuser2=mysql_query($getuser) or die(mysql_error()); $getuser3=mysql_fetch_array($getuser2); if($getuser3) { $_SESSION['username']=$_POST['username']; if($getuser3['username'] == "admin") { header ("Location: http://www.domain.com/admin.php"); } else { echo "Welcome user!": } } else { echo "Invalid Password": } Link to comment https://forums.phpfreaks.com/topic/205386-simple-admin-logon-and-redirect/#findComment-1074853 Share on other sites More sharing options...
ntroycondo Posted June 21, 2010 Author Share Posted June 21, 2010 Thanks. I'll give that a try. Link to comment https://forums.phpfreaks.com/topic/205386-simple-admin-logon-and-redirect/#findComment-1074859 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.