从css传递php post变量

从css传递php post变量,php,post,Php,Post,我制作了一个index.php页面,其中包含一个表单和一些要用php执行的python代码,我想在php执行python代码时显示一个旋转器gif。我发现:但我不知道如何将POST变量传递给php。这是我的密码: 索引表格: 在loader.gif之后调用php文件: 有什么想法吗?我知道我也可以使用Javascript,但我不知道如何使用。首先:请注意,您执行的代码包含用户输入!因此,用户可以尝试在您的服务器上执行他想要的代码,但您不会严重损坏您的服务器或数据 要解决加载微调器的问题,应该尝试

我制作了一个index.php页面,其中包含一个表单和一些要用php执行的python代码,我想在php执行python代码时显示一个旋转器gif。我发现:但我不知道如何将POST变量传递给php。这是我的密码:

索引表格: 在loader.gif之后调用php文件:
有什么想法吗?我知道我也可以使用Javascript,但我不知道如何使用。

首先:请注意,您执行的代码包含用户输入!因此,用户可以尝试在您的服务器上执行他想要的代码,但您不会严重损坏您的服务器或数据

要解决加载微调器的问题,应该尝试使用Javascript和单个页面进行表单输入和加载微调器。包含jQuery后,截取表单提交并使用AJAX发送数据。当请求运行时,您可以显示加载微调器

$(function() {
  $("form").submit(function(e) {
    e.preventDefault(); // Prevent the default submission of the form
    var form = $(this);
    var url = form.attr('action'); // Extract the URL from the form

    // Show your loading information and hide the form
    $("#loading_div").show();
    $("form").hide();

    $.ajax({
           type: "POST",
           url: url,
           data: form.serialize(), // Send the form information as 
           success: function(data) {
               // Script has finished
               // Do something here...
           },
           error: function() {
               // Script execution not successful
           }
    });
  });
});
以及你的索引:

<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>

<div style="display: none;" id="loading_div">
    <h1>Please wait</h1>
    <p> Processing the url. It may take a few seconds. </p>
    <img src="images/loader.gif" alt="loading" id="loader" />
</div>

我假设您的第二个php代码片段是welcome.php?

我有一个带有索引的页面,这个页面名为welcome,包含php代码,它执行一个python脚本,该脚本执行一些操作,并使用python脚本的结果创建一个新页面,我必须在执行python脚本后显示该页面。我知道,不管怎么说,这听起来像是绕口令:D,即使有你的建议,我仍然看不到加载微调器…确保在页面加载后绑定Javascript处理程序。您可以将其包装在$function{…}中以实现这一点。此外,浏览器开发工具向您展示了什么?嗯,好吧,现在我可以加载页面加载之前Javascript处理程序绑定的微调器,所以我修复了它,但它似乎没有在欢迎页面中调用php。再次检查浏览器的控制台和网络选项卡使用控制台让我意识到我不得不等待。非常感谢你的帮助!
<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>
$(function() {
  $("form").submit(function(e) {
    e.preventDefault(); // Prevent the default submission of the form
    var form = $(this);
    var url = form.attr('action'); // Extract the URL from the form

    // Show your loading information and hide the form
    $("#loading_div").show();
    $("form").hide();

    $.ajax({
           type: "POST",
           url: url,
           data: form.serialize(), // Send the form information as 
           success: function(data) {
               // Script has finished
               // Do something here...
           },
           error: function() {
               // Script execution not successful
           }
    });
  });
});
<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>

<div style="display: none;" id="loading_div">
    <h1>Please wait</h1>
    <p> Processing the url. It may take a few seconds. </p>
    <img src="images/loader.gif" alt="loading" id="loader" />
</div>