Sending mail from flash with PHP

  • DrGonzo
  • Beginner
  • Beginner
  • DrGonzo
  • Posts: 36

Post 3+ Months Ago

Hello,
I have made a contact form that is supposed to send the detail on email via a PHP file. It works to some extent, however it only gives me the details of the last variable in the list?

This is my PHP script:

<?php

$to = "larry@tshirtsetc.co.uk";
$msg = "Name: $_POST[name]\n";
$msg = "Company Name: $_POST[company]\n";
$msg = "Email Address: $_POST[email]\n";
$msg = "Telephone Number: $_POST[telephone]\n";
$msg = "Address: $_POST[address]\n";
$msg = "Small qty: $_POST[s]\n";
$msg = "Medium qty: $_POST[m]\n";
$msg = "Large qty: $_POST[l]\n";
$msg = "XLarge qty: $_POST[x]\n";
$msg = "XXLarge qty: $_POST[xxl]\n";
$msg = "Comments: $_POST[message]\n";


mail($to, $subject, $msg, "From: My web site\nReply-To: $email\n");

?>

The only info I get is the last variable - 'message'?

Any one know what i've done wrong?

Thanks,

DrGonzo.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Tchuki
  • Mastermind
  • Mastermind
  • Tchuki
  • Posts: 1774
  • Loc: Edinburgh

Post 3+ Months Ago

http://www.kirupa.com/developer/actions ... _email.htm
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

hahahahaa that`s a "i`m tired and not paying attention" mistake ... :D
look again at your code. You always have: $msg = ....
you have to concat it, not to replace it all the time. So the correct code is this:
Code: [ Select ]
<?php

$to = "larry@tshirtsetc.co.uk";
$msg = "Name: $_POST[name]\n";
$msg .= "Company Name: $_POST[company]\n";
$msg .= "Email Address: $_POST[email]\n";
$msg .= "Telephone Number: $_POST[telephone]\n";
$msg .= "Address: $_POST[address]\n";
$msg .= "Small qty: $_POST[s]\n";
$msg .= "Medium qty: $_POST[m]\n";
$msg .= "Large qty: $_POST[l]\n";
$msg .= "XLarge qty: $_POST[x]\n";
$msg .= "XXLarge qty: $_POST[xxl]\n";
$msg .= "Comments: $_POST[message]\n";

mail($to, $subject, $msg, "From: My web site\nReply-To: $email\n");

?>
  1. <?php
  2. $to = "larry@tshirtsetc.co.uk";
  3. $msg = "Name: $_POST[name]\n";
  4. $msg .= "Company Name: $_POST[company]\n";
  5. $msg .= "Email Address: $_POST[email]\n";
  6. $msg .= "Telephone Number: $_POST[telephone]\n";
  7. $msg .= "Address: $_POST[address]\n";
  8. $msg .= "Small qty: $_POST[s]\n";
  9. $msg .= "Medium qty: $_POST[m]\n";
  10. $msg .= "Large qty: $_POST[l]\n";
  11. $msg .= "XLarge qty: $_POST[x]\n";
  12. $msg .= "XXLarge qty: $_POST[xxl]\n";
  13. $msg .= "Comments: $_POST[message]\n";
  14. mail($to, $subject, $msg, "From: My web site\nReply-To: $email\n");
  15. ?>

p.s.: notice the "." before the "=" ... that is concat.
  • DrGonzo
  • Beginner
  • Beginner
  • DrGonzo
  • Posts: 36

Post 3+ Months Ago

Nice one Ice - Your a star!

I shouldn't work so late.......

Thanks.

DrGonzo.
  • errorbaby
  • Newbie
  • Newbie
  • errorbaby
  • Posts: 14

Post 3+ Months Ago

Hi,
I have tried out the tutorial mentioned above http://www.kirupa.com/developer/actions ... _email.htm but I cant seem to get anything back in my mail inbox.

The flash movie works fine (after entering data, the thank you message appears) but that's the furthest I can go.

I have changed the php to what Icecold has coded above (with slight changes to customised to my variables). Can anyone guide me on what went wrong?

My php script is as below:

<?php
$to = "xxx@yahoo.com";
$subject = "My Flash site reply";

$msg = "Name: $_POST["name"]\n";
$msg .= "Email Address: $_POST[email]\n";
$msg .= "Comments: $_POST[message]\n";

mail($to, $subject, $msg, "From: My web site\nReply-To: $email\n");
?>

The text that I have highlighted in bold, can someone tell me what it is pointing to? Should I change it?
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

that's just the "sender" that will appear.
if you dont get anything in your inbox ... either check your bulk messages ... or make sure you have activated the SMTP on the server that you use. aah, and dont expect to send anything using the flash test movie or loading the published html in the browser ... you really need the apache server for this.
  • errorbaby
  • Newbie
  • Newbie
  • errorbaby
  • Posts: 14

Post 3+ Months Ago

I have checked the inbox and bulk folder... no returned message in there. As for the smtp, do you mean chmod? I have set chmod to 755 (hope it is right?) and I have tested the swf file on a test html instead of a published one.... any other solutions :?
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

what does SMTP got to do with chmod?
SMTP = simple mail transmission protocol ...
In windows is activated from IIS ... in linux, i dont know linux :P
maybe you need another mail server in order to send one, don't know.

and to test the file you need to test it like ... this:
http://localhost/tests/myflash.html
or
http://hostedsite.com/myflash.html
  • errorbaby
  • Newbie
  • Newbie
  • errorbaby
  • Posts: 14

Post 3+ Months Ago

I am using a free host. Think I can still use this method?
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

i dont know, ask or see if they provide SMTP support
  • medeea
  • Born
  • Born
  • medeea
  • Posts: 1

Post 3+ Months Ago

Hy,

I've tried all the variants proposed by you and i couldn't send and receive any email.I'm actually a beginner in Flash and i don't know what are the exactly steps to make it work.I don't know which server i need, and, lets say, if i work with asp, how am i supposed to upload the swf/html and asp to the server?I don't know what to do in these pleriminary steps.

Please help me.
Thank you very much
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

medeea,

Sounds like you need to start with the basics and gradually progress to where it seems you'd like to be.

All of the things you just mentioned are really basic things you have to know before you can go much further. If possible take some basic courses on web design at a local college or online training. I could answer your questions but I don't think you'd understand the answers. I'll give it a shot though.

If you're working with ASP you shouldn't be. Use ASP.NET instead. In either case you should be using a Windows server running IIS. Your files get uploaded to the wwwroot directory in Inetpub folder. If you are working on the server itself just save them there to that directory. If you are working on the server remotely you'll need an FTP client and FTP access to the webserver. To send email with ASP you essentially follow the same steps as above except instead of a php script you would most likely use a standard ASP script using CDONTS or JMAIL (assuming JMAIL is installed). Of course you need an SMTP server running on your Windows server that is capable of sending mail.
  • shana1729
  • Born
  • Born
  • shana1729
  • Posts: 1

Post 3+ Months Ago

I think that your server is not supporting PHP(you may need to install PHP with PEAR in that case). Or your server may not be having SMTP enabled. The code you have written will work for Windows based server. IF you have linux based server the \n at the end has to be replaced with \r\n.

And in order to upload files you need to contact your system admin people/ the poeple who manages your web domain. You can FTP the files into server and test it!

Cheers,
Nishana

http://nishanaa.blogspot.com/2008/11/se ... g-php.html

Post Information

  • Total Posts in this topic: 13 posts
  • Users browsing this forum: No registered users and 13 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.