I have a problem php recognising my flash variables, I am using textInput boxes from the components section.
This is my code:
// set some variables
//
mailform = "mailform.php";
confirm = "thank you a confirmation email has been sent to your email address.";
action = "send";
error1 = "valid email required";
error2 = "input required";
//
// and focus on variable fname
//
//
// validate email function
//
function validate(address) {
if (address.length>=7) {
if (address.indexOf("@")>0) {
if ((address.indexOf("@")+2)<address.lastIndexOf(".")) {
if (address.lastIndexOf(".")<(address.length-2)) {
return (true);
}
}
}
}
return (false);
}
//
// clear form
function clearform() {
name.text = "";
company.text = "";
number.text = "";
email.text = "";
from.text = "";
to.text = "";
weight.text = "";
}
// form check
//
function formcheck() {
if ((((email.text == null)) || (email.text.length<1)) || (email.text == "valid email required")) {
email.text = error1;
action = "";
}
if (!validate(email.text)) {
email.text = error1;
action = "";
}
if ((name.text == null) || (name.text == "")) {
name.text = error2;
action = "";
}
if ((company.text == null) || (company.text == "")) {
company.text = error2;
action = "";
}
if ((number.text == null) || (number.text == "")) {
number.text = error2;
action = "";
}
if ((from.text == null) || (from.text == "")) {
from.text = error2;
action = "";
}
if ((to.text == null) || (to.text == "")) {
to.text = error2;
action = "";
}
if ((weight.text == null) || (weight.text == "")) {
weight.text = error2;
action = "";
}
if ((validate(email.text)) && (email.text != error1) && (name.text != "") && (name.text != error2) && (company.text != "") && (company.text != error2) && (number.text != "") && (number.text != error2) && (from.text != "") && (from.text != error2) && (to.text != "") && (to.text != error2) && (weight.text != "") && (weight.text != error2)) {
action = "send";
loadVariablesNum(mailform, 0, "POST");
}
}
stop();
my php code is:
<?
$adminaddress = "info@nicktoye.co.uk";
$siteaddress ="http://www.keepcouriers.co.uk";
$sitename = "Keep Couriers";
//No need to change anything below ...
// Gets the date and time from your server
$date = date("m/d/Y H:i:s");
// Gets the IP Address
if ($REMOTE_ADDR == "") $ip = "no ip";
else $ip = getHostByAddr($REMOTE_ADDR);
// Gets the POST Headers - the Flash variables
$action = $HTTP_POST_VARS['action'] ;
$email = $HTTP_POST_VARS['email.text'] ;
$name = $HTTP_POST_VARS['name'] ;
$company = $HTTP_POST_VARS['company.text'] ;
$number = $HTTP_POST_VARS['number.text'] ;
$from = $HTTP_POST_VARS['from.text'] ;
$to = $HTTP_POST_VARS['to.text'] ;
$weight = $HTTP_POST_VARS['weight.text'] ;
//Process the form data!
// and send the information collected in the Flash form to Your nominated email address
if ($action == "send") {
//
mail ("$adminaddress","Info Request",
"A visitor at $sitename has left the following information
Name: $name
Email: $email
The visitor commented:
------------------------------
From: $company
Contact Me On $number
I want a quote for delivering a parcel $from
to $to
at an approximate weight of $weight
Logged Info :
------------------------------
Using: $HTTP_USER_AGENT
Hostname: $ip
IP address: $REMOTE_ADDR
Date/Time: $date","FROM:$adminaddress" ) ;
//This sends a confirmation to your visitor
mail ("$email","Thank You for visiting $sitename",
"Hi $name,
Thank you for your interest in $sitename!
Cheers,
$sitename
$siteaddress","FROM:$adminaddress") ;
//Confirmation is sent back to the Flash form that the process is complete
$sendresult = "Thank you. You will receive a confirmation email shortly.";
$send_answer = "answer=";
$send_answer .= rawurlencode($sendresult);
echo $send_answer;
} //
?>
<?
$adminaddress = "info@nicktoye.co.uk";
$siteaddress ="http://www.keepcouriers.co.uk";
$sitename = "Keep Couriers";
//No need to change anything below ...
// Gets the date and time from your server
$date = date("m/d/Y H:i:s");
// Gets the IP Address
if ($REMOTE_ADDR == "") $ip = "no ip";
else $ip = getHostByAddr($REMOTE_ADDR);
// Gets the POST Headers - the Flash variables
$action = $_POST['action'] ;
$email = $_POST['email.text'] ;
$name = $_POST['name'] ;
$company = $_POST['company.text'] ;
$number = $_POST['number.text'] ;
$from = $_POST['from.text'] ;
$to = $_POST['to.text'] ;
$weight = $_POST['weight.text'] ;
//Process the form data!
// and send the information collected in the Flash form to Your nominated email address
if ($action == "send") {
//
mail ("$adminaddress","Info Request",
"A visitor at $sitename has left the following information
Name: $name
Email: $email
The visitor commented:
------------------------------
From: $company
Contact Me On $number
I want a quote for delivering a parcel $from
to $to
at an approximate weight of $weight
Logged Info :
------------------------------
Using: $HTTP_USER_AGENT
Hostname: $ip
IP address: $REMOTE_ADDR
Date/Time: $date","FROM:$adminaddress" ) ;
//This sends a confirmation to your visitor
mail ("$email","Thank You for visiting $sitename",
"Hi $name,
Thank you for your interest in $sitename!
Cheers,
$sitename
$siteaddress","FROM:$adminaddress") ;
//Confirmation is sent back to the Flash form that the process is complete
$sendresult = "Thank you. You will receive a confirmation email shortly.";
$send_answer = "answer=";
$send_answer .= rawurlencode($sendresult);
echo $send_answer;
} //
?>
Can you see where I am going wrong.
I took out the component input boxes and just put in some standard input boxes, put the correct variable’s in and it worked. So when I went back to my components way of doing things. It stopped working. I know that you can’t specify a variable name for a component like you can for a standard input box, but i thought with loadVars you could.
Its probable simple I know that, but I can’t see it.
Ok, I am not very good at this thing, but there are two things I don’t see, that I have used/included to successfully achieve what you are trying to do.
The first thing I don’t see in your code is where you are setting the input box values to the LoadVar variables. Currently you have all the formData values given to strings. formData.name = “name”; is a string.
The next thing I didn’t see was an ‘onload’ function for the returned data. you can place this underneath your formData = LoadVars info, though I don’t think it matters where it is placed.
ok so how would i change the formData part to assign the values to variables, i actually thought i had done that, but if i have done it wrong can you tell me the right way
Go back to using plain inputboxes with instance names of ‘name’, ‘company’, etc etc.
or tell me which component you are using, so I can look at how it handles info