# Redirect using php

**URL:** https://forum.kirupa.com/t/redirect-using-php/11947
**Category:** Uncategorized
**Created:** [January 24, 2003, 10:30am UTC](https://forum.kirupa.com/t/redirect-using-php/11947 "2003-01-24T10:30:21Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jimw00d](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jimw00d](https://forum.kirupa.com/u/jimw00d)
#### Post date: [January 24, 2003, 10:30am UTC](https://forum.kirupa.com/t/redirect-using-php/11947/1 "2003-01-24T10:30:21Z")

</div>

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

H.i");

$EmailBody = "Sent By: $FirstName  
Senders Email: $Email

Message Sent:  
$ToComments

$BrowserType  
$MediaTypes  
$  
ServerName

$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??

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [January 24, 2003, 1:05pm UTC](https://forum.kirupa.com/t/redirect-using-php/11947/2 "2003-01-24T13:05:52Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [January 24, 2003, 1:54pm UTC](https://forum.kirupa.com/t/redirect-using-php/11947/3 "2003-01-24T13:54:34Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [January 25, 2003, 1:32pm UTC](https://forum.kirupa.com/t/redirect-using-php/11947/4 "2003-01-25T13:32:25Z")

</div>

“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

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

```

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [January 27, 2003, 9:01am UTC](https://forum.kirupa.com/t/redirect-using-php/11947/5 "2003-01-27T09:01:58Z")

</div>

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

H.i");

$EmailBody = "Sent By: $Name  
Senders Email: $Email

From: $From

Interested In: $InterestedIn

Message Sent:  
$Details

$BrowserType  
$MediaTypes  
$ServerName

$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???
