logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Coding & Scripting Corner View previous topic :: View next topic
Reply to topic   Topic: Weird error - Form posted value that contains "CD/"
Author
Bandai



Joined: 04 Jul 2012
Posts: 1

PostPosted: Wed 04 Jul '12 21:17    Post subject: Weird error - Form posted value that contains "CD/" Reply with quote

I'm getting this weird error when I try to send a certain string via POST to a PHP script hosted online.

This is the string I'm trying to send:

Code:
<b>character name cd</b>



The string here that is causing the problem is the two letter "CD". Even if I sent it like this I'm still getting the "Not Acceptable" error.

Code:
<b>CD</b>



or even this:

Code:
CD/



But if I send it like this (any character after CD except space) it goes thru:

Code:
<b>CDa</b>



What could be causing this error? My google-fu wasn't enough for this.


I'm testing this via simple HTML form and posting it to the PHP file that would output the value, here's the HTML code for the form:

Code:
<form action="http://linkhere.com/accept.php" method="POST" name="acceptme" enctype="multipart/form-data" accept-charset="UTF-8" >
    <p>Test:</p>
    <textarea id="testvalue" name="testvalue" rows="10" cols="50"></textarea><br />
    <INPUT type="submit" value="Submit" id="submit1" name="submit1">   
</form>


The PHP side has a simple script that accepts the posted value then display it:

Code:
<?php

$str = file_get_contents("php://input");

echo $str;

?>



Other info that might help find out the main cause of the problem:
* Shared hosting
* mod_security is disabled
* Nothing on the Apache error_log file
* Apache/2.2.21

Any idea?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Fri 06 Jul '12 18:15    Post subject: Reply with quote

The issue is that you use php://input. That is only to use form the command line. In your case use $_POST['testvalue'] Don't forget to escape the content of $_POST['testvalue'] with mysql_espace_string Wink
Back to top


Reply to topic   Topic: Weird error - Form posted value that contains "CD/" View previous topic :: View next topic
Post new topic   Forum Index -> Coding & Scripting Corner