您好我正在进行注册页面
我是php的新手,并且想知道当我在表单中使用动作部分时这是否会起作用
<form method="post" id="formArea" action="action.php">
action.php是一个包含
的文件redirect.html
<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>
答案 0 :(得分:0)
你可以从表格中做到这一点。如果这是你要找的东西:
<form method="post" id="formArea" action="<?PHP $_SERVER['PHP_SELF'];?>">
//this will make the form post to same page as the form
如果您想要将其发送给两者,则可以将$_POST
数据保存在变量中并稍后使用。
EX:
<?PHP
//your form submit code might look something like this same file as your form
if(isset($_POST['submit']))
{
foreach($_POST as $key -> $value)
{
//echo or show your values or store your values in database or w/e
$_SESSION['post'][$key] = $value;
//this will make a session variable to be used again later each session array is marked with post identified by $key and stored a $value
}
//you can call your other page here this will only run after this page runs and loads your information above and then redirect with a session variable.
header("Location: redirect.html");
}
else
{
echo "<form method=\"post\" id=\"formArea\" action=\"".$_SERVER['PHP_SELF']."\">";
}
此代码未经过测试但可行,redirect.html将处理来自$_SESSION['post']
的代码