SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems With PHP POST

    Hi there,

    I am running on a new cPanel server installation and I am having some problems with POST data.

    Here's my test POST script:

    Code php:
    	public function post_test()
    	{
    		if ($this->input->post('post_test'))
    		{
    			echo 'got post';
    		}
     
    		echo '<form action="" method="post">';
    		echo '<textarea name="live"></textarea>';
    		echo '<input type="hidden" name="post_test" value="1">';
    		echo '<input type="submit" name="submit" value="Submit">';
    		echo '</form>';
    	}

    The $_POST array is empty when I post this data in textarea[name=live]:

    Code:
    <b>Need Tickets?</b> site@mysite.com<br>
    <b>Booking Now!</b> booking@mysite.com<br><br>
    
    To be announced
    The $_POST array populates with data from the form when I post this data (it posts properly):

    Code:
    <b>Need Tickets?</b> site@mysite.com<br>
    <b>Booking Now!</b> booking@mysite.com<br><br>
    My question is, why does the entire $_POST array become empty when I post anything in textarea[name=live] beyond the <br><br>? So weird.

  2. #2
    SitePoint Mentor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,257
    Mentioned
    32 Post(s)
    Tagged
    5 Thread(s)
    Hi Panduola,

    Is there some more code that you haven't shown? How are you checking the value of 'live' once the form is submitted?

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Doing a var_dump($_POST); reveals array(0){}

  4. #4
    SitePoint Mentor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,257
    Mentioned
    32 Post(s)
    Tagged
    5 Thread(s)
    Are you using CodeIgniter? Could you try var_dump($this->input->post()); and let me know what you get?

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes. I have done this as well. The response is bool(false).

  6. #6
    SitePoint Mentor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,257
    Mentioned
    32 Post(s)
    Tagged
    5 Thread(s)
    If this site is online somewhere, could you share a link to it? I'd like to see the page and check what the browser is actually submitting etc.

  7. #7
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes: http://incolorband.com/welcome/post_test

    Try submitting the two different code samples above.

  8. #8
    SitePoint Mentor bronze trophy
    fretburner's Avatar
    Join Date
    Apr 2013
    Location
    Brazil
    Posts
    1,257
    Mentioned
    32 Post(s)
    Tagged
    5 Thread(s)
    Right, I've tried both variations of the text you mention in your first post and I get the same results you do. Interestingly, when submitting the full text (the one that doesn't work) the Chrome console reports that the server responds with a 403 error.

    I did a quick search and it's possible that it's related to a server module called mod_security: http://ellislab.com/forums/viewthread/187785/#887877

    The suggested fix is to add the following lines to your .htaccess file:
    Code:
    <IfModule mod_security.c>
    SecFilterEngine Off
    SecFilterScanPOST Off
    </IfModule>
    If that works for you, I'd recommend checking with your hosting company if it's safe to leave it set like that.

  9. #9
    SitePoint Enthusiast
    Join Date
    Mar 2010
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Solved! Great. This did the trick. Many thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •