[Tutor] Python 2.5 and PHP 5.2.0

Luke Paireepinart rabidpoobear at gmail.com
Thu Feb 1 11:21:20 CET 2007


OkaMthembo wrote:
> Hi Guys,
>
> I need some wisdom from you. Is it possible to have PHP pages posting 
> to python scripts on the server side and returning values back to the 
> calling PHP files? Like, if my enterval.php form's action="think.py", 
> would the two scripts be able to talk to each other?
A client that is accessing your page never sees your PHP.
they just see an html file with a form in it.
when they submit the form, the python file will be called and its output 
will be displayed in the client's browser.
I can think of a roundabout way to do what you want:

PHP file returns a form to the client.  when this form is submitted to 
the py file, all of the data your py script needs is sent in the query 
string or whatever.
the py file does whatever it does, and then inside the html it returns 
to the client, it includes an instant redirect back to the PHP file with 
whatever
data you want to return.

However, this is a bad way to go about it.
You should be able to use python scripts on the server side without 
relying on the client's browser to pass data.
Not exactly sure how to, though.  May depend on your OS.

-Luke


More information about the Tutor mailing list