How to send a post header programatically

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
flycast
Forum Commoner
Posts: 37
Joined: Wed Jun 01, 2005 7:33 pm

How to send a post header programatically

Post by flycast »

I have a host that will not allow me to use the mail() function in PHP scripts. He has his own ColdFusion script that he wants me to submit form information to. The problem is that this bypasses all the error checking of the form since the form is written as a self submitting form. I don't want to use javascript for error checking as 10% of browsers have it turned off.

Is there a way for me to salvage my self submitting form by replacing the mail() function with a header() function that would neatly look like it was submitted by my original form? IF this can be done what would the header look like?

Thanks,
Eric
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

It should work. Get the $_POST array values, and transfer it within the URI might be on idea. Not perhaps correct, but you get the ideas:

Code: Select all

// ... code ...
// mail(...);
foreach ($_POST as $key => $val) {
 $array[$key] = $val;
 $string = base64_encode(serialize($array));
 header("Location: ./theotherpage.php?postinfo={$string}");
}
...then base54_decode and unserialize the $_GET['postinfo'] being sendt in theotherpage.php.

There is also cURL() to name something else.
flycast
Forum Commoner
Posts: 37
Joined: Wed Jun 01, 2005 7:33 pm

Post by flycast »

HOw could I capture and examine a header? My thought is to submit some infro from a form to another page and examine th ehader to make sure I get all the dataila just right.

Thanks,
Eric
Syranide
Forum Contributor
Posts: 281
Joined: Fri May 20, 2005 3:16 pm
Location: Sweden

Post by Syranide »

a little tip is otherwise to use some other class, there is a neat bunch of classes (SMTP/mail) which sends a message equally to the internal mailfunction... there is probably a functiondefinition somewhere which works just like mail() too.
(let's you specify everything the way you want with possibly full errorchecking)
Post Reply