View Full Version : forms using PHP or CDsys.. and...

06-04-2009, 07:25 PM
Hello all

I need to redo a clients forms on his website.. he has a few pages that have forms - I have a few questions before I begin:
1. Should I use PHP or CDsys - anyone have a preference?
2. If I use PHP ( I know how to do this - I think in CDsys) how do I send the form to a person based on the selection of the users closest city? e.g - the form has a drop down of 25 or so cities.. based on the selection like "Seattle" the form is to be sent to paul@clientsemail.com - I found a page via this DC site [ http://www.dreamweaverclub.com/dreamweaver-php-form.php ] that has a good example of PHP form code I sorta understand it and do have some form PHP code via a past job I had... but nothing of how to accomplish this based on selection thing I need to do

Thanks - example below
if(isset($_POST['submit'])) {
$from = "contact_form@xxxxxxxx.com";
$to = "yonga@xxxxxx.com";
$Name_field = $_POST['Name'];
$subject = "Request for info from: $Name_field";
$Email_field = $_POST['EmailAddress'];
$PhoneNumber_field = $_POST['PhoneNumber'];
$City_field = $_POST['City'];
$State_field = $_POST['State'];
$Referral_field = $_POST['Referral'];
$Story_field = $_POST['Story'];
$headers = "From: $from \n";
$headers .= "bcc: mi@xxxxxxx.com \n";
$Story = $_POST['Story'];
$body = "Name: $Name_field\n Email address: $Email_field\n Phone Number: $PhoneNumber_field\n City: $City_field\n State: $State_field\n How did you hear about our firm? $Referral_field\n User Message:\n $Story";
echo "";
mail($to, $subject, $body, $headers);

06-05-2009, 01:58 AM
this script at present will send to yonga@xxxxxx.com which is declared as $to
you need to re define $to to the form field that is being passesd for ie
$to = $Email_field ;

put it after the $Email_field has been declared though.
word of caution any address entered in the form field will be sent , so any text in $story would be also sent, leaving a perfect opportunity for spammers