Africa Posted March 20, 2008 Share Posted March 20, 2008 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 More sharing options...
clown[NOR] Posted March 20, 2008 Share Posted March 20, 2008 first of all i've never seen any email scripts like this but that's cool 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); Link to comment https://forums.phpfreaks.com/topic/97051-formmailphp-help-required/#findComment-496665 Share on other sites More sharing options...
Africa Posted March 21, 2008 Author Share Posted March 21, 2008 Hey cheers for this info, I am not a programmer, so this is all new to me. Where do I put the: <input type="hidden" name="formname" value="red"> Thanks.. Link to comment https://forums.phpfreaks.com/topic/97051-formmailphp-help-required/#findComment-497250 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.