View Full Version : webmail redirection

09-22-2003, 09:18 AM
I am attempting to write a simple logon page, consisting of a form containing to input field, email address, and password.
The script then needs to redirect, and login the user depending on the email address.
If the email address is someuser@company.com.au, the script needs to send the variables $username and $password to "webmail.company.com.au", but if the domain is anything else the script needs to go to "webmail.$domain" with variables $user and $pass. these all need to go through with the post method.
these are the steps I have so far...

1. User inputs data
2. script processes data, explodes $email
3. if $email[1] == company.com.au
4. Redirect to appropriate page.

I'm stuck at 4...
how would i post to another page without user interaction (using the superglobals method).

If anyone can help I'd greatly appreciate it. hope this isn't to murky a description.

09-22-2003, 10:04 AM
Welcome here.

I don't think you can. Well, you could send a form with a javascripts Onload or something, buth thats a bit of a hack.
Why does it needs to be posted ?

You could use
$url = "http://www.rigthdomain.com/page2.php?user=" . $user . "&pwd=" . $pass
header("Location: $url");

Then in page2.php you do your stuff (you can get the values with $_GET['user'] ) and depending on the results of your validation or whatever, you redirect the user again
$url = "http://www.rigthdomain.com/page3.php"
header("Location: $url");

crazy horse
09-22-2003, 04:27 PM
You can construct POST requests within a PHP script with CURL if you want to avoid sending user name and password variables in a GET request. This way you can evaluate the submitted email address and then POST to the relevant address. Here's a really good tutorial on CURL:

http://www.phpfreaks.com/tutorials/49/1.php (note that the emphasis is on merchant transactions but it still shows you how CURL works)

More here:


09-23-2003, 04:33 AM
In reply to the first question, I need to post to the receiving scripts, as I cannot make changes to them. Using Header Location redirects was what I was first going to do, but I am still left with the dilemma of how to post the variables through.

I am currently looking at the CURL Tutorial, and I think this is the way I am going to go. It appears that I can do exactly what I need to do with CURL.

Thanks to you both for replying & helping!! :) :thumbsup: