PHP echo command not working when using $_POST?

Discussion in 'PHP' started by PrinceIsrael, Jan 17, 2009.

  1. #1
    Hi,

    I am passing two values from Flash to PHP. PHP script sends the two values to a mail id. This works perfect. But when I am trying to echo those two values it is not working at all.

    Here is the script

    <?php
    
    	if ($_POST)
    	{
    		$mailTo = "demo@agp.com";
    		$mailSubject = "User Statistics [Mp3 Gallery]";
    		
    		$Header = "MIME-Version: 1.0\r\n";
    		$Header .= "Content-type: text/html; charset=iso-8859-1\r\n";
    		
    		$output = "<BR>";
    		$output .= "Action    : " . $_POST['action'] . "<BR><BR>";
    		$output .= "Song   : " . $_POST['song'] . "<BR><BR>";
    		
    		
    		$output = nl2br($output);
    		
    		if (mail($mailTo, $mailSubject, stripslashes($output), $Header))
    		{
    			echo("&result=1&");
    		}
    		else
    		{
    			echo("&result=2&");
    		}
    	}
    	else
    	{
    		echo("This script runs only in Flash!!!");
    		
    	}
    	
    ?>
    
    Action :  <?php echo $_POST["action"]; ?><br />
    Song : <?php echo $_POST["song"]; ?>
    
    
    PHP:

    All working perfect except the last two lines where I am trying to echo the values.

    Please help me guys, I know nothing in PHP, Im a Flash developer. lol :)
     
    PrinceIsrael, Jan 17, 2009 IP
  2. tamen

    tamen Peon

    Messages:
    182
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    What does it say above the last two lines on the resulting page?
     
    tamen, Jan 17, 2009 IP
  3. manijifera

    manijifera Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Action :  <?php echo $_POST["action"]; ?><br />
    Song : <?php echo $_POST["song"]; ?>
    PHP:
    TRy

    Action :  <?php echo $_REQUEST["action"]; ?><br />
    Song : <?php echo $_REQUEST["song"]; ?>
    PHP:
    or

    Action :  <?php echo $_GET["action"]; ?><br />
    Song : <?php echo $_GET["song"]; ?>
    PHP:
     
    manijifera, Jan 17, 2009 IP
  4. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #4
    Where is the values of $_POST["action"] and $_POST["song"] come from?

    Maybe you can post here the html form part here and let us have a look
     
    ads2help, Jan 17, 2009 IP
  5. PapaCarlo

    PapaCarlo Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    <?php
    $action = $_POST['action'];
    echo "Action : ", $action;
    ?>
    PHP:
     
    PapaCarlo, Jan 17, 2009 IP
  6. PrinceIsrael

    PrinceIsrael Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    It echos nothing. :eek:
     
    PrinceIsrael, Jan 19, 2009 IP
  7. PrinceIsrael

    PrinceIsrael Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7

    So I need to change the method to REQUEST or GET in the other page as well right?
     
    PrinceIsrael, Jan 19, 2009 IP
  8. PrinceIsrael

    PrinceIsrael Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hi, It is from Flash Action Script. It is Action Script 2. Here it is :

    function sendValues() {
    			email_lv = new LoadVars();
    			email_lv.action = action;
    			email_lv.song = description_txt;
    			trace(action);
    			trace(description_txt);
    			email_lv.onLoad = function(ok) {
    				if (ok) {
    					trace("Email Sent!!!");
    					trace(unescape(this));
    				} else {
    					trace("Problem sending an Email!!!");
    				}
    			};
    			email_lv.sendAndLoad("contents/userstats.php", email_lv, "POST");
    		}
    		sendValues();
    
    
    Code (markup):
     
    PrinceIsrael, Jan 19, 2009 IP
  9. PrinceIsrael

    PrinceIsrael Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Still it is the same buddy :eek:
     
    PrinceIsrael, Jan 19, 2009 IP
  10. digitals.future

    digitals.future Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    if you want to do an echo to a $_POST var

    
    <?php
    if(isset($_POST['submit']))
    {
    
       $nume = $_POST['nume'];   
    
    }
    
    echo "$nume";
    // This Should Work 
    ?>
    
    
    
    
    Code (markup):
     
    digitals.future, Apr 5, 2009 IP
  11. parthiphp

    parthiphp Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    You put the last two line inside the

    if ($_POST)
    {
    condition
    }
     
    parthiphp, Apr 5, 2009 IP
  12. nirajkum

    nirajkum Active Member

    Messages:
    815
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #12
    may be $num doest have any values due to the if statement
     
    nirajkum, Apr 6, 2009 IP
  13. buldozerceto

    buldozerceto Active Member

    Messages:
    1,137
    Likes Received:
    43
    Best Answers:
    0
    Trophy Points:
    88
    #13
    have you tried with print_r($_POST) ?
     
    buldozerceto, Apr 6, 2009 IP
  14. eamiro

    eamiro Well-Known Member

    Messages:
    274
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    123
    #14
    Maybe the problem comes from your flash script, try to check it!
     
    eamiro, Apr 6, 2009 IP
  15. ghprod

    ghprod Active Member

    Messages:
    1,010
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #15
    please define first where that var $_POST come from ... then include in if ...

    not outside :)

    reagrds
     
    ghprod, Apr 12, 2009 IP