Jump to content

AUTOMATICALLY send user to new domain/page


ostig

Recommended Posts

I have created two scripts for user authentication and I am stuck as to how to get the user where I want him/her to go.

 

The first script gets the username and password using a form and goes to a second script for validation.

 

The validation script validates that the user name and password are correct by comparing to MySQL DB. Now I am stuck as I am very new to php (one day) and just have a "Dummies" book at the moment.

 

If the username and password is good, I need to automatically send the user to another URL.

 

If the username is not good, I need to automatically send the user back to the first script's URL.

 

If the password is no good, I need to automatically send the user to an information page about what they can do.

 

My problem is I cannot figure how to automatically send the user anywhere (whichout them clicking on something). I looked at the header command, but to me it seems it is not an option because I am going to be sending them elsewhere in the middle of a php script inside of if statements and what I read seems like this is not such a good way to go as the header command needs to be first?

 

Any help appreciated!

The header function does not need to be first, it just needs to be before any output. This makes perfect sense as there is no point outputting anything if all your going to do is redirect the user anyway.

 

<?php header('Location: http://domain.com/somepage.php'); ?>

Okay, those two command work for me when I am sending to a URL, as requested, thank you.

-----

But now to add to the level of complexity, last evening I learned how to do this:

 

<a href="domain.com/index.htm?color=<?php echo $color; ?>&date=<?php echo $date; ?>" ....

 

in order to send to contents of a variable appended to the end of a URL, as shown.

 

Problem is that this will not work for me when I try it in the meta or header command (which I guess is what I have to use to send the user to the new URL), I get parse errors. Am I now up against something that is not valid? For this task I am required to send up to 5 variable=value strings at the end of the URL.

Okay, those two command work for me when I am sending to a URL, as requested, thank you.

-----

But now to add to the level of complexity, last evening I learned how to do this:

 

<a href="domain.com/index.htm?color=<?php echo $color; ?>&date=<?php echo $date; ?>" ....

 

in order to send to contents of a variable appended to the end of a URL, as shown.

 

Problem is that this will not work for me when I try it in the meta or header command (which I guess is what I have to use to send the user to the new URL), I get parse errors. Am I now up against something that is not valid? For this task I am required to send up to 5 variable=value strings at the end of the URL.

 

you should be able to

 

<?PHP

//PAGE TEXT

echo "<meta http-equiv='refresh' content='0;url=page.php?color=$color&date=$date'>" ;

?>

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.