1

I am a newbie in coding. I am learning php and python.

I want to take data from user. For this I used google and found a form based on html and php

index.html

<html>
<body>

<form action="data.php" method="get">
TEXT1: <input type="text" name="text1">
TEXT2: <input type="text" name="text2">
<input type="submit">
</form>

</body>
</html>

Now data.php can use:

$_GET["text1"] $_GET["text2"]

But my script is in python. I don't know how to use the data given by user.

Please help.

Regards, Abhishek.

2
  • Save it to a file or database using PHP then load it using Python. Commented Mar 30, 2013 at 7:32
  • 1
    Will definitely try it but I fear that if many people access it at a time it can create a problem. Maybe I am wrong but just doubt that if someone gets result with wrong data... I mean he entered something and get result for something else... Sorry for silly question... Commented Mar 30, 2013 at 7:36

2 Answers 2

1

You could the system(..) [http://php.net/manual/en/function.system.php] command to call your python script with command line arguments.

system('python myScript.py ' . $_GET['text1'] . ' ' . $_GET['text2']);

Although I would really advice against using user provided input in this way, if a user would send 1;rm -rf /;echo as $_GET['text1'] your system would die.. (assuming apache is running as root, which would also be a bad idea)

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for quick reply. I am not having root access... Will this still work? Ans can you tell some way to prevent hackers from killing the m/c? Else no one will use it.
1

If you use a python framework like Pylons/Pyramid, you add your request parameters to your processing function, for instance:

def process_data(request):

   text1 = request.params.get('text1')

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.