How to access the HTML table from PHP [duplicate] - php

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.

Related

curl php bash sign [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.
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.

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/

Is it possible to use JavaScript's variable in PHP? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Access a JavaScript variable from PHP
theVariable = String.fromCharCode(theVariable).toLowerCase();
is it possible to use theVariable in PHP codes ? How?
Not really... you can send it to a PHP script using AJAX or an HTML form. I strongly recommend you get a clearer understanding of what JavaScript is vs. PHP, particularly what it means that JavaScript runs on the client-side (i.e. in the browser), and PHP runs server-side.
Only if the the variable is sent via ajax to a PHP page. You see PHP is executed first, then the page is served to the client. Then the client executes the javascript. So the javascript is executed long after the PHP has been executed.
To use a variable that is in JavaScript in PHP, you have to send an Ajax request to a PHP page passing that variable in. This probably isn't the effect you're looking for.
JavaScript executes on the viewer's computer. PHP executes on the server. To send a JavaScript variable to PHP, you need to send some packet of information from the client to the server. This is done as a GET/POST request.
The only way to pass a variable from JavaScript to PHP is to pass it by an AJAX call.

Send iPhone data to PHP file [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicates:
iPhone: Post data to php page
Passing Data From iPhone app to PHP file
What is the best way to send simple numerical and textual data from an iphone app to a php application?
Essentially what I am trying to do is to get the data input by users sent to a php file so it can be stored in a remote database.
What is the best way to send data from an iphone app to a php app so it can be stored in a MYSQL database...
assuming you know which fields are being sent, there is nothing to stop you sending the data via post, but make sure you validate/sanitise on the php side.
if you choose to go this route, I would have a look at http://allseeing-i.com/ASIHTTPRequest/
You will want to use NSURLRequest to post data to a PHP file on your server. There are also some libraries out there such as http://allseeing-i.com/ASIHTTPRequest/ which you could use instead.

Categories