contra10 Posted February 19, 2009 Share Posted February 19, 2009 I'm trying to create a login that is already defined in the script...my password and username are already specific...i tries to login and redirect but its not working <?php <?php //if the login form is submitted if (isset($_POST['submit'])) { // if form has been submitted if (($_POST['username'] == "login") and ($_POST['pass'] == "login")){ // Create the URL string $url = "http://localhost/indicatedaccess.php/"; // Finall Echo the meta tag echo('<meta HTTP-EQUIV="REFRESH" content="0; url='.$url.'">'); } } ?> INCORRECT TRY AGAIN! <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post"> Username: <input type="text" name="username" /><br> Password: <input type="password" name="pass"/><br> <input type="submit"> </form> ?> Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted February 19, 2009 Share Posted February 19, 2009 Use the header function to redirect, not a meta refresh. header("Location: xyz.php"); exit(); Quote Link to comment Share on other sites More sharing options...
contra10 Posted February 19, 2009 Author Share Posted February 19, 2009 i tried that b4 too and i'm tried it again but i still don't get redirected <?php //if the login form is submitted if (isset($_POST['submit'])) { if (($_POST['username'] == "login") and ($_POST['pass'] == "login")){ header("Location: http://localhost/admin/indicatedaccess.php"); exit(); } } ?> Quote Link to comment Share on other sites More sharing options...
allworknoplay Posted February 19, 2009 Share Posted February 19, 2009 Try this: <?php //if the login form is submitted if (isset($_POST['submit'])) { if (($_POST['username'] == "login") && ($_POST['pass'] == "login")){ header("Location: http://localhost/admin/indicatedaccess.php"); exit(); } } ?> Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted February 19, 2009 Share Posted February 19, 2009 if($_POST['username'] == "login" && $_POST['pass'] == "login") { Quote Link to comment Share on other sites More sharing options...
contra10 Posted February 19, 2009 Author Share Posted February 19, 2009 i tried both if (($_POST['username'] == "login") && ($_POST['pass'] == "login")){ and if ($_POST['username'] == "login" && $_POST['pass'] == "login"){ neither are working...it just reloads the same page Quote Link to comment Share on other sites More sharing options...
JonnoTheDev Posted February 19, 2009 Share Posted February 19, 2009 get rid of this: if (isset($_POST['submit'])) { and use a hidden field: <input type="hidden" name="action" value="login" /> if($_POST['action'] && $_POST['action'] == 'login') { // validate username and password } Quote Link to comment Share on other sites More sharing options...
premiso Posted February 19, 2009 Share Posted February 19, 2009 Neil hit the nail on the head. However you do not "need" the hidden input. <input type="submit" name="submit" value="Submit" /> </form> That would allow your original code to work. You just were not defining a name for that submit button so it was never populating the $_POST['submit'] data.. Quote Link to comment Share on other sites More sharing options...
contra10 Posted February 19, 2009 Author Share Posted February 19, 2009 wow i feel so dumb for missing that...thxs Quote Link to comment 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.