nate51
08-11-2008, 05:00 AM
I have a simple email form on my site that is a flash site that when someone hits submit a php page sends the data to my email. With it being a simple type of form it does not check the fields before submiting and I don't know why people do this but they hit submit without filling anything in.
Are there any tutorials or can anyone help me so that if certain fields are not filled in, the submit button cannot be used or it will prompt people to fill the fields.
Here is my action script code for the mc that holds the fields
onClipEvent(data){
// show welcome screen
_root.content_mc.contact_mc.gotoAndPlay(33);
}
Here is the php page
<?php
/***************************************************\
* PHP 4.1.0+ version of email script. For more
* information on the mail() function for PHP, see
* http://www.php.net/manual/en/function.mail.php
\***************************************************/
// First, set up some variables to serve you in
// getting an email. This includes the email this is
// sent to (yours) and what the subject of this email
// should be. It's a good idea to choose your own
// subject instead of allowing the user to. This will
// help prevent spam filters from snatching this email
// out from under your nose when something unusual is put.
$sendTo = "xxxx@xxxxx.com";
$subject = "Inquiry/Comment from site";
// variables are sent to this PHP page through
// the POST method. $_POST is a global associative array
// of variables passed through this method. From that, we
// can get the values sent to this page from Flash and
// assign them to appropriate variables which can be used
// in the PHP mail() function.
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: " . $_POST["name"] ."<" . $_POST["email"] .">\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
// now we can add the content of the message to a body variable
$message = "From: " . $_POST["name"] ." " . $_POST["email"] ." " . $_POST["message"] ."\r\n";
// once the variables have been defined, they can be included
// in the mail function call which will send you an email
mail($sendTo, $subject, $message, $headers);
?>
*Note I am aware there is a slight flaw in the code so that when I get email responses the address bar has a bunch of excess code in it I am still working on it, but as long as the emails are getting to me and I can get names, email address and comment from it, that's fine for me for now.
Are there any tutorials or can anyone help me so that if certain fields are not filled in, the submit button cannot be used or it will prompt people to fill the fields.
Here is my action script code for the mc that holds the fields
onClipEvent(data){
// show welcome screen
_root.content_mc.contact_mc.gotoAndPlay(33);
}
Here is the php page
<?php
/***************************************************\
* PHP 4.1.0+ version of email script. For more
* information on the mail() function for PHP, see
* http://www.php.net/manual/en/function.mail.php
\***************************************************/
// First, set up some variables to serve you in
// getting an email. This includes the email this is
// sent to (yours) and what the subject of this email
// should be. It's a good idea to choose your own
// subject instead of allowing the user to. This will
// help prevent spam filters from snatching this email
// out from under your nose when something unusual is put.
$sendTo = "xxxx@xxxxx.com";
$subject = "Inquiry/Comment from site";
// variables are sent to this PHP page through
// the POST method. $_POST is a global associative array
// of variables passed through this method. From that, we
// can get the values sent to this page from Flash and
// assign them to appropriate variables which can be used
// in the PHP mail() function.
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: " . $_POST["name"] ."<" . $_POST["email"] .">\r\n";
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
// now we can add the content of the message to a body variable
$message = "From: " . $_POST["name"] ." " . $_POST["email"] ." " . $_POST["message"] ."\r\n";
// once the variables have been defined, they can be included
// in the mail function call which will send you an email
mail($sendTo, $subject, $message, $headers);
?>
*Note I am aware there is a slight flaw in the code so that when I get email responses the address bar has a bunch of excess code in it I am still working on it, but as long as the emails are getting to me and I can get names, email address and comment from it, that's fine for me for now.