Forums

PHP

This topic is locked

Form, mysql and email

Posted 05 Apr 2007 19:48:00
1
has voted
05 Apr 2007 19:48:00 Mary Fredendall posted:
I have seen a few posts regarding this and have tried the solutions with no results.

I have a php form that is connected to a database that was created using dreamweaver insert-application object record insertion form wizard. Now, how do I integrate all that code that shows up on the top of the document into a mail script?

I tried Mr. Green's solution of

if (phpversion() > "4.0.6" {
$HTTP_POST_VARS = &$_POST;
}

if (isset($HTTP_POST_VARS\["formSeen"\])) { // note: remove the \ characters on this line. 
// create the mail information
$to = " ";
$subject = "Registration Info";
$from = "From: MySite Registration System\r\n";
$body = "The following information was submitted:-\n\n";
while (list($key,$value) == each($HTTP_POST_VARS)) {
$body.= $key . " = " . $value . "\n";
}
// now send the mail
mail($to,$subject,$body,$from);

// then redirect to another page
header("Location: registrationSent.php";
}

But this didn’t work. Where do I put it in the document? Before or after or during the script that is created by Dreamweaver with the insert record form wizard?

I already have a redirect to a page in the insert record stuff, do I just remove it in the mail script?

How do I integrate results from the form into the mail script?

Help! I have been trying this forever in a thousand different ways and am very frustrated.

Replies

Replied 06 Apr 2007 17:38:48
06 Apr 2007 17:38:48 Alan C replied:
Hi
a lot of that code at the top of DW-generated pages is internal stuff that DW uses, it takes a bit of wading through to really get the sense of it.

Do you want to send the whole contents of the form by email as well as putting it into the database?

If that is the case then you can look down the DW code and you should see the query that does the UPDATE, then there will be the actual write to the database, so what you would need to do is add your emailing section there.

If on the other hand you have a form and just want to send the information by email you could use either Formmail - or better Forms to go

Reply to this topic