如何在执行完php代码后,将输入的数据排除掉?

问题描述 投票:-1回答:1

我有一个帖子输入,在这里我提交一些简单的数据。

<form method="post" action="result.php">
    <input type="url" name="url" class="form-control" placeholder="http://example.com/">
    <input type="submit" name="submit" />
</form>

在html代码被执行后,会有一个php代码回传成功或类似这样的代码,这并不重要,但我有一个问题,当我include('submit.php')时,它将被删除。

但我有一个问题,当我include('submit.php')时,它会显示输入,我不希望这样。

我怎样才能做到不在result.php上显示输入?

php html forms include require
1个回答
0
投票

如果你希望它是用户特定的,你可以尝试使用Cookie或像这样的会话。

index.php

<?php
session_start();
?>

<?php if(!isset($_SESSION['show_button']) && !$_SESSION['show_button'] ){ ?>
<!-- Button logic here... -->
<?php } ?>

result.php

// If the url has been entered, it returns a false from empty()
$_SESSION['show_button'] = empty($_POST['url']);
© www.soinside.com 2019 - 2024. All rights reserved.