首页 文章

另一页表单提交后的PHP自动刷新页面

提问于
浏览
1

我目前有3个页面:index.php,Insertred.php和homeme.php

Homered是一个在提交后更新到数据库的表单,而Index.php是一个显示结果的页面 . 我已经做了一些关于自动刷新页面的搜索,但所有这些都是计时器刷新 .

是否有可能在homered.php提交时自动刷新index.php?目前它执行此操作:homered.php提交按钮> insertred.php> index.php

homered.php :(删除了php部分作为其刚刚会话检查)

<html>

<head>
    <link rel="stylesheet" type="text/css" href="homered.css">                           
    </head>
<body>
<div class="centerimage">
<img src="images/anonymousfacepng.png" alt="Avatar" align="middle">
</div>
<div class="home-page">  
  <div class="form">
    <form class="home-form" action="insertred.php" method="post">
    <input type="text" placeholder="FTP Password" name="FTPBreach"/>
    <input type="text" placeholder="XP2 Victim IP" name="VictimIP"/>
    <input type="text" placeholder="XP2 Victim Password" name="VictimPass"/>
    <input type="text" placeholder="SQL Username" name="SQLUser"/>
    <input type="text" placeholder="SQL Password" name="SQLPass"/>
    <button>Submit</button>
      <p class="message"><a href="logoutred.php">logout</a></p>
    </form>
  </div>
</div>
</body>
<footer>
    © 
</footer>
</html>

Insertred.php:

<?php
    $db = mysqli_connect('prjtest1', 'root', 'test', '165619z_database');
    if (!$db)
    {
        die('Could not connect: ' . mysql_error());
    }
    $currenttime = date('Y-m-d H:i:s');
    echo $sql="UPDATE indextableredupdated SET FTPBreach = '$_POST[FTPBreach]', VictimIP = '$_POST[VictimIP]', VictimPass = '$_POST[VictimPass]', SQLUser = '$_POST[SQLUser]', SQLPass = '$_POST[SQLPass]', message = '$_POST[message]', time = '$currenttime' WHERE user = '2'" ;

    $query = mysqli_query($db,$sql);

    if (!mysqli_query($db, $sql))
    {
        die('Error: ' . mysql_error());
    }

    if($query)
    {

    header("location: index.php");
    }
    ?>

不确定你是否需要index.php的代码,因为它很长 . TLDR;我需要index.php只在insertred.php之后刷新

1 回答

  • 0

    这实际上是不可能的 . PHP是一种服务器端语言,只在请求时执行一次 . 由于PHP编译方式,不可能制作一个监听器或类似的东西 .
    它执行一次,也许回显任何数据等 . 但是当页面被查看到客户端时,在页面再次刷新之前不会运行任何服务器端代码 .

    单击here观看视频,教您如何在后台/服务器上运行PHP

相关问题