PDA

View Full Version : redirect using php



jimw00d
January 24th, 2003, 05:30 AM
I am using the following code:

<html>
<body>
<?php
$ToEmail = "northls@nbkayaking.com";

$ToSubject = "Enquiry";

$BrowserType = $HTTP_USER_AGENT;

$MediaTypes = $HTTP_ACCEPT;

$ServerName= $REMOTE_ADDR;

$Date= date("d/F/y\n\nH.i");

$EmailBody = "Sent By: $FirstName\nSenders Email: $Email\n\nMessage Sent:\n$ToComments\n\n$BrowserType\n$MediaTypes\n$
ServerName\n\n$Date";

mail($ToName." <".$ToEmail.">",$ToSubject, $EmailBody, "From: ".$FirstName." <".$Email.">");

if(mail($ToName." <".$ToEmail.">",$ToSubject, $EmailBody, "From: ".$FirstName." <".$Email.">")){
echo "Mail Sent";
}
else{
echo "Mail not Sent";
}
?>


In flash Mx I have a mail form which posts this code, in turn producing an email which is working fine.

I decided however to display to the user whether the mail was sent and received by the server.

I therefore need to include a redirection script but I cannot get header() to work and I am not sure how to include java pop up scripts.


Maybe using the alert() function in java would help??

Any ideas??

eyezberg
January 24th, 2003, 08:05 AM
Why dont you just "echo "Mail Sent";" back to flash using a dynamic textfield to display the status variable, as in
echo "&status=Mail Sent"; // or not sent..

jimw00d
January 24th, 2003, 08:54 AM
Would you care to explain in a little more detail, i.e. what format would flash accept the variable in, how would I define the location of the php variable in flash.

I am a bit of a newbie

I take it the get method could be used.

eyezberg
January 25th, 2003, 08:32 AM
"echo "Mail Sent";"
prints stuff to the browser,

"echo "&status=Mail Sent";"
will sent the status variable back to flash,
so in flash you'll get (on the same timeline you called the php)
a variable "status" containing "Mail sent".

All you need then is a dynamic textfield,
textfield.text=status;
maybe send the mailer clip to a loading frame on submitting,
and on data, to another frame to display the result (status).

all variables on the same timeline you call a script from are sent to php, php will set up a variable $flashvariable with the same name for each; one thing to note is, flash is not case-sensitive with var names, php IS!
when you echo like above, flash gets the var & the content,
you could also do

if(mail($ToName." <".$ToEmail.">",$ToSubject, $EmailBody, "From: ".$FirstName." <".$Email.">")){
$status= "Mail Sent";
}
else{
$status= "Mail not Sent";
}
echo "&status="$status;

jimw00d
January 27th, 2003, 04:01 AM
Sorry to keep on the same subject but the php code you suggested is producing errors:

<html>
<body>
<?php
$ToEmail = "northls@nbkayaking.com";

$ToSubject = "Enquiry";

$BrowserType = $HTTP_USER_AGENT;

$MediaTypes = $HTTP_ACCEPT;

$ServerName= $REMOTE_ADDR;

$Date= date("d/F/y\n\nH.i");

$EmailBody = "Sent By: $Name\nSenders Email: $Email\n\nFrom: $From\n\nInterested In: $InterestedIn\n\nMessage Sent:\n$Details\n\n$BrowserType\n$MediaTypes\n$Ser verName\n\n$Date";

mail($ToName." <".$ToEmail.">",$ToSubject, $EmailBody, "From: ".$FirstName." <".$Email.">");

if(mail($ToName." <".$ToEmail.">",$ToSubject, $EmailBody, "From: ".$Name." <".$Email.">")){
$status= "Mail Sent";
}
else{
$status= "Mail not Sent";
}
"echo "&status=Mail Sent";"

?>
</body>
</html>

The error report suggests that there is an unexpected =

Any ideas???