0

Explanation

  • I have a plain HTML form with a few fields
  • I post it to my controller function
  • In the function I var_dump the POST data

    public function actionReceive()
    {
        echo "<pre>";
        var_dump($_POST);
        echo "</pre>";
        exit();
    }
    
  • On screen php shows the POST data is empty

  • In Firebug I can see the POST data

enter image description here

enter image description here

Question

Why is the POST data not displayed in the var_dump?

When I post it directly to a view file in site/page the POST is displayed with var_dump.

Larry Schiefer
  • 15,687
  • 2
  • 27
  • 33
Bob van Ham
  • 125
  • 5
  • 4
    The browser POSTS the data normally but receives a 301 redirect code from the server (why? we don't know) and visits the redirect URL with a GET request -- all POST data are lost. This is standard and expected behavior. Find out why you are sending a 301. – Jon Aug 22 '14 at 14:25
  • may be ur page is redirectign to error url.... or you do not have access to this actiom... may be you are not pasiing some variable or something... check accessControll in controller... – Jaimin MosLake Aug 23 '14 at 06:11

1 Answers1

0

why are you using var_dump($_POST) ??

If you want to pass data from one page to another in PHP just create 2 files. Let's sets first file name as send.html, and another one as receive.php.

Now put these codes into send.html file:

<form method="post" action="catching-var.php"> 
   1. <input type="text" name="name1"/><br/>
   2. <input type="text" name="name2"/><br/>
   3. <input type="text" name="name3"/><br/>
   4. <input type="text" name="name4"/><br/>

   <input type="submit" name="submit"/>
</form>

Also put these lines into receive.php file:

<?php    
   $name0 = $_POST['name0'];
   $name1 = $_POST['name1']; 
   $name2 = $_POST['name2']; 
   $name3 = $_POST['name3']; 
   $name4 = $_POST['name4'];

   echo $name0.'<br/><br/>'; 
   echo $name1.'<br/><br/>'; 
   echo $name2.'<br/><br/>'; 
   echo $name3.'<br/><br/>'; 
   echo $name3.'<br/><br/>';   
?>

Put some values into the HTML textbox fields and click the Submit button.

EDIT: If you do this in Yii Framework all of these operations and codes are same. But you must paste the PHP codes in action. That's all.

Please tell me; in which step you have problem?

Thanks. Best regards.

Mirjalal
  • 57
  • 1
  • 9