how to check the response header after sending the modified request - php

I was thinking if their is any way i can check the response header or the page is rendered differently after i have modified the request header or get parameter.
Like:
Original:www.abc.com/index.php?a=2
mODIFIED:www.abc.com/index.php?a=2polo
Now when i have appended the polo string after 2 i should see page rendered differently or it should rendered normally. But how can i check that it was rendered normally or not.
Any way i can compare normal response and the modified "request " response?
Elaboration of my problem.
I have an example.
suppose this is the original url:http://www.lnctgroup.in/institute.php?institute=4
Now this is the modified one on get parameter:http://www.lnctgroup.in/institute.php?institute=4polo
You can see the page rendered normally in original case but while appending "polo" string it shown error as mysql error may be but the page rendered differently.I just want to compare if i am getting the same page or different page after i have modified the get post parameters.
Help

If you would have gone through this then you shouldn't have asked this question.
http://php.net/manual/en/class.httpresponse.php
Go through it first.I cant prepare fully functional code for you here.

Related

httprequest getting back PHP functions and variables

How does one access and receive back a variable from a PHP file with a HTTP Request?
I have gotten a HTTP Request to connect to my .PHP file. What I wanted to do next is for example reference that I want to receive $testvariable = 1; back but I have no idea where to begin. The HTTP parameters don't really let me reference this $testvariable directly.
What if the PHP file has simply one function and at the end of it it does a return $testvariable;? Would HTTP receive back this one variable? What if I need more than one. Maybe try and get the PHP to place parameters in the URL and the HTTP reads those parameters in the url? Maybe these "headers" are key to this...
I figured it out. HTTP Request gets back ALL that is on your HTML page. It seems like it ignores <html><body> tags but everything else in the body gets taken back at your response. Even if your answer is " 1 " but you have a single space around it your response is 1 including blank spaces. You need a clean "1".
Passing variables works by using the contents field. You place your values and assign them to a string like number= that then gets posted on the page. When a page is loaded, it can look for a variable under the same name like $test = $_POST['number']; and take the value within that variable and use it further where it needs to on your page.

Drupal Views Header PHP code not working with AJAX Enabled View

I have some custom PHP code in a View header to load a different image based on the URL. The View works fine on it's initial load, but as soon as I change any of the filtering options with AJAX enabled, the Header disappears. Example code:
$req = $_SERVER['REQUEST_URI'];
if (preg_match("/TEXT-IM-LOOKING-FOR/", $req))
{
...HTML HERE...
}
I checked the URI by printing $req with dpm() and it's coming back with the text I'm looking for in the string, it just fails to reload the header for some reason. If for some reason this can't be done, is there any way to retain the header and only reload the body of the View?
It's almost never a good idea to put HTTP headers in a template/view for exactly the reasons you're citing. Switching to AJAX (in drupal) appears to change (maybe delete) the headers being sent.
You should instead try to put this code in a controller before it reaches a template/view.

Using PHP inside Javascript? To shrink URL

I made a bitly url shrinker, and I currently have a Soundcloud Javascript API that outputs a url link of a song. Im trying to shrink it using my shrinker. The shrinker works using this:
<?php echo $bitly->shorten('http://google.com'); ?> //Equals google.com in short url format
The javascript code I'm trying to implement it in is this: Ill go ahead and give you what I tried to do already, that didn't work.
Before I edited:
container.find('span.player-actions').html(
'Soundcloud | Download'
);
After I tried:
container.find('span.player-actions').html(
'Soundcloud | Download'
);
Any suggestions, I'm open to anything. And would love to make this work!
That has been already explained but in case you're new to this concept, there is a simplified explanation.
<?php tags in your code are processed on server before your page is sent to user's browser. Actually browser never receives those tags - they're replaced with PHP output on server and then the resulting page is sent to user.
As a result of some mistake sometimes PHP code makes into user's browser but it behaves as any other non-standard tag - content between <?php and ?> would be invisible to visitor.
JavaScript, on the other hand, operates in user browser with (in our case) what PHP has already output. When you change the page with JavaScript, it's not sent back to server - actually, server is totally unaware of that, so it can't execute the PHP code you're outputting by your JavaScript.
In order to achieve a similar result you need to send an AJAX request from your JavaScript code. It'll basically be another "page request" initiated by your JavaScript, but happening at the background with PHP output not replacing your current page, but arriving into your JavaScript code. This way your JavaScript is outputting PHP output and not PHP code, that's why it is possible.
You cannot call PHP on a string that is generated via javascript since PHP is server side and executed before JavaScript which is client side.
If you want to shorten this string, you'll have to make an ajax call to a php page that will return the shrunk url.

Salesforce Web2Lead - Lead Capture Page: Not available.

Upon debug I'm getting a response that states Lead Capture Page: Not available.
Has anyone run into this problem... I'm passing everything correctly and salesforce.com board is no help at all.
Unfortunately, the error message you got is generic, it doesn't say what the error is.
Using the debug=1 param, or the debugemail param, it tries to return to you the page that the post came from. I think it uses the Referer: header for that. No referrer header (like if you just curl post data to sf), then you get the line above instead of something like
Lead Capture Page: http://yoursite.com/your/form.php
Here's some other tips, given that sf isn't telling you jack:
instead of www.salesforce or test.salesforce, try posting to the same subdomain you see when you log in by browser.
Also look at the return header Is-Processed:, I've seen exceptions in there.
try the generated form; as generated, you change the subdomain as above and it should work as-is. then gradually hack your form and the generated form towards each other till they both fail or both succeed.

How to get the HTML source code after executing header(location:URL)

My web hosting provider does not permit to use curl FOLLOWLOCATION option so I'm trying to
do it manually by using the header function.
My problem is that I need to keep my PHP script running and to be able to get the redirected URL data for parsing.
How do I do that?
Technically the PHP script continues running after the header () function is called. How you get URL data is another question. Can you not use get_file_contents () or readfile () on the URL?
You read the RAW data the request returns, you check for the redirect header(s), fetch the related URL(s) and do a new get with that URL (dry, rinse, repeat). As simple as that...
Alternatively you could stop being so lazy, check the curl_setopt documentation in the PHP reference manual and find solutions - by reading the comments at the bottom of the page - on how to solve this problem of course.

Categories