Jump to content

formmail.php - help required...


Africa

Recommended Posts

Hi All,

If anyone can help me with this, it would be awesome...

 

I am building a website that has at least two forms. The current script that I use to make a form function is written below. But now what do I do if I have two different forms on the same website, eg, Form Red and Form Blue. I would like these forms to be emailed to me with their subject heading, eg. Form Red. What do I add to my script to make this work for two forms?

 

Thanks so much if anyone can help...

Africa

 

<?

 

#

#mail all variables to:

$my email goes here';

while (list($key,$val) = each($HTTP_POST_VARS)){

$formmessage.="$key = $val\n";

}

#reset the from: address for a neater look

$header.="From: The name of my form goes here <[email protected]>\n";

#if there's an email element, use it for reply-to

if ($email)

$header.="Reply-To: $email\n";

#log the IP Address of the sender.

if ($HTTP_X_FORWARDED_FOR)

$header.="X-Originating-IP: $HTTP_X_FORWARDED_FOR via $REMOTE_ADDR\n";

else

$header.="X-Originating-IP: $REMOTE_ADDR\n";

mail($to,"Mail Form Results",$formmessage,$header);

header("Location: confirm.htm");

?>

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/97051-formmailphp-help-required/
Share on other sites

first of all i've never seen any email scripts like this but that's cool :P what you could do is to add hidden input in your forms something like

<input type="hidden" name="formname" value="red">

 

now in the mail code you add

$formname = $_REQUEST['formname'];
$mailsubject = "This was sent from the $formname form";

 

and replace

mail($to,"Mail Form Results",$formmessage,$header);

with this

mail($to,$mailsubject,$formmessage,$header);

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.