[英]I have created one html submit button and connects with php code but, after selecting that how can i go back my html page?
<?php
if($run == TRUE)
echo "Data Inserted Successfully <a href='index.html'>Click here to insert more</a>";
else
echo "Error !";enter code here
?>
I have created one html submit button and connects with php code but, after selecting that how can i go back my html page? 我创建了一个html提交按钮,并与php代码连接,但是,选择之后,我该如何返回我的html页面?
Realistically I would change the form to run the PHP on the same page. 实际上,我将更改表单以在同一页面上运行PHP。 So on the line where you create a form, instead of putting
<form action='whatever.php'></form>
I'd remove the action piece, then move the PHP script onto the same page (make sure it's .php instead of .html), and then wrap your whole script in something like this: 因此,在创建表单的那一行中,我将删除动作片段,然后将PHP脚本移至同一页面(确保它是.php),而不是放置
<form action='whatever.php'></form>
而不是.html),然后将整个脚本包装成如下形式:
if (isset($_GET['submit'])){ //or post depending on if you're using POST for your form, which is set by doing method=POST (suggested) or method=GET when creating the form's HTML
//your regular php script would go here :)
}
But if you insist on having the PHP on another page and having it direct back you can do it like such: 但是,如果您坚持要在另一页上放置PHP并将其直接返回,则可以这样进行:
die(header('Location: index.html')); //change index.html to the directory of the page (or even a URL) that you want them directed to
Best of luck to you! 祝您好运!
Use
$_SERVER['PHP_SELF']
as action in the form使用
$_SERVER['PHP_SELF']
作为表单中的操作
I would prefer you write your html in php file and then use $_SERVER['PHP_SELF'] this willl submit the data on the same page and you can handle the data of the form being on the same page/php file 我希望您在php文件中编写html,然后使用$ _SERVER ['PHP_SELF']这将在同一页面上提交数据,并且您可以处理在同一页面/ php文件中的表单数据
<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.