Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-29-2011, 01:22 AM   PM User | #1
Ugogrl
New Coder

 
Join Date: Feb 2011
Location: EVERYWHERE ... YOU JUST NEVER KNOW WHEN I WILL POP UP WHERE
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Ugogrl can only hope to improve
Question Flash php - want to add something

Hi all, everyone was so amazing the last time I was stuck ... thanks again for that help

I found this really amazing Flash Form Mail / PHP that I want to use ...

but it is missing the part

to capture the below info which is important to me and was in my old CGI script


[CODE] my $REMOTE_ADDR = 1;
my $HTTP_USER_AGENT = 1;
my $DATE = 1;
[ICODE]

(can the above somehow be added to this .... and do I need to post the flash file also?)


PHP Code:
<?
if(!empty($HTTP_POST_VARS['sender_mail']) || !empty($HTTP_POST_VARS['sender_message']) || !empty($HTTP_POST_VARS['sender_subject']) || !empty($HTTP_POST_VARS['sender_name']))
{
    
$to "@.com";
    
$subject stripslashes($HTTP_POST_VARS['sender_subject']);
    
$body stripslashes($HTTP_POST_VARS['sender_message']);
    
$body .= "\n\n---------------------------\n";
    
$body .= "Mail sent by: " $HTTP_POST_VARS['sender_name'] . " <" $HTTP_POST_VARS['sender_mail']  . ">\n";
    
$header "From: " $HTTP_POST_VARS['sender_name'] . " <" $HTTP_POST_VARS['sender_mail'] . ">\n";
    
$header .= "Reply-To: " $HTTP_POST_VARS['sender_name'] . " <" $HTTP_POST_VARS['sender_mail'] . ">\n";
    
$header .= "X-Mailer: PHP/" phpversion() . "\n";
    
$header .= "X-Priority: 1";
    if(@
mail($to$subject$body$header))
    {
        echo 
"output=sent";
    } else {
        echo 
"output=error";
    }
} else {
    echo 
"output=error";
}
?>


Thanks again in advance ... to whoever is another angel
Ugogrl is offline   Reply With Quote
Old 03-29-2011, 03:38 AM   PM User | #2
Labrar
New Coder

 
Join Date: Jun 2008
Posts: 61
Thanks: 0
Thanked 12 Times in 12 Posts
Labrar is an unknown quantity at this point
Just modify your Body Var
PHP Code:
 $body stripslashes($HTTP_POST_VARS['sender_message']).'\n\nIP:'.$_SERVER[''HTTP_USER_AGENT''].'\n\nClient:'.'\n\nDate:'.date('d.m.Y H:i:s'); 
Labrar is offline   Reply With Quote
Users who have thanked Labrar for this post:
Ugogrl (03-30-2011)
Old 03-29-2011, 04:09 AM   PM User | #3
Ugogrl
New Coder

 
Join Date: Feb 2011
Location: EVERYWHERE ... YOU JUST NEVER KNOW WHEN I WILL POP UP WHERE
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Ugogrl can only hope to improve
Error message

Okay, I put it where you said ... but got this error message?

[CODE]Parse error: syntax error, unexpected T_STRING, expecting ']' in /mnt/r0148/d11/s37/b02bff1d/www/.............com/contact2.php on line 6
[ICODE]

any solutions???



Quote:
Originally Posted by Labrar View Post
Just modify your Body Var
PHP Code:
 $body stripslashes($HTTP_POST_VARS['sender_message']).'\n\nIP:'.$_SERVER[''HTTP_USER_AGENT''].'\n\nClient:'.'\n\nDate:'.date('d.m.Y H:i:s'); 
Ugogrl is offline   Reply With Quote
Old 03-29-2011, 02:16 PM   PM User | #4
Labrar
New Coder

 
Join Date: Jun 2008
Posts: 61
Thanks: 0
Thanked 12 Times in 12 Posts
Labrar is an unknown quantity at this point
Sorry. It was late.
PHP Code:
 $body stripslashes($HTTP_POST_VARS['sender_message']).'\n\nIP:'.$_SERVER['HTTP_USER_AGENT'].'\n\nClient:\n\nDate:'.date('d.m.Y H:i:s'); 
Labrar is offline   Reply With Quote
Users who have thanked Labrar for this post:
Ugogrl (03-30-2011)
Old 03-29-2011, 04:20 PM   PM User | #5
Ugogrl
New Coder

 
Join Date: Feb 2011
Location: EVERYWHERE ... YOU JUST NEVER KNOW WHEN I WILL POP UP WHERE
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Ugogrl can only hope to improve
Smile Great! That works ... except

Quote:
Originally Posted by Labrar View Post
Sorry. It was late.
PHP Code:
 $body stripslashes($HTTP_POST_VARS['sender_message']).'\n\nIP:'.$_SERVER['HTTP_USER_AGENT'].'\n\nClient:\n\nDate:'.date('d.m.Y H:i:s'); 
Thanks You!

It all works great but is not picking up

the IP / Host ? number
Ugogrl is offline   Reply With Quote
Old 03-29-2011, 04:37 PM   PM User | #6
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
This code is ancient.
There is no guarantee that the registered long arrays have been enabled in PHP. $HTTP_*_VARS are deprecated, and will disappear; use the superglobal equivalents of $_* for each of the $HTTP_*_VARS (except files which is just the $_FILES superglobal, not the same pattern as the long array is $HTTP_POST_FILES).

Useragent does not provide the ip address, and the simplest variable that may contain it is the 'REMOTE_ADDR' in the $_SERVER superglobal, not the HTTP_USER_AGENT. Anything user provided is not guaranteed to ever exist, and the $_SERVER superglobal has few guaranteed offsets.

I'd say go find yourself a new mailer script, look particularly for a new version which includes preventative measures for mail injections. All data provided by a client is tainted and should never be trusted.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Old 03-30-2011, 12:50 AM   PM User | #7
Ugogrl
New Coder

 
Join Date: Feb 2011
Location: EVERYWHERE ... YOU JUST NEVER KNOW WHEN I WILL POP UP WHERE
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Ugogrl can only hope to improve
Question even more lost than before

Quote:
Originally Posted by Fou-Lu View Post
This code is ancient.
There is no guarantee that the registered long arrays have been enabled in PHP. $HTTP_*_VARS are deprecated, and will disappear; use the superglobal equivalents of $_* for each of the $HTTP_*_VARS (except files which is just the $_FILES superglobal, not the same pattern as the long array is $HTTP_POST_FILES).

Useragent does not provide the ip address, and the simplest variable that may contain it is the 'REMOTE_ADDR' in the $_SERVER superglobal, not the HTTP_USER_AGENT. Anything user provided is not guaranteed to ever exist, and the $_SERVER superglobal has few guaranteed offsets.

I'd say go find yourself a new mailer script, look particularly for a new version which includes preventative measures for mail injections. All data provided by a client is tainted and should never be trusted.



Sorry, thank moderator ... but I have no idea what you said at all ... but thanks it sounds good just the same
Ugogrl is offline   Reply With Quote
Old 03-30-2011, 03:46 AM   PM User | #8
Labrar
New Coder

 
Join Date: Jun 2008
Posts: 61
Thanks: 0
Thanked 12 Times in 12 Posts
Labrar is an unknown quantity at this point
That means that this code is to old. Nobody uses such scripts since PHP4.
But indead this is a popular Codesnippet out of google.

But i guess youre not really in PHP aint ya?
Leave it like that. Its old, but it works.
So dont you care about it.

But in the other hand this is not the way of secure coding.
Labrar is offline   Reply With Quote
Users who have thanked Labrar for this post:
Ugogrl (03-30-2011)
Old 03-30-2011, 11:54 PM   PM User | #9
Ugogrl
New Coder

 
Join Date: Feb 2011
Location: EVERYWHERE ... YOU JUST NEVER KNOW WHEN I WILL POP UP WHERE
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Ugogrl can only hope to improve
Thumbs up Thank you !!!!!!!

Quote:
Originally Posted by Labrar View Post
That means that this code is to old. Nobody uses such scripts since PHP4.
But indead this is a popular Codesnippet out of google.

But i guess youre not really in PHP aint ya?
Leave it like that. Its old, but it works.
So dont you care about it.

But in the other hand this is not the way of secure coding.
Really I think I am getting all formats ... just not the lingo? No techie talk for me ... if you get my drift ... NEWBIE

Thank you for helping me ... like the Newbie I am ((hugs)) ... I do appreciate when someone takes that into consideration ... all I have searched for is the perfect form mail ... I guess without having to pay for it ... I can only expect second best ... right??? I mentioned one time in another forum I would pay for help and I got booted ... so I won't do that ever again ... I guess in the long run ... I can't have the information from my old CGI script which I did so love ... and have the same information gathering in a flash / php or whatever format ... ??? Cause I really like the FLASH FORMAT ???
But, really still only want .. the best secure method ... Whatever that is???
You were the only one to really help me and answer me ... I thank you ... be blessed by the Universe ... for your kindness!!!!!!!!

I wish more were like you!!!!!!!!!
Ugogrl is offline   Reply With Quote
Old 03-31-2011, 12:08 AM   PM User | #10
Ugogrl
New Coder

 
Join Date: Feb 2011
Location: EVERYWHERE ... YOU JUST NEVER KNOW WHEN I WILL POP UP WHERE
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Ugogrl can only hope to improve
Help ... I need some help?

Quote:
Originally Posted by Fou-Lu View Post
This code is ancient.
There is no guarantee that the registered long arrays have been enabled in PHP. $HTTP_*_VARS are deprecated, and will disappear; use the superglobal equivalents of $_* for each of the $HTTP_*_VARS (except files which is just the $_FILES superglobal, not the same pattern as the long array is $HTTP_POST_FILES).

Useragent does not provide the ip address, and the simplest variable that may contain it is the 'REMOTE_ADDR' in the $_SERVER superglobal, not the HTTP_USER_AGENT. Anything user provided is not guaranteed to ever exist, and the $_SERVER superglobal has few guaranteed offsets.

I'd say go find yourself a new mailer script, look particularly for a new version which includes preventative measures for mail injections. All data provided by a client is tainted and should never be trusted.

You totally had me sooooo lost

Please, try to understand that most of us who ask for help ... it is because we do not understand what you do ... why forums were created ... was it not?

You have so much potential ... to help others ... just remember the little guy was also once you too ... before you learnt what you learnt ... you asked a lot of questions also from those who taught you ... I seriously don't want to learn your profession ... I just want to run a cool little site ???

With as much protection as I can use ... sorry you didn't understand ... I WAS ASKING FOR HELP???

I did do the Google thing ... for what I wanted ... and it came up ... if it doesn't work ... then tell, show or lead where to go ... don't just leave me hanging ... cause I don't get the lingo

Have a wonderful ... exploration of thoses who need your help ...
I did you give you (Thank you points ... just because)



Definition of HELP

transitive verb

1: to give assistance or support to <help a child with homework>


Last edited by Ugogrl; 03-31-2011 at 12:12 AM..
Ugogrl is offline   Reply With Quote
Old 03-31-2011, 12:15 AM   PM User | #11
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,521
Thanks: 45
Thanked 440 Times in 429 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Basically $HTTP_POST_VARS and $HTTP_GET_VARS are no longer in use by default in php.

PHP now uses this: $_POST and $_GET.

$_GET is what is sent in the address - EG www.domain.com/index.php?var1=this&var2=that

$_POST is data sent in the headers - from a form.

In your case you need to use $_POST['sender_message'] instead of $HTTP_POST_VARS['sender_message'] because the $HTTP_POST_VARS is old, no longer supported and on most servers disabled.

Similarly to get the users IP you now need to use $_SERVER['REMOTE_ADDR'] instead of the http user agent you were using as that is also deprecated (old).

Hope that makes it easier for you. Any problems please let us know.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 03-31-2011, 04:40 AM   PM User | #12
Labrar
New Coder

 
Join Date: Jun 2008
Posts: 61
Thanks: 0
Thanked 12 Times in 12 Posts
Labrar is an unknown quantity at this point
And it is also easy to understand.
Short example

Actionscript:
PHP Code:
mylvar=new LoadVars();
mylvar.onLoad=function(connected){
if(
connected){
trace(this.serveranswer);
}else{
trace('Cannot connect to the server. Is your Flasmovie in the same folder than your phpfile??\nOtherwise please use an absolute path to it'); }
}
mylvar.mytesttext='Hello im right here';
mylvar.sendAndLoad('myphpfile.php',mylvar,"POST"); 
And the php source (save at as myphpfile.php on your server)

PHP Code:
<?php
echo "&serveranswer=Your Flashvar has the value: ".$_POST['mytesttext'];
?>
Just try it.

Explanation:
sendAndLoad can be used for both directions. Sending variables to the server, and getting variables from the server. So you can work with them also in your Flashmovie and in your Basescript on the server.

Going to bed now. Im drunken abit

Party all the time at Key west

Last edited by Labrar; 03-31-2011 at 04:50 AM..
Labrar is offline   Reply With Quote
Users who have thanked Labrar for this post:
Ugogrl (03-31-2011)
Old 03-31-2011, 09:46 PM   PM User | #13
Ugogrl
New Coder

 
Join Date: Feb 2011
Location: EVERYWHERE ... YOU JUST NEVER KNOW WHEN I WILL POP UP WHERE
Posts: 27
Thanks: 8
Thanked 0 Times in 0 Posts
Ugogrl can only hope to improve
Smile Sorry ???

Quote:
Originally Posted by Labrar View Post
And it is also easy to understand.
Short example

Actionscript:
PHP Code:
mylvar=new LoadVars();
mylvar.onLoad=function(connected){
if(
connected){
trace(this.serveranswer);
}else{
trace('Cannot connect to the server. Is your Flasmovie in the same folder than your phpfile??\nOtherwise please use an absolute path to it'); }
}
mylvar.mytesttext='Hello im right here';
mylvar.sendAndLoad('myphpfile.php',mylvar,"POST"); 
And the php source (save at as myphpfile.php on your server)

PHP Code:
<?php
echo "&serveranswer=Your Flashvar has the value: ".$_POST['mytesttext'];
?>
Just try it.

Explanation:
sendAndLoad can be used for both directions. Sending variables to the server, and getting variables from the server. So you can work with them also in your Flashmovie and in your Basescript on the server.

Going to bed now. Im drunken abit

Party all the time at Key west
lol ... well enjoy the party

I looked at this and thought maybe if I had a drink I might understand it ... I don't understand coding or where to put any of the things you wrote ... I wish I did ... thanks
Ugogrl is offline   Reply With Quote
Old 03-31-2011, 10:13 PM   PM User | #14
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,521
Thanks: 45
Thanked 440 Times in 429 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Ok, here you are:

PHP Code:
<?
if(isset($_POST['sender_mail']) || isset($_POST['sender_message']) || isset($_POST['sender_subject']) || isset($_POST['sender_name']))
   {
   
$to "@.com";
   
$subject stripslashes($_POST['sender_subject']);
   
$body stripslashes($_POST['sender_message']);
   
$body .= "\n\n---------------------------\n";
   
$body .= "Mail sent by: " $_POST['sender_name'] . " <" $_POST['sender_mail']  . ">\n";
   
$body .= "Senders IP: $_SERVER[REMOTE_ADDR]\n";
   
$body .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\n";
   
$header "From: " $_POST['sender_name'] . " <" $_POST['sender_mail'] . ">\n";
   
$header .= "Reply-To: " $_POST['sender_name'] . " <" $_POST['sender_mail'] . ">\n";
   
$header .= "X-Mailer: PHP/" phpversion() . "\n";
   
$header .= "X-Priority: 1";

   if(@
mail($to$subject$body$header))
      {
      echo 
"output=sent";
      }
   else
      {
      echo 
"output=error";
      }
   }
else
   {
   echo 
"output=error";
   }
?>
As many of us said, it wasn't hard work - I just changed $HTTP_POST_VARS to $_POST. I've no idea why you couldn't do that though as its been clearly explained many times.

I've also put in your requested IP address and user agent too.

Usage: Put your email address in where you see @.com and upload.
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 04-01-2011, 02:26 AM   PM User | #15
Labrar
New Coder

 
Join Date: Jun 2008
Posts: 61
Thanks: 0
Thanked 12 Times in 12 Posts
Labrar is an unknown quantity at this point
Thats not pretty hard to understand.
Just copy the actionscriptcode and paste it to your first frame in root.
Save the phpcode as a phpfile to your server.
Just modify the path in your actionscript that it matches the path to your php file on server and test it
Labrar is offline   Reply With Quote
Users who have thanked Labrar for this post:
Ugogrl (04-01-2011)
Reply

Bookmarks

Tags
flash, form mail, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:16 AM.


Advertisement
Log in to turn off these ads.