PDA

View Full Version : Problems with flash and php


aLOy
11-22-2006, 04:24 AM
Hi..
im trying to send an e-greeting card tt's done in flash and send it over using php script.. im also using phpMySQL as a database to store the messages typed by users and the email add of the recipients tt they type.. ohh and the text inputs are located in flash.. now flash is able to send the info to the database but not to the email..

here's the codes in flash:

var domain:String = "http://sitap101:8080/proj/0607s2/3a86/";
var loadurl:String = "read_data.php";
if (msg_id>0) {
message_btn._visible = false;
var external_data:LoadVars = new LoadVars();
external_data.onLoad = function(success:Boolean) {
if (success) {
message_mc.message_txt.text = this.message;
email_txt.text = this.receiver;
}
};
trace(domain+loadurl+"?id="+msg_id);
external_data.load(domain+loadurl+"?id="+msg_id);
}

var domain:String = "http://sitap101:8080/proj/0607s2/3a86/";
var card_id:String = "NewYear_editedAS";

var outgoing_data:LoadVars = new LoadVars();
outgoing_data.onLoad = function(success:Boolean) {
if (success) {
//-- message sent successful
if (this.status == 1) {
external_data.load(domain+loadurl+card_id+msg_id);
gotoAndPlay("movieSent");
trace("message sent");
}
else {
trace("message could not be sent");
}
}
};
send_btn.onRelease = function() {
// send message to database
outgoing_data.message = data_txt.text;
outgoing_data.receiver = email_txt.text;
outgoing_data.card_id = card_id;
outgoing_data.msg_id = msg_id;
outgoing_data.sendAndLoad(domain+"add_data.php", outgoing_data, "POST");
};

and here's the php codes (the file is named add_data.php):

<?php
require_once('db_conn.php');
$message = $_POST['message'];
$receiver = $_POST['receiver'];
$query = sprintf("INSERT INTO send_tbl (message, receiver) VALUES ('%s', '%s')",
(!get_magic_quotes_gpc()) ? addslashes($message) : $message,
(!get_magic_quotes_gpc()) ? addslashes($receiver) : $receiver,
time());
echo($query);
$result = mysql_query($query) or die("Query failed : " .mysql_error());
if($result){
echo("&status=1&");
echo("&result=" . $result);

echo($_GET['card_id'] . ".swf");
echo($_GET['msg_id']);

$to = $_POST['receiver'];
$subject = 'Happy New Year!!!';
$message = 'You have received an E-Greeting card from your friend.';

$success = mail($to, $subject, $message);
echo "success=" . $success;

}else{
echo("&status=0&");
}
mysql_close($my_db_conn);
?>

PLEASE HELP!! as im still a newbie in programming.. thanks in advance..

Cota
11-22-2006, 01:11 PM
2 things I see intitially...your GET's should be POST's...and try adding a from header in the email.

$success = mail($to, $subject, $message, "From: Joe@dirt.com");

aLOy
11-24-2006, 11:14 AM
alritee.. i've changed accordingly already but still its not working.. in fact now the data could not even be sent to the database.. wad actually appears in the database is this, "<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE...". Wad does this means n y is it sent over to the database??

aLOy
12-04-2006, 07:37 AM
ok now i can send my email already.. however i've gt another problem.. anyone noes how to send a link using php so that it will appear when the email is sent over??

here are the modified codes in php:

$domain = $_GET['domain'];
$card_id = $_GET['card_id'];
$outgoing_data = $_GET[$domain . $card_id . ".swf"];

$subject = 'Happy New Year!!';
$body = 'You have received an E-Greeting card from your friend.' . "\r\n\n";
$body .= 'Click on the link below to view the card.' . "\r\n";
$body .= $outgoing_data . "\r\n";

$success = mail($receiver, $subject, $body);

php will get the url from flash cuz there are several cards n this script is shared between them.. basically it means that the 'card_id' determines which card the user wants to send.. you can refer to the top for my script in flash..

i've also tried hardcoding by typing the url directly into the message body but the .swf file that is opened by the link cannot be played at all.. wad is wrong?? im desperate!! really appreciate any help!! thanks in advance..