Jump to content

posting to self then redirecting?


Rifts

Recommended Posts

Is there anyway to do this:

 

my form is posting to self, then checking login creds. if they are incorrect it spits out "invaild bla bla" but if they are correct send them to a different page?

 

here is the short version of what I have.

 

if(isset($_POST['submit'])) {

//check inputs vs db

if ($check) {
header("Location: http://". $_SERVER['SERVER_NAME']."/include/process_renew.php");
} else { 
echo "<font color='red'>Username or Password did not match.</font> <br /><br />";
   }
}


}

 

I tested it using echo first and it worked fine then replaced the echo with header and now when I submit it just refreshes the page.

 

is this not possible?

Link to comment
Share on other sites

If the echo is what you expect it to be but the header redirect fails, the headers may have already been sent.

 

if ($check) {
if( !headers_sent() ) {
	header("Location: http://". $_SERVER['SERVER_NAME']."/include/process_renew.php");
} else {
	echo 'Headers already sent. Can\'t redirect.';
}
} else {
echo "<font color='red'>Username or Password did not match.</font> <br /><br />";
}

Link to comment
Share on other sites

You may also use a meta-refresh.

 

if(isset($_POST['submit'])) {

//check inputs vs db

if ($check) {
echo "<meta http-equiv=\"refresh\" content=\"0;url=". $_SERVER['SERVER_NAME']."/include/process_renew.php\">";
} else { 
echo "<font color='red'>Username or Password did not match.</font> <br /><br />";
   }
}

 

Link to comment
Share on other sites

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.