如何转义其他代码-php


How to escape other codes - php

我有一个action='#'的表单输出一些输入

以及当提交按钮点击时的声明

if($_POST['edit'] == 'Edit') 
{
    manipulation here
    with printout
}

这里发生的是MAIN FORM的输出当点击提交按钮时,IF语句的输出打印出来

我想要的是,当点击提交按钮时,只会显示IF语句上的打印输出。

您是否尝试过用else-one或其他类型的情况扩展if语句?

//when form is submitted
if($_POST['edit'] == 'Edit') 
{
    manipulation here
    with printout
}
//when form not submitted
else 
{
    //display form
}

如果我理解正确,您不希望在表单提交后显示它。如果是这种情况,您可以检查表单提交的值之一是否已设置,并在此基础上显示原始表单。

这里有一个例子:

<?php if( !isset($_POST['edit']) ): ?>
    <form action="#">
        <input type="text" name="edit" />
        ...
        <input type="submit" value="Submit" />
    </form>
<?php else: ?>
    Display other information.
<?php endif; ?>