sjslovechild
01-16-2007, 04:26 PM
I'm having problems getting php to validate the information from a component based flash form and email the information.
With no validation the php script sends email just fine, it just also sends blank emails. With validation the warning messages come up for all the required fields saying that nothing was entered. This is constant if all, some or none of the fields have content in them. Any help would be appreciated.
//Below is the actionscript code in the movies first frame.
stop();
submit_btn.onRelease = function() {
var emailResponse:LoadVars = new LoadVars();
var email:LoadVars = new LoadVars();
email.dealer = dealership_txt.text;
email.dealeremail = dealership_txt.getValue();
email.model = model_txt.text;
email.name = name_txt.text;
email.address = address_txt.text;
email.city = city_txt.text;
email.zip = zip_txt.text;
email.email = email_txt.text;
email.phone = phone_txt.text;
getURL("http://www.foobar.com/form_validation.php", emailResponse, "POST")
emailResponse.onLoad = function() {
debug_txt.text = this.result;
};
// gotoAndStop(2);
};
//Below is the PHP code that sends nothing but validation errors.
<?php # form validation script
$dealer = $_REQUEST["email.dealer"];
$dealeremail = $_REQUEST["email.dealeremail"];
$model = $_REQUEST["email.model"];
$name = $_REQUEST["email.name"];
$address = $_REQUEST["email.address"];
$city = $_REQUEST["email.city"];
$zip = $_REQUEST["email.zip"];
$email = $_REQUEST["email.email"];
$phone = $_REQUEST["email.phone"];
// check $dealername and strip any slashes
if (!empty($dealername)) {
$dealername = stripslashes($dealername);
} else { //If no value was entered...
echo'<p><b>You forgot to select a Dealer</b></p>';
}
if (!empty($model)) {
$model = stripslashes($model);
} else { //If no value was entered...
echo'<p><b>You forgot to select a model</b></p>';
}
if (!empty($name)) {
$name = stripslashes($name);
} else { //If no value was entered...
echo'<p><b>You forgot to enter your name</b></p>';
}
if (!empty($address)) {
$address = stripslashes($address);
} else { //If no value was entered...
echo'<p><b>You forgot to enter your address</b></p>';
}
if (!empty($city)) {
$city = stripslashes($city);
} else { //If no value was entered...
echo'<p><b>You forgot to enter your city</b></p>';
}
if (!empty($zip)) {
$zip = stripslashes($zip);
} else { //If no value was entered...
echo'<p><b>You forgot to enter your zip code</b></p>';
}
if (!empty($phone)) {
$phone = stripslashes($phone);
} else { //If no value was entered...
echo'<p><b>You forgot to enter your Phone code</b></p>';
}
if (!empty($email)) {
echo'<p><b>You forgot to enter a email address</b></p>';
}
//if everything is filled out send the email
if ($dealername && $model && $name && $address && $city && $zip && $phone && $email){
$message = "
Price Request:
**********************
Dealer: $dealer
Model: $model
First Name: $name
Current Street Address: $address
City: $city
Zip Code: $zip
Email: $email
Home Phone Number (Area Code Included): $phone
";
$email = "$dealeremail";
$subject = "Price Request";
$from = "From: Price Request <foobar.com>";
mail($email, $subject, $message, $from);
}
?>
//Below is the PHP code that sends email fine with no validation.
<?php
$dealer = $_REQUEST["dealer"];
$dealeremail = $_REQUEST["dealeremail"];
$model = $_REQUEST["model"];
$name = $_REQUEST["name"];
$address = $_REQUEST["address"];
$city = $_REQUEST["city"];
$zipcode = $_REQUEST["zip"];
$email = $_REQUEST["email"];
$phone = $_REQUEST["phone"];
$message = "
Price Request:
**********************
Dealer: $dealer
Model: $model
First Name: $name
Current Street Address: $address
City: $city
Zip Code: $zipcode
Email: $email
Home Phone Number (Area Code Included): $phone
";
$email = "$dealeremail";
$subject = "Ford Dealers Price Request";
$from = "From: Ford Dealers Price Request <foobar.net>";
mail($email, $subject, $message, $from);
?>
With no validation the php script sends email just fine, it just also sends blank emails. With validation the warning messages come up for all the required fields saying that nothing was entered. This is constant if all, some or none of the fields have content in them. Any help would be appreciated.
//Below is the actionscript code in the movies first frame.
stop();
submit_btn.onRelease = function() {
var emailResponse:LoadVars = new LoadVars();
var email:LoadVars = new LoadVars();
email.dealer = dealership_txt.text;
email.dealeremail = dealership_txt.getValue();
email.model = model_txt.text;
email.name = name_txt.text;
email.address = address_txt.text;
email.city = city_txt.text;
email.zip = zip_txt.text;
email.email = email_txt.text;
email.phone = phone_txt.text;
getURL("http://www.foobar.com/form_validation.php", emailResponse, "POST")
emailResponse.onLoad = function() {
debug_txt.text = this.result;
};
// gotoAndStop(2);
};
//Below is the PHP code that sends nothing but validation errors.
<?php # form validation script
$dealer = $_REQUEST["email.dealer"];
$dealeremail = $_REQUEST["email.dealeremail"];
$model = $_REQUEST["email.model"];
$name = $_REQUEST["email.name"];
$address = $_REQUEST["email.address"];
$city = $_REQUEST["email.city"];
$zip = $_REQUEST["email.zip"];
$email = $_REQUEST["email.email"];
$phone = $_REQUEST["email.phone"];
// check $dealername and strip any slashes
if (!empty($dealername)) {
$dealername = stripslashes($dealername);
} else { //If no value was entered...
echo'<p><b>You forgot to select a Dealer</b></p>';
}
if (!empty($model)) {
$model = stripslashes($model);
} else { //If no value was entered...
echo'<p><b>You forgot to select a model</b></p>';
}
if (!empty($name)) {
$name = stripslashes($name);
} else { //If no value was entered...
echo'<p><b>You forgot to enter your name</b></p>';
}
if (!empty($address)) {
$address = stripslashes($address);
} else { //If no value was entered...
echo'<p><b>You forgot to enter your address</b></p>';
}
if (!empty($city)) {
$city = stripslashes($city);
} else { //If no value was entered...
echo'<p><b>You forgot to enter your city</b></p>';
}
if (!empty($zip)) {
$zip = stripslashes($zip);
} else { //If no value was entered...
echo'<p><b>You forgot to enter your zip code</b></p>';
}
if (!empty($phone)) {
$phone = stripslashes($phone);
} else { //If no value was entered...
echo'<p><b>You forgot to enter your Phone code</b></p>';
}
if (!empty($email)) {
echo'<p><b>You forgot to enter a email address</b></p>';
}
//if everything is filled out send the email
if ($dealername && $model && $name && $address && $city && $zip && $phone && $email){
$message = "
Price Request:
**********************
Dealer: $dealer
Model: $model
First Name: $name
Current Street Address: $address
City: $city
Zip Code: $zip
Email: $email
Home Phone Number (Area Code Included): $phone
";
$email = "$dealeremail";
$subject = "Price Request";
$from = "From: Price Request <foobar.com>";
mail($email, $subject, $message, $from);
}
?>
//Below is the PHP code that sends email fine with no validation.
<?php
$dealer = $_REQUEST["dealer"];
$dealeremail = $_REQUEST["dealeremail"];
$model = $_REQUEST["model"];
$name = $_REQUEST["name"];
$address = $_REQUEST["address"];
$city = $_REQUEST["city"];
$zipcode = $_REQUEST["zip"];
$email = $_REQUEST["email"];
$phone = $_REQUEST["phone"];
$message = "
Price Request:
**********************
Dealer: $dealer
Model: $model
First Name: $name
Current Street Address: $address
City: $city
Zip Code: $zipcode
Email: $email
Home Phone Number (Area Code Included): $phone
";
$email = "$dealeremail";
$subject = "Ford Dealers Price Request";
$from = "From: Ford Dealers Price Request <foobar.net>";
mail($email, $subject, $message, $from);
?>