4 Replies - 737 Views - Last Post: 18 July 2010 - 05:52 PM Rate Topic: -----

#1 CodeVillain  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 143
  • Joined: 10-July 10

header("location: ) for the original page

Posted 17 July 2010 - 05:00 PM

if($errflag) {
		$_SESSION['ERRMSG_ARR'] = $errmsg_arr;
		session_write_close();
		header("location: login-form.php");
		exit();
	}


I'm changing my login form to be on multiple pages, so I want to make it so that the header("location: ) in the login form process targets the original page with the form on it. How would I go about doing this? Do I need to turn it into a variable? If so, what would I have to add to my form that would store the original URL of the form post into a variable I could then plop in my header location?

Is This A Good Question/Topic? 0
  • +

Replies To: header("location: ) for the original page

#2 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3001
  • View blog
  • Posts: 10,393
  • Joined: 08-August 08

Re: header("location: ) for the original page

Posted 17 July 2010 - 05:56 PM

Why not make the login form a function? That way you could include and call it from any page:
loginform.php:
<?php
function loginform()
{
  // code to create login form
}
?>

Some page:
<?php
include("loginform.php");
loginform();


Was This Post Helpful? 1
  • +
  • -

#3 CodeVillain  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 143
  • Joined: 10-July 10

Re: header("location: ) for the original page

Posted 17 July 2010 - 08:26 PM

View PostCTphpnwb, on 17 July 2010 - 03:56 PM, said:

Why not make the login form a function? That way you could include and call it from any page:
loginform.php:
<?php
function loginform()
{
  // code to create login form
}
?>

Some page:
<?php
include("loginform.php");
loginform();



Well it's not the login form itself that's the issue, it's the error redirect on the processing page for the login form. It finds the errors then redirects based on those errors. Right now I've actually just set it up so all errors will take them to a "login failed" page where they can then proceed to attempt to re-login, but I'd rather just keep them on the same page.
Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3001
  • View blog
  • Posts: 10,393
  • Joined: 08-August 08

Re: header("location: ) for the original page

Posted 18 July 2010 - 04:55 AM

The loginform() function could easily check to see if an attempt to login has been made, and display appropriate error messages along with the form, or display a welcome screen if the login was successful. ;)
Was This Post Helpful? 2
  • +
  • -

#5 CodeVillain  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 143
  • Joined: 10-July 10

Re: header("location: ) for the original page

Posted 18 July 2010 - 05:52 PM

View PostCTphpnwb, on 18 July 2010 - 02:55 AM, said:

The loginform() function could easily check to see if an attempt to login has been made, and display appropriate error messages along with the form, or display a welcome screen if the login was successful. ;)


Good to know, I didn't know functions were capable of doing that. Thank you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1