2017-02-13 80 views
1

嗨,朋友们有2个文件index.php,form.php。在index.php中,我在form.php中将index.php中的表单操作给出了。如何在index.php上单击按钮时显示form.php。但如果用户在浏览器url中键入example.com/form.php,则显示如何隐藏它想要仅在点击提交按钮时才显示页面php

回答

1

设置sessions并检查它是否为真,则让form.php其他运行索引页重定向或只能在一个页面

<?php 

if (isset($_POST['submit'])) 
{ 

//if button clicked run this php 

//your php code here... 


} else { 
//if button not clicked show form 
?> 
<form action="<?php echo $_SERVER['PHP_SELF']?>" name="myform"> 

//form fields here... 

<input type="submit" name="submit" value="submit"> 

</form> 

<?php } ?> 

合并的形式,如果按钮点击它会执行PHP代码只其他形式将显示