# Flash mx and php

**URL:** <https://forum.kirupa.com/t/flash-mx-and-php/10599>\
**Category:** Uncategorized\
**Created:** [January 3, 2003, 11:21pm UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599 "2003-01-03T23:21:40Z")\
**Posts on this page:** 20\
**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 3, 2003, 11:21pm UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/1 "2003-01-03T23:21:40Z")

</div>

I have been trying for a few days to obtain information about the users of sites. No success so far.

In flash I am using:

loadVariablesNum(“mailPHP.php”, “0”, “POST”);

My php code is:

```php

<html>
<body>
<?php
$mail_to="northls@nbkayaking.com";
$browserType=$HTTP_USER_AGENT;
$mediaTypes=$HTTP_ACCEPT;
?>
</body>
</html>

```

I know I have made an arseup somewhere.

Who knows?

Cheers

[edit]by lostinbeta to show code…  
Kaotic: Use [PHP] [/PHP] (without spaces) to show your HTML and PHP code since this forum converts that.[/edit]

---

<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 4, 2003, 12:09am UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/2 "2003-01-04T00:09:30Z")

</div>

I don’t know how Flash and PHP work together, it isn’t really my area, but I think the problem lies within your PHP script, it doesn’t look right to me. I just started learning PHP and created by own mailForm script, but I don’t know how to write one that will work with Flash like that.

---

<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 4, 2003, 10:18pm UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/3 "2003-01-04T22:18:01Z")

</div>

the correct .php file would be:

```php
<?
$mail_to="northls@nbkayaking.com";
$browserType=$HTTP_USER_AGENT;
$mediaTypes=$HTTP_ACCEPT;

echo "mail_to=\"". $mail_to ."\"&browserType=\"". $browserType ."\"&mediaTypes=\"" . $mediaTypes . "\"";
?>

```

the thing is you have to print the content of the variables like this:  
var=var\_value

for multiple variables, you can use the ampersand (&) between variables, like this: var1=var\_value1&var2=var\_value2

and one more thing… in the .php file do not use \<html\> […] tags… print out only the variables and their content

have fun 😉

---

<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 4, 2003, 10:20pm UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/4 "2003-01-04T22:20:57Z")

</div>

Even though it wasn’t me having the problems, I still want to thank you for that info.

I don’t work with server side flash, but am thinking about getting more into it, this is definitely good knowledge to have 🙂

---

<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 4, 2003, 10:57pm UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/5 "2003-01-04T22:57:41Z")

</div>

Thanks for the code. My only query is that I wanted the php file to generate an email. At the moment it only generates the code as shown in:

[http://nortls.nbkayaking.com/BrowserConfig](http://nortls.nbkayaking.com/BrowserConfig)

I guess through the echo command

Would you have an idea how to use the mail() command to send the variables through email.

I seem to keep screwing the mail command up, getting errors such as:

Warning: Wrong parameter count for mail() in C:\Program Files\Apache Group\Apache2\htdocs est.php on line 11

Regards

---

<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 5, 2003, 12:21am UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/6 "2003-01-05T00:21:05Z")

</div>

the mail() php command prototype is like this:

bool mail ( string to, string subject, string message [, string additional\_headers [, string additional\_parameters]])

so, if you want to email ‘some1@yahoo.com’ with the subject ‘wassup’ and the message ‘hello there’, you would use:

```php

if (@mail("some1@yahoo.com", "wassup", "hello there"))
     echo 'email sent';
else echo "problems sending the email :/";

```

in your case, use:

```php

if (@mail($mail_to,"subject",
     "browser= " . $browserType . "<br>" . 
     "mediaTypes= " . $mediaTypes))
  echo 'email sent';
else echo "problems sending the email :/";

```

and you’ll have an email with these things 🙂

hope i’m being usefull 🙂

---

<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 5, 2003, 12:53am UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/7 "2003-01-05T00:53:01Z")

</div>

… why wasnt this one moved to serverside scripting?

---

<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 5, 2003, 12:57am UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/8 "2003-01-05T00:57:18Z")

</div>

Very good question senocular. I didn’t even notice it was in the Actionscript section.

I moved it now.

---

<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 5, 2003, 1:45am UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/9 "2003-01-05T01:45:49Z")

</div>

:beam:

---

<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 5, 2003, 3:11am UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/10 "2003-01-05T03:11:50Z")

</div>

Thanks for the good eye 😉

[SIZE=1]::because as you can see I am missing one…lol::[/SIZE]

---

<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 5, 2003, 3:08pm UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/11 "2003-01-05T15:08:58Z")

</div>

OK my final php code is :

\<?  
$ToEmail = "northls@nbkayaking.com";

$ToSubject = “Enquiry”;

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

Message Sent:  
$ToComments  
";

$browserType=$HTTP\_USER\_AGENT;

$mediaTypes=$HTTP\_ACCEPT;

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

?\>

As you can see I have defined variables for browser type and media types. But I am having problems getting the values passed into the email. I get errors if I add thjem to the email body part of the mail command

Any pointers

Regards

---

<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 5, 2003, 8:38pm UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/12 "2003-01-05T20:38:02Z")

</div>

your code is a little bit confusing…

first, put the $browserType and $mediaTypes in $EmailBody.  
second, what variable is $ToName ? you’ve used it as the first parameter in the mail() command: $ToName." \<".$ToEmail."\>".

if ($ToName) is not defined, then the mail() tried to send an email to an invalid address

i would explain you better, but i’m in a hurry… tomorrow i start school early 😕

---

<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 6, 2003, 9:22am UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/13 "2003-01-06T09:22:45Z")

</div>

$ToName is a variable passed into the php script through flash. The real problem I have is adding additional variables, would this work as the php body?

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

Message Sent:  
$ToComments

$BrowserType=HTTP\_USER\_AGENT

$mediaTypes=$HTTP\_ACCEPT  
";

I am new to php coding and this is my first meaningful script therefore I am not sure about correct form of coding etc.

Regards

---

<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 6, 2003, 1:13pm UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/14 "2003-01-06T13:13:45Z")

</div>

I’ve had success with:

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

$ToSubject = “Enquiry”;

$BrowserType = $HTTP\_USER\_AGENT;

$MediaTypes = $HTTP\_ACCEPT;

$ServerName= $REMOTE\_ADDR. " " . $REMOTE\_USER;

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

MessageSent:  
$ToComments

$BrowserType

$MediaTypes  
$ServerName";

mail($ToName." \<".$ToEmail."\>",$ToSubject, $EmailBody, “From: “.$FirstName.” \<”.$Email."\>");  
?\>  
\</body\>  
\</html\>

Only trouble is that $HTTP\_ACCEPT returns _/_ and the BrowserType returns Mozilla rather than IE,

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 6, 2003, 8:53pm UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/15 "2003-01-06T20:53:26Z")

</div>

hmm… have no ideas on this one :((  
anyone there who can help?

---

<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 6, 2003, 8:58pm UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/16 "2003-01-06T20:58:38Z")

</div>

hmm… it just popped out of my mind… you can use get\_browser() for determining the browser type and some other stuff… maybe this will report the right browser;

i’ve searched right now on [php.net](http://php.net) about this function; look at the following example on how to use get\_browser():

```php

<?php
function list_array ($array) {
    while (list ($key, $value) = each ($array)) {
    $str .= "<b>$key:</b> $value<br>
";
    }
    return $str;
}
echo "$HTTP_USER_AGENT<hr>
";
$browser = get_browser();
echo list_array ((array) $browser);
?>

```

would write something like:

```auto

Mozilla/4.5 [en] (X11; U; Linux 2.2.9 i586)<hr>
<b>browser_name_pattern:</b> Mozilla/4\.5.*<br>
<b>parent:</b> Netscape 4.0<br>
<b>platform:</b> Unknown<br>
<b>majorver:</b> 4<br>
<b>minorver:</b> 5<br>
<b>browser:</b> Netscape<br>
<b>version:</b> 4<br>
<b>frames:</b> 1<br>
<b>tables:</b> 1<br>
<b>cookies:</b> 1<br>
<b>backgroundsounds:</b> <br>
<b>vbscript:</b> <br>
<b>javascript:</b> 1<br>
<b>javaapplets:</b> 1<br>
<b>activexcontrols:</b> <br>
<b>beta:</b> <br>
<b>crawler:</b> <br>
<b>authenticodeupdate:</b> <br>
<b>msn:</b> <br>

```

don’t worry about this example, because the browser in this test was really mozilla (the test was run under linux)

so try this function…

---

<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 23, 2003, 1:05pm UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/17 "2003-01-23T13:05:53Z")

</div>

Cold,

In a previous reply you used the echo command to display the results of my mailto() script. I would like to redirect users to another html page which will display the results of mailto().

The script I have used is:

\<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($mail\_to,“subject”,  
"browser= " . $BrowserType . “” .  
"mediaTypes= " . $MediaTypes)  
header(“Location: [http://evolt.org](http://evolt.org)”));  
exit;  
?\>  
\</body\>  
\</html\>

The last section header … I have added.

It doesn’t work at the moment. How would the echo command work with the header line, or am I way off the mark.

Know anything about launching pop-ups with php??

regards

---

<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 23, 2003, 6:21pm UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/18 "2003-01-23T18:21:06Z")

</div>

Sorry that this question has been posted twice, I did it completely by accident.

---

<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 23, 2003, 6:39pm UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/19 "2003-01-23T18:39:09Z")

</div>

Completely all right. I took care of it for ya 😉

---

<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 23, 2003, 8:21pm UTC](https://forum.kirupa.com/t/flash-mx-and-php/10599/20 "2003-01-23T20:21:30Z")

</div>

well, in case of succes, header() to .php page that says ‘email sent’ or something like this… otherwise, header() to a .php that says ‘not sent’;

furthermore, you can header() to a page like x.php?mailto=logik&browser=ie6 --i mean, transmit the parameters, and procces the $\_POST parameters ( if(isset($\_POST[‘mailto’])) echo … )

if you want to display what the mail contained in the page you’re redirecting… just put almost the same code with echo(), not with mail()

> Know anything about launching pop-ups with php??

well, you can pop-up a window with javascript with the window.open() command

for further help, just let me know 🙂

[Next page](https://forum.kirupa.com/t/flash-mx-and-php/10599.md?page=2)
