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..
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..