Jump to content

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

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
}

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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