I've made a index.php page with a form and some python code to be executed with php, and I would like to show a spinner gif while the php executes the python code. I found that: https://stackoverflow.com/a/34298686/11160699 but I can't figure out how to pass POST variables to php then. Here's my code:
- index form:
<form action="welcome.php" method="post">
<div class="row">
<div class="col-25">
<label for="fname">Website url</label>
</div>
<div class="col-75">
<input type="text" name="site" placeholder="Enter the site to be validated" autocomplete="off" pattern="(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+" required>
</div>
</div>
<div class="row">
<!--input type="submit" value="Validate"-->
<div><input type="submit" name="user_button" value="I'm a normal user"></div>
<div><input type="submit" name="programmer_button" value="I'm a programmer"></div>
</div>
</form>
- php code:
ob_start();
$url = $_POST["site"];
$path="pyt";
$dir = chdir($path);
list($scriptPath) = get_included_files();
echo exec("C:/Users/me/PycharmProjects/env/Scripts/python main.py '$scriptPath' '$url'");
- call to php file after loader.gif:
<div id="ok">
<h1> Please Wait </h1>
<p> Processing the url. It may take a few seconds. </p>
<img src='images/loader.gif' alt='loading' />
</div>
<style>
#runPHP
{
background-image:url(phps.php);
display:none;
}
</style>
</head>
<body>
<div id="runPHP"></div>
Any idea? I know I could also use Javascript, but I don't know how to do it.