Javascript is required error message on Post method

Hi guys. I'm trying to perform a post method action in my php and the site that I post to returns "This site require javascript to be enabled". Now the problem is that this is a backend php script that is sending this post method. The site is http://mlungisi.0fees.us

How can I solve this?
LVL 2
Mlungisi NdlelaFounder of MCSIDevelopers also a software developerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris StanyonWebDevCommented:
You probably can't solve it. If the URL that you're posting to need Javascript to be enabled, then you will probably only be able to post to it inside your browser, and not from Server-Side code. This may be a design decision by the author, or just a side-effect of their design choices.
0
Julian HansenCommented:
What are you posting to where?
0
Mlungisi NdlelaFounder of MCSIDevelopers also a software developerAuthor Commented:
@Chris that so sad then. @Juliam I'm posting just strings to a particular file ("test.php") and the string is something like "http://mlungisi.0fees.us/test.php?a=l&u=test&p=12345"

I saw that I can set the cookies on android post method but I don't want to touch this as it is working properly. I post from my Android app to a first server where I'm trying to forward the received data to another server so the first server doesn't have this problem and I can received data correctly with no problem but now the second server where which is the final end of the data has this.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Chris StanyonWebDevCommented:
Yeah - if test.php has checks in it to validate JS is enabled, then you're probably going to struggle. It's probably not written to accept non-browers (cURL) requests to it.
0
Mlungisi NdlelaFounder of MCSIDevelopers also a software developerAuthor Commented:
@Chris.

Note that this file I'm the one created it, the only thing that it does is simply return what ever data you posted to it. If I was to sort this on the server how should I go about?
0
Julian HansenCommented:
That link is only returning an empty Array()

Where are you trying to call this from JavaScript (Client) code or PHP (Server) Code

Can you explain the use case.

Client: AJAX
PHP: cUrl

Can you show us the code you are using to call as well as the source for test.php
0
Chris StanyonWebDevCommented:
OK. I don't think it's necessarily a problem with your test.php script. It looks like it's more to do with your server setup.

If I try a non-browser POST to test.php I get the Javascript Error. If I try a non-browser POST to test5.php, test5.php, anything.php ... I get exactly the same error. Those files don't exist so I shouldn't be getting that error - I would expect a 404. You may need to speak with your hosting provider about this, because it looks like your pages are being passed-thru something else.
0
Chris StanyonWebDevCommented:
One other thing of note. You say you're trying to POST data to your test.php script and then give the following as an example:

http://mlungisi.0fees.us/test.php?a=l&u=test&p=12345

That's a GET request, not a POST request. If you need your script to handle the data from that link, you will need to use $_GET instead.
1
Mlungisi NdlelaFounder of MCSIDevelopers also a software developerAuthor Commented:
I'm not basically posting it that way I'm using the cURL to post and for testing also I used this to test and I get
<html>
  <body>
    <script type="text/javascript" src="/aes.js" ></script>
    <script>function toNumbers(d){var e=[];d.replace(/(..)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0].constructor==Array?arguments[0]:arguments,e="",f=0;f
      <d.length;f++)e+=(16>d[f]?"0":"")+d[f].toString(16);return e.toLowerCase()}var a=toNumbers("f655ba9d09a112d4968c63579db590b4"),b=toNumbers("98344c2eee86c3994890592585b49f80"),c=toNumbers("4f08f585841b9b2444e0c9707cd16526");document.cookie="__test="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/"; location.href="https://mlungisi.0fees.us/?pass=123456&user=5210&i=1";
      </script>
      <noscript>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support</noscript>
    </body>
  </html>

Open in new window

0
Mlungisi NdlelaFounder of MCSIDevelopers also a software developerAuthor Commented:
This is how I post from the first server to the second server.
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
  $data = $_GET;//json_decode(file_get_contents("php://input"), true);
$url = 'http://mlungisi.0fees.us/test.php';
$myvars = $data;

$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);

$response = curl_exec( $ch );
echo $response;
}else{
    echo "Couldn't decode this data.";
}

?>

Open in new window

Here is my test.php code
<?php
print_r($_POST);
?>

Open in new window

0
Chris StanyonWebDevCommented:
Yeah - that's what my previous post alluded to. If you use Hurl.it to test, no matter what URL you put in the Destination (test.php, anything.php, something.php) you will get exactly the same result, which is why I'm suggesting that it's not a problem with your script but with the server. The POST doesn't seem to be reaching your test.php page at all when called from outside of the browser.

Have a chat with your hosting provider's tech support.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chris StanyonWebDevCommented:
A little confused by your code now - you're basically saying "If this is a POST request, then get the variables from the GET request !!" That doesn't really make any sense
0
Mlungisi NdlelaFounder of MCSIDevelopers also a software developerAuthor Commented:
@Chris.

Well trust me that the only way I was able to receive the data that is sent by my Android app, I tried listening on the POST but there was nothing returned only this way was working and even now its the only way working for me.
0
Julian HansenCommented:
Let's start from the beginning.

You gave us this http://mlungisi.0fees.us
This gives us a directory listing.
You then gave us this
http://mlungisi.0fees.us/test.php?a=l&u=test&p=12345

Open in new window

Which is supposed to be pointing to this
<?php
print_r($_POST);
?>

Open in new window

If you execute the link it appears to work - returns an empty array because we are sending GET parameters to a script expecting post.
Running a test form
<form method="post" action="http://mlungisi.0fees.us/test.php">
  <input type="text" name="a" value="l" />
  <input type="text" name="u" value="test" />
  <input type="text" name="p" value="12345" />
  <input type="submit">
</form>

Open in new window

Works and returns the $_POST data array
I then tried to post the above form to this script
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
  $data = $_POST;
  // YOUR SCRIPT
  $url = 'http://mlungisi.0fees.us/test.php';

  // MY SCRIPT
  //$url = 'http://mrcp9/ee/t3112a.php';
  $ch = curl_init( $url );
  
  curl_setopt( $ch, CURLOPT_POST, 1);
  curl_setopt( $ch, CURLOPT_POSTFIELDS, $data);
  curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt( $ch, CURLOPT_HEADER, 0);
  curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);

  $response = curl_exec( $ch );
  if (!$response) {
	echo 'Curl error: ' . curl_error($ch);
  }
  else {
    echo "RESPONSE RELAYED: {$response}";
  }
}else{
   echo "Couldn't decode this data.";
}

Open in new window


I made some changes
a) Used $_POST
b) The $data = $_POST; $myvars = $data was a waste of CPU cycles - so simplified on that

My script is the same as yours just does a print_r($_POST);

When I set the above to point to my script - it works. Your script it does not - so as Chris pointed out - something on your server is blocking this.
1
Mlungisi NdlelaFounder of MCSIDevelopers also a software developerAuthor Commented:
Well I've opened a ticket with the hosting and they said this is because of the protection they have which is robot block and they said I should only see this once but I see it every time I fire a method to this server.

So Isn't there a way I could bypass this robot check, in wget tool there is an option to bypass this robot check, I'm not sure if its the same robot or something else.
0
Chris StanyonWebDevCommented:
For bypassing this 'robot check' you will want to speak to your host. You may even want to ask them to remove it. Ask them how you can host your own API endpoints, because to do that, you would need the robot check removing!
0
Mlungisi NdlelaFounder of MCSIDevelopers also a software developerAuthor Commented:
Thanks everyone, I've decided to change the second server to another that doesn't have this problem.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.