Jump to content

[SOLVED] login already defined


contra10

Recommended Posts

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>
?>

Link to comment
https://forums.phpfreaks.com/topic/145960-solved-login-already-defined/
Share on other sites

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();
}
}
?>

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..

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.