php contact form

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
Bendeguz
Forum Newbie
Posts: 1
Joined: Tue Nov 04, 2008 10:23 am

php contact form

Post by Bendeguz »

hello all
I am very new to php and am having trouble adding the php script to my contact form.
I have a contact form made in swishmax2. this form was a tutorial and i have done that.
But as for the php script for the contact form, it was not explained how and where to add
script if i create new fields in the movie.
I have done this in Swishmax2 this code is for thew submit button. Now originally there was 4 fields
with this tutorial and i added 4 more but i am not sure where to add the extra php script for the new
fields.
this is the script in Swishmax2 for the submit button:

on (release) {
if((bridenameVar=="")||(brideemailVar=="")||(weddingdateVar=="")||(ceremonylocationVar=="")||(bridesaddressVar=="")||(cityVar=="")||(zipcodeVar=="")||(weddingdetailsVar=="")){
errormessage="Please fill out all the fields";
}
else {
errormessage="Sending....";
send="yes";
this.loadVariables("contact.php",'POST');
send="no";
bridenameVar="";//this was the nameVar//
brideemailVar="";//this was the emailVar//
weddingdateVar="";//this was the subjectVar//
ceremonylocationVar="";//new field added//
bridesaddressVar="";//new field added//
cityVar="";//new field added//
zipcodeVar="";//new field added//
weddingdetailsVar="";//this was the messageVar//
}
}
Now the original php script that came with the tutorial is this:

<?
if ($send=="yes") {
$to = "info@mafloral.com";//this is the email the message will be delivered to//
$subject = "$subjectVar";
$body .= "$msgVar";
$from = "$nameVar";
$tfrom = "From: <$emailVar>";
mail($to,$subjectVar,$msgVar,$tfrom);
}
echo "&errormessage=Email has been sent&";
?>

Could someone please help me with adding the script in the php
for the newly created fields.

Thanks in Advance
Bendeguz
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: php contact form

Post by Jade »

Have you tried accessing them from the $_POST variable?

Code: Select all

 
<?
if ($_POST['send'] =="yes") {
$to = "info@mafloral.com";//this is the email the message will be delivered to//
$subject = $_POST['subjectVar'];
$body .= $_POST['msgVar'];
$from = $_POST['nameVar'];
$tfrom = "From: <" . $_POST['emailVar'] . ">";
mail($to,$subject,$body,$tfrom);
}
echo "&errormessage=Email has been sent&";
?>
 
Post Reply