Reputation: 11
I have a form, which one submitted goes to a php file and inserts values into DB(MySql).After successfully inserting values into DB,I want to use the values of this parameter form as a python file in another php file when i submitted .
file register.php -> file description.php (button start) -> file exucuter.php( execute pythonfile)
Upvotes: 0
Views: 57
Reputation: 41820
Instead of redirecting to exucuter.php after doing your DB insert, if you
include 'exucuter.php'; // (assuming they are in the same directory)
in description.php after the DB does its work, you should be able to use the values directly from $_POST
in exucuter.php. This way you won't have to worry about storing them somewhere or transferring them between the two scripts.
If your second script (description.php) requires some additional user interaction before your third script (exucuter.php) runs, then you can't just include exucuter.php, and you do need a way to retain the values from your first script. There are different ways to do this: storing them in the session or in a file or database, putting them in the query string for the form action in description.php, or including them as hidden inputs. Here is an example using hidden inputs:
register.php
<form action="description.php" method="POST">
<label for="x">X: </label><input type="text" name="x" id="x">
<input type="submit" value="Register">
</form>
description.php
<?php if (isset($_POST['x'])) { /* Do your DB insert */; } ?>
<form action="exucuter.php" method="POST">
<!--Use a hidden input to pass the value given in register.php-->
<input type="hidden" name="x" value="<?php isset($_POST['x']) ? $_POST['x'] : ''; ?>">
<label for="y">Y: </label><input type="text" name="y" id="y">
<input type="submit" value="Execute">
</form>
exucuter.php
<?php
if (isset($_POST['x']) && isset($_POST['y'])) {
// execute your python program
}
Upvotes: 1