-
Begin the rat race
error not showing
Hello
I am trying to modify the code on my submit button to let the user know they havent filled out their name, email, and contact number properly.
here is the original code:
Code:
//submit button
on(release){
if(name_txt.text == "" || email_txt.text == "" || phone_txt.text == ""){
'code to display error'
break;
}else{
form.loadVariables("email.php", "POST");
}
}
after this failed to work i then altered it to this:
Code:
on (release) {
if (_root.name_txt.text.length < 3 || _root.email_txt.text.length < 6 || _root.phone_txt.text.length < 6) {
'code to display error';
break;
} else {
form.loadVariables("email.php", "POST");
}
trace("Length: " + _root.name_txt.text.length);
}
but still no luck, i looked at it again and im thinking i need to alter this `code to display error` to the actual code to bring up the error or play the movie but i dont know how to do it, im so lost.
any help or advice?
cheers
<br />
darrenazzopardi.wordpress.com
-
try this
PHP Code:
on(release){
if(_root.name_txt.length == 0 || _root.email_txt.length == 0 || _root.phone_txt.length == 0){
_root.name_txt.text = "Required" /// or create a movie clip that will show the user a message.
example: error_mc._visable = true;
break;
}else{
form.loadVariables("email.php", "POST");
}
}
Last edited by wattsup; 12-08-2005 at 07:20 AM.
-
This works. Not exactly ideal though.
Code:
_root.onEnterFrame = function () {
var myNameString_str:String = _root.name_txt.text;
var myEmailString_str:String = _root.email_txt.text;
var myPhoneString_str:String = _root.phone_txt.text;
_root.myButton_btn.onPress = function () {
if (myNameString_str.length == 0 || myEmailString_str.length == 0 || myPhoneString_str.length == 0) {
// ...
// Run error code here.
trace("Error: Field error detected.");
trace("==============================");
} else {
// ....
// Post to form.
};
};
};
-
Begin the rat race
change my old variables to the new ones
Hi thanks for both your reply,
while i was doing some code research, i looked at this code and popped it into mine
Code:
function ckName(){
if (formData.name == ""){
errBox.setMessage("You Must Fill In Your Name");
return false; }
else {
return true};
}
function ckEmail(){
if(formData.email == ""){
errBox.setMessage("You Must Fill In Your Email Address");
return false;}
else{
if(formData.email.indexOf(".",0)==-1 || formData.email.indexOf("@",0)==-1){
errBox.setMessage("Your Email Address Is Not In Correct Form");
return false;}
else{
return true;}
}
}
function clrData(){
this.formData.name = "";
this.nameIN.text = "";
this.formData.email = "";
this.emailIn.text = "";
this.formData.company = "";
this.companyIn.text = "";
this.formData.phone= "";
this.phoneIn.text = "";
}
function myOnLoad(success){
errBox.setEnabled(true);
if(success){
errBox.setIcon("info");
errBox.setTitle("Thank You");
errBox.setMessage("Thank You For Contacting Consulting. We will respond shortly.");
errBox._visible=true;
clrData();
}
else{
errBox.setIcon("warning");
errBox.setTitle("System Error");
errBox.setMessage("There has been a system error submitting your email. Please re-submit. Thank you.");
errBox._visible=true;
}
}
function goPostal(){
if(!ckName()){errBox._visible=true;return;}
else{
if(!ckEmail()){errBox._visible=true;return;}
}
errBox.setIcon("info");
errBox.setTitle("Sending Mail");
errBox.setMessage("Your Email Is Being Submitted");
errBox._visible=true;
errBox.setEnabled(false);
form.loadVariables("email_1.php", "POST");
}
this works perfectly as the errors show when the field has not been completed.
My question is because i changed my original variables to match the new ones, for example, name to formData.name, my php has changed
I have to adjust the php code, but here i`m having trouble. For me its trial and error so its taken me a while but i havent cracked it.
what i need to do is replace my original variables with the new ones:
name=formData.name
email=formData.email
company=formData.company
phone=formData.phone.
here is my orinal code:
PHP Code:
<?php
$sendTo = "dazzclub@yahoo.co.uk";
$subject = "my website Enquiry/Comment";
// 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.
// header information not including sendTo and Subject
// these all go in one variable. First, include From:
$headers = "From: " . $_POST["name"] ." <" . $_POST["email"] .">\r\n";
// next include a replyto
$headers .= "Reply-To: " . $_POST["email"] . "\r\n";
// often email servers won't allow emails to be sent to
// domains other than their own. The return path here will
// often lift that restriction so, for instance, you could send
// email to a hotmail account. (hosting provider settings may vary)
// technically bounced email is supposed to go to the return-path email
$headers .= "Return-path: " . $_POST["email"];
// now we can add the content of the message to a body variable
$message = $_POST["message"] . "\n\nContact details:\nPhone: ".$_POST["phone"]."\nAddress: ".$_POST['address'];
// added fields
$message = $message . "\nAddress 2: ".$_POST["address2"]."\nAddress3: ".$_POST['address3'];
// etc...
// added fields
$message = $message . "\nTown: ".$_POST["town"]."\nCity: ".$_POST['city'];
// added fields
$message = $message . "\nCountry: ".$_POST["country"]."\nPostcode: ".$_POST['postcode'];
// added fields
$message = $message . "\nTemperature: ".$_POST["temperature"]."\nColour: ".$_POST['colour'];
// added fields
$message = $message . "\nInktype: ".$_POST["inktype"]."\nApplication: ".$_POST['application'];
// added fields
$message = $message . "\nCompany: ".$_POST["company"]."\nCompany: ".$_POST['company'];
// added fields
$message = $message . "\nName: ".$_POST["name"]."\nName: ".$_POST["name"].
// 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, $body );
?>
Ive tried swapping them around but no luck, any ideas?
thanks
<br />
darrenazzopardi.wordpress.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|