if you need it, my php info is at http://www.laurentobia.com/phpversion.phpQuote:
Originally Posted by Chimpanzee
Printable View
if you need it, my php info is at http://www.laurentobia.com/phpversion.phpQuote:
Originally Posted by Chimpanzee
Hi All,
Can someone please help me out :( been stuck on trying to solve this issue for a while now and cant figure out why it isnt working.
As the Point of this whole thread is about PHP not recieving variable from flash, i thought this would be the best place to put it!
The Variables are assigning correctly in flash but when passing them to PHP nothing is in the $_POST array :thumbsdow
Here is my flash code and PHP
[Flash Code]var msg:LoadVars = new LoadVars();
var TScore = "465";
var TName = "Testing"
msg.nName = nName.text;
msg.score = Score.text;
phpResult.text = msg.toString();
msg.send("WebsiteAddress.php","_parent","POST");[/Flash Code]
Can someone please point out where the bloody hell i am going wrong please, its doing my head in!PHP Code:<html>
<head>
<title>Basic PHP</title>
</head>
<body>
<?php
$link = mysql_connect("localhost", "blah", "blah");
if(!$link) {
// no database link, handle appropriately
} else { // we have db, lets continue!
$result = mysql_select_db("awm_eq264145", $link);
if(!$result) {
// no db selection, handle appropriately
} else { // we have our db, lets continue!
$query = "INSERT INTO assignment (Name, Score) VALUES ('" .$_POST['nName']."','". $_POST['score']."')";
if(mysql_query($query,$link)){
//if the query was successfully sent, get the number of rows
$rows_affected = mysql_affected_rows($link);
} else {
printf("<pre>");
print_r($_POST);
printf("</pre>");
printf($query);
printf("bollox didnt work");
}
}
}
?>
Hi,
flash should look like
var msg:LoadVars = new LoadVars();
msg.TScore = "465";
msg.send("WebsiteAddress.php","_parent","POST");
Musicman
Hi there,
I have an email form movie with a php script which works perfectly as a standalone swf.
The problem arise when I import the form into my website movie and make it a movie symbol, which I subsequently drag into another page and at this stage the form stops working. Must be something simple I have overlooked.
Any ideas? Help appreciated.
Jan
Hi,
this sounds very much like the old loadvariablesnum with level 0 or _root as a target.
Once your movie works with loadvariables and relative target (this, _parent) or a loadvars object, it should work by itself and as part of a bigger movie
Musicman
Thanks for the reply!
What I have is the following:
on (release) {
sender_mail = _root.Semail.text
sender_name = _root.Sname.text
sender_subject = _root.Ssubject.text
sender_message = _root.Smessage.text
loadVariables("sendmail.php",this,"POST");
this.onData = function()
{
for(var a in this) trace([a,this[a]])
_root.nextFrame();
if(this.output=='sent')
{
_root.errTitle = 'Thank You.';
_root.errType = "Your message has been succesfully sent.";
} else {
// else
_root.errTitle = "Error!";
_root.errType = "Attention, an error occurred while processing your message. Please try again later.";
}
}
}
Funny that it works on it's own though!
Is there such a thing in flash that you cannot place a movie symbol within another movie symbol for the php script to work? Simply asking because it seems odd for it work when in a standalone, but not when imported.
Thanks again!
Jan
Hi,
are you sure your text fields are still in the _root?
Musicman
You may well have a point there Musicman!
As I have trawled the net for a solution, I understand that there is a common problem attached to the use of _root and that _root infact is regarded as poor practice.
With regard to my example above, is there any way to re-write the code to avoid _root ?
Thanks again!
Jan
That did the trick! Simply replaced all _root with _parent and "hey presto"!
Thanks again Musicman!
Best Regards
Jan
had the same exact problem
not sure if this is the right post to get some help with this but my flash isnt communicating with my php file for sending email from flash
Code:var sendData_lv:LoadVars = new LoadVars();
var receiveData_lv:LoadVars = new LoadVars();
var formValidated:Boolean;
var errorMessages:Array = new Array();
receiveData_lv.onLoad = function():Void{
trace(this.sent);
if(this.sent == "OK"){
message0_txt.text = "Thank you for your Request, I will be intouch with you shortly";
}else{
message0_txt.text = this.sent;
}
}
submit_btn.onRelease = function() {
//this clears the error text field if they have been populate previously
clearTextFields();
errorMessages.length = 0; //empty the array so next time the submit button is clicked the array is not already populated
formValidated = checkForm();
if (formValidated) {
//the form is valid and so now we can send details to our PHP file
//populate LoadVars object with the field values
sendData_lv.name = name_txt.text;
sendData_lv.email = email_txt.text;
sendData_lv.phone = phone_txt.text;
sendData_lv.request = request_txt.text;
//trace(sendData_lv.email);
//trace("valid");
sendData_lv.sendAndLoad("email1.php"+new Date().getTime(), receiveData_lv);
} else {
//populate textfields with the error messages
for (var i = 0; i<errorMessages.length; i++) {
_root["message"+i+"_txt"].text = errorMessages[i];
trace(errorMessages[i]);
}
}
};
function checkForm():Boolean {
//check whether the name field is empty
if (name_txt.text == "") {
errorMessages.push("Please enter your name.");
}
if (email_txt.text == "") {
errorMessages.push("Please enter your email address.");
} else if (email_txt.text.indexOf("@") == -1 || email_txt.text.indexOf(".") == -1) {
errorMessages.push("Please enter a valid email address.");
}
if (request_txt.text == "") {
errorMessages.push("Please enter Request information");
}
//if at this point the array is empty i.e has length 0, then this in effect means the form has passed all checks
if (errorMessages.length == 0) {
return true;
} else {
return false;
}
}
function clearTextFields():Void {
for (var i = 0; i<errorMessages.length; i++) {
_root["message"+i+"_txt"].text = "";
;
}
}
PHP Code:<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$request = $_POST['request'];
$subject = 'Request from your website';
$headers = "From: $name <$email>\n";
$headers .= "Reply-To: $name <$email>\n";
//ENTER YOUR EMAIL ADDRESS HERE
$to = '[email protected]';
//---------------------------
$success = mail($to, $subject, $request, $headers);
if($success){
echo '&sent=OK';
}else{
echo '&sent=Error';
}
?>
Hi,
I can occasionally help when I know an actual website url
Musicman
www.parkagencywest.comQuote:
Originally Posted by Musicman
Okay, I can't figure out why this isn't working. I'm trying to send an e-mail from my flash site, and it acts like it's going through, but I'm not getting any of my test e-mails.
Here is my AS:
And here is my PHP.PHP Code:stop();
send_btn.onRelease = function() {
my_vars = new LoadVars();
my_vars.sender = email_box.text;
my_vars.subject = subject_box.text;
my_vars.message = message_box.text;
if (my_vars.sender != "" and my_vars.subject != "" and my_vars.message != "") {
my_vars.sendAndLoad("email.php", my_vars, "POST");
gotoAndStop(25);
} else {
error_clip.gotoAndPlay(25);
}
my_vars.onLoad = function() {
gotoAndStop(26);
};
};
email_box.onSetFocus = subject_box.onSetFocus=message_box.onSetFocus=function () {
if (error_clip._currentframe != 1) {
error_clip.gotoAndPlay(6);
}
};
What am I doing wrong?PHP Code:<?php
$subject = $_REQUEST["subject"];
$message = $_REQUEST["message"];
$sender = $_REQUEST["sender"];
$full_message = $_SERVER['REMOTE_ADDR'] . "\n\n" . $message;
$message= $full_message;
$message = stripslashes($message);
$subject = stripslashes($subject);
$sender = stripslashes($sender);
$subject = "Contact form ". $subject;
if(isset($message) and isset($subject) and isset($sender)){
mail("[email protected]", $subject, $message, "From: $sender");
}
?>
Hi,
can you just upload this php file and view it in browser?
If you do get the mail, then there might be a problem with your movie. If you dont get it, you should ask the server staff for assistanceCode:<?
mail("[email protected]", "test message", "just a test", "From: [email protected]");
echo "mail sent...";
?>
Musicman
Okay, I uploaded just the that php file, and it showed up in the directory, so when I clicked on it, nothing happened. No e-mail, or anything. I take it I need to talk to the server staff now?Quote:
Originally Posted by Musicman
Hi,
it did not even say "mail sent" then?
Could this be a windows server with unconfigured mail function?
Musicman
Here is all that shows up:
http://www.tomartin.net/php.php
Should I have renamed the php file "index" instead?
Hi,
probably write the file again, with as simple a program as possible (e.g. notepad on windows) that does not add
<title>Untitled Document</title>
by itself or convert every < to <
Musicman
Such as this?
http://www.tomartin.net/mail.htm
Sorry, I'm relatively new to PHP