curl php bash sign [duplicate] - php

This question already has answers here:
Can I read the hash portion of the URL on my server-side application (PHP, Ruby, Python, etc.)?
(12 answers)
Closed 9 years ago.
I have a code and need help. I have a curl call with a bash sign like this
http://example.com.ua/script.php
clients send me data using a script but some send me the bash # which I need to save all the data to my database. When I get $_SERVER I don't see all the data how can get all the data?
for example:
I have
http://example.com.ua/script.php#code1234
I need to save:
example.com.ua/script.php#code1234
but I see
example.com.ua/script.php

PHP does not have access to the location hash, period.
You only have access to querystrings in PHP, and if you need to get the hash, you would have to use javascript to get it, and send it to your PHP script with ajax.

Related

How to access the HTML table from PHP [duplicate]

This question already has answers here:
What is the difference between client-side and server-side programming?
(3 answers)
Closed 8 years ago.
I have a page with a java script that adds a row to a table. On the same page there is a PHP script that should read the table and add it to the database. How do I read the table using PHP ?
What you're thinking of will not directly work.
A Javascript script is executed on the client side only, whereas a PHP is executed on the server side only, and before the datas are sent to the client.
PHP can not directly read the table.
What you can do is use AJAX to send the data from the user's browser to a PHP script that'll use them.
You'll find more infos here.
PHP is serverside programing, the PHP code serves data to the client - PHP can't read from the client.
If you add a row using javascript, PHP has no way of getting that info.
You'll need to use Ajax to solve your specific problem.
You cannot "read the table" with PHP. You will have to send the data of the table to the server (and read it with PHP) using JavaScript or CGI.
A well-known technique to do this is called Ajax.

how to get the entire url in php including the # symbol with values [duplicate]

This question already has answers here:
Can I read the hash portion of the URL on my server-side application (PHP, Ruby, Python, etc.)?
(12 answers)
Closed 9 years ago.
abcd.com/indexreadmore.php?#cat2
This is what the url in which I want to get all the parts like above mentioned, I can get a bit but not able to get the #cat2 and help me fetch entire url in php from the url bar.
The hashtags are not sent to the server, only the browser so PHP wouldn't be able to parse that from the address. You'd have to use javascript:
<script type="text/javascript">alert(window.location.hash);</script>
You cannot get the URL after the # in PHP..
The maximum you can attain is abcd.com/indexreadmore.php , To verify this you could just do a print_r($_SERVER); on your PHP code.
The content after the # can be retrieved only through JavaScript.
If you mean to parse the url, then there is parse_url function.
var_dump(parse_url('abcd.com/indexreadmore.php?#cat2'));
The browser does not send the hash fragment to the server if you mean get it in indexreadmore.php.

Get the value of a Hashtag in PHP & JavaScript [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Can PHP read the hash portion of the URL?
I've a gallery site.
The actual selected album is marked in the URL with a hashtag.
Example with the album HDR:
http://www.example.com/gallery#HDR
Now i want to split the URL with parse_url. But there i need the URL in a String, WITH the hashtag. So it doesn't work with $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']...
The only way i know to reach the URL is with JavaScript.
But how can i convert a JavaScript variable in a PHP variable?
You cannot convert a javascript variable to php, because php is server sided and js client sided.
No variable in $_SERVER contains the "#xxx" part.
Check: Can I read the hash portion of the URL on my server-side application (PHP, Ruby, Python, etc.)?

retrieve name of calling script / Javascript in php [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Securing a remote ajax method call
Is there a way to retrieve the name of the javascript file that called a php script from within the PHP code?
Unfortunately, since I have to call a PHP script from Javascript (for Google maps) on a webpage, this 'invites' to retrieve my data by just calling the PHP script by hand. Checking for the script/file that invoked the PHP script would bring at least some protection.
You could set a session variable with some random value on the server when your page is opened, and add that variable in the query string to your php script.
Then in your javascript-called php script, you start the session and check the session variable against the query one.

How can I call a python instance using php? [duplicate]

This question already has answers here:
php : Capturing the command output
(3 answers)
Closed 8 years ago.
I have a PHP program, and a Python program. You can think that the Python program is like a robot or machine. Typically, it will use a database, do some analysis and return result for you. It is a plain text console application.
I would like to let the user use the program via a web interface. So, I would like to use PHP, accept user input, and the pass it to the Python program, and back to the user.
How can I achieve it? The Python program is always running on the server, which will keep analysis data from the web and the user input, so it can't easily convert to become a script on server side.
Any ideas?
You might want to check exec function. You can pass the input from user as parameters to the python script and get back the output from it.
Take a look into http://www.csh.rit.edu/~jon/projects/pip/

Categories