$_GET not return any value in php - php

Hi I am facing a problem with respect to $_GET in PHP . I am trying to do payment gateway Integration with EBS. The problem is I am not able to read response I get from URL.
My code to read response is:
$RR=$_GET["DR"];
echo $RR;
$DR = preg_replace("/\s/","+",$_GET["DR"]);
When I try to check the value using echo command it returns null. Can some one please help me understand if I need to follow some other process. Also , this works well in WAMP Server I have which uses PHP 5.4.12 however this code is not working when I am hosting it to different server bought from a vendor. PHP version used there is 5.3.
The URL I have is
http://companyururl.com/response.php?DR=IXc9laP5EPzkG8rJUEkT9GPYZKb+340d1KINeq1DJAbrqc5GeRs3RVwRJ7YShbNZUyaxTmSW46lexsfKVHpZGaEckYB8kpxGvDoGUG9XULC1ZM6XhHu125hgs12+1Ql5jETUw9t8LKV32SFu+2e9n2eDeWfaVS23HN6kQFdC+0KFK8/QdCeEXY1DBNUMX2/1eUCJrLX16tG038+FnvqxqWy6U4nGM7dcwNPnq0PMioKTQs3yXTX3RaVhC83LSbeniKgkYcEBcpZsGMetiadcjQF9qYNNwzL0FgBuah7z+MgIaz1KEDx7/HJ3T8xdunrx8CeGq19oOSp5+lDqFGZZfz8Vb+tCJ4lVzfYoy+037m3jqFtkee4vHmZEkEl2Rl68PZ9shBoLH8iZaO4imURPT53+Kgm3nwFITwyztV1tk/NlG+Y9w3kKV7hlrem/c0SsqLAomL8WORidK0AXxwpitLLuXXWt5bLs14xjVTHfVjRrluSXAg5ylE5M7wt8XV6O1aniKoeapRkKOYyo2BArkIk+92SRWzA24Wb3r+fN5lpyb9aCwOWCi2Of2tikMc/XotK9X5lxix6x0Ec4YRCV2m5f/x7xRDktcKZeJuLOVyxn3Zdx5JzdAseuc/P2vzH8xDCJ6GVcvD+7eeyv1+ZqCnapQmyAWyaCZJ0cQG+YZfKkd30IE5UMRquym0KqrOvrCJZtV4F4T+n8wPq1U4V2j57hfnTp3WzF/l3rjNizCW68Akkmk9d17sVKkGg=
I am trying to read DR value in the form .Looking for a reply.

Check weather request contains data or not by using
var_dump($_REQUEST);
and then check using
var_dump($_GET);
var_dump($_POST);
if you are get null in get and data in post it means you have to check form method from get to post as post is default method for sending data. change it to get method. like this one:
<form action="" method="get">
....
</form>

Related

Passing POST parameters to PHP does not work

I am sending parameters to a PHP file as a POST request, direct from my browser like :
example.com/
with example.php?CID=1
But not getting the values in the PHP file.
I am sending parameters to a PHP file as a POST request, direct from my browser like
in the php file i am trying to read :
$cid = $_POST["CID"];
$cname = $_POST["CNAME"];
But the local variables are null after executing this.
I also tried doing this :
echo var_dump($_POST);
and it returns :
array(0)
i am hosting this on a paid hosting server, and the configuration allows upto 1000 parameters.
The way you have set this up you are using the get method
$cid = $_GET["CID"];
$cname = $_GET["CNAME"];
If you are wanting to use post then please read the PHP manual
https://www.php.net/manual/en/reserved.variables.post.php
first of all try this PHP "php://input" vs $_POST
php://input
it will solve your issues and let you process developement as workaround - it is very usefull when communicating with pure json not as jason passed into Post field.
next make a check configuration of your server - i had the same problem with nginx and solved it somehow but do not remember how ;)

How to pass data to Advanced REST client chrome extension

I have a simple php file which just echoes $_POST['email']. I want to access it through rest client extension.
New extension looks totally different. This answer uses old extension.
I just added a check isset($_POST['email']). It returns else part data.
How do I post data with new extension?
Here's how to setup the request:
Since you're accessing email in $_POST you'll need to choose the POST method
Set the Content-Type to application/x-www-form-urlencoded
Add the data form entries (in your case email=emailvalue)
Then your PHP script will be able to read the value of $_POST['email']

KnockoutJS - Sending a form containing the value of a javascript object results in a timeout

I have a problem that occurs when I try to send a form, if a particular field type is present, the page returns a time out.
I'm using KnockoutJS's mapping plugin to map an object coming from the server. I'm able to modify the object and I want to send it back.
To do so, I created a computed function that returns the result of ko.toJSON to which I pass this particular object. Then, this value is put in an hidden input to be sent back to the server:
<input type="hidden" name="a" data-bind="value: exportToJSON()" />
When I'm sending the form with this input field, I get an error 7:
Error 7 (net :: ERR_TIMED_OUT): The operation timed out.
Here's a JSFiddle representing my code
http://jsfiddle.net/etiennenoel/4EXSy/17/
I suspect that the problem is caused because the data in the field sent via POST is not escaped ?
Update 1
Someone suggested to use ko.mapping.toJSON. However, doing that results in an empty string, see it here: http://jsfiddle.net/etiennenoel/4EXSy/18/
Update 2
Now, results input is not empty, thanks to #abc123: http://jsfiddle.net/etiennenoel/4EXSy/19/.
However, I still get a timeout when sending the POST Data. You can see the POST data that is sent when I send my form in my code: http://pastebin.com/hNRm4zdZ
Update 3
I'm using symfony2 and I'm starting to think that the problem might be linked to something in symfony2 since when I copy and paste the form on a simple .html file, the data gets sent...
Update 4
I deleted Symfony2 dev.log, clicked on the button to send the form, got the time out error and unfortunately, the log is still empty.... Also, all the php and apache logs do not show anything...
Update 5
I finally decided to test my symfony website on another server and it works on this other server... Now this is getting weird, why isn't it working in my local server ? I'm using MAMP Pro as a local server
You are returning ko.mapping.toJSON(self.playersEvaluation) you cannot access a property of knockout without calling the function since it is actually a function.
To get it to return proper JSON please do the following:
function appViewModel() {
var self = this;
self.playersEvaluation = ko.observableArray();
self.exportToJSON = ko.computed(function() {
return ko.mapping.toJSON(self.playersEvaluation())
}, this);
}
JSFiddle: http://jsfiddle.net/abc123/WReza/1/
To use Console Easily: http://jsfiddle.net/abc123/WReza/1/embedded/result/
Luckily since you are using the ko.mapping plugin this will work because it does the following:
All properties of an object are converted into an observable. If an update would change the value, it will update the observable.
Arrays are converted into observable arrays. If an update would change the number of items, it will perform the appropriate add/remove actions. It will also try to keep the order the same as the original JavaScript array.
Taken from ko.mapping

Strange behaviour when trying to send data with ajax (jQuery)

I'm coding an website which must have same functionality as SO. My server use Litespeed, which increase the speed of runing php files.
When I'm trying to send php code in regular form, everything seems to be ok, data being sent to the action file without interpreting the code inside the variable. But when I'm trying to send the same data in comments textareas, with jQuery $.post method, I'm getting Forbidden 403 error. Data is blocked on the road by Litespeed server. I don't know why is happening this, why is $_POST data auto-evaluated when using ajax?
This situation doesn't appear everytime, but just in some cases, for example:
this is a new message which presents this php code: <?php mysql_query("SELECT * FROM my_table"); ?>
Note that if I remove <?php and ?> from my message, it is ok. I've already tried to use encodeURI() method but this don't change anything.
Is there any setting which must be applied in .htaccess for not auto-evaluate $_POST data?
or I should replace the open and close tags, before sending the comment?
Later edit
This is how I managed to resolve this right now, but I'm still waiting for a suggestion with .htaccess:
$but.prev('textarea').val().replace(/(<\?php)/gi,'-?php ').replace(/(<\?)/gi,'-? ').replace(/\?>/gi,' ?-');
and on the server side
str_replace(array('-?php','?-','-?'), array('`<?php','?>`','`<?'), $_POST['comment']);

$_FILES is not working in PUT and DELETE

I am writing API for my mobile app. I have a problem in PUT and DELETE. In post method , I can use $_FILES for uploading file. However, it return NULL value in PUT and DELETE method.
I just use simple code for testing
<?php
echo "FILE: ";
var_dump($_FILES["file"]["name"]);
?>
I am using POSTMAN chrome extension for testing the PUT and DELETE method.
Are You using Your form with enctype="multipart/form-data" attribute?
There is almost the same problem thread - check it: How to receive a file via HTTP PUT with PHP

Categories