2017-02-28 61 views
1

你好我目前做一个注册页面,HTML表单:动作澄清

我是新来的PHP,并想知道如果我在形式

<form method="post" id="formArea" action="action.php"> 

使用动作部分这会工作action.php的是包含

redirect.html 

<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>

WOU文件这工作?或者有没有办法可以在操作部分同时拥有这两种功能,而无需创建新文件?

+2

对不起进程的代码,但目前还不清楚你问什么...什么是'redirect.flx' ?输出线的意义是什么?你为什么不简单地试试,如果有可能,而不是问我们呢? – arkascha

+0

redirect.flx只是一个html文件。它会将用户重定向到新页面并显示他们输入的信息。我没有尝试过,因为我不在家,无法连接到服务器 – Continuum

+0

现在你的问题更加不清楚了:'action =“action.php”'会导致对'action.php'文件的请求。为什么应该有一个'redirect.html'文件发挥作用?还有什么好的附加文件呢? – arkascha

回答

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']