使用php在新窗口中提交表单

时间:2014-11-17 04:26:31

标签: php html forms post

尝试使用php提交表单。当表单完成并且我点击“提交”时,我想要加载一个新的网页,显示客户端的所有凭据和选择以及客户端的注册号。我想使用“post”方法使用外部.php文件创建新页面。

这是我的表格:

<form name="form1" method="post" action="confirmation.php">

    What is your name? <input type="text" name="fullname" size="25" /><br />
    Your address: <input type="text" name="address" size="25" /><br />
    Your email: <input type="text" name="email" size="25" /><br />
    Your phone number (home/mobile): <input type="text" name="phonenumber" size="25" />


    What type of apartment are you willing to rent?:<br />
    <input type="checkbox" name="1Bedroom" /> 1 bedroom<br />
    <input type="checkbox" name="2Bedroom" /> 2 bedroom<br />
    <input type="checkbox" name="3Bedroom" /> 3 bedroom<br />


    Rental Type:<br />
    <input type="radio" name="type" value="weekly" /> Weekly <br />
    <input type="radio" name="type" value="monthly" /> Monthly <br />

    Starting Date for Rental <input type="date" name="startingdate" size="25" />
    <br />

    <input type="submit" value="Submit Form" />


</form>

到目前为止我已经尝试过了(没有公寓类型,租赁类型,开始日期):

<?php 
 echo $_POST["fullname"]; <br />
 echo $_POST["address"]; <br />
 echo $_POST["email"]; <br />
 echo $_POST["phonenumber"]; <br />
?> 

但表格的输入并没有在新窗口中显示。

2 个答案:

答案 0 :(得分:1)

如果您想在提交时打开新窗口。试试这个

<form target="_blank" action="confirmation.php" method="post">

    -- Your code here --

</form>

答案 1 :(得分:0)

我假设您尝试使用重定向在confirmation.php上获取这些值,并根据您提供的内容,只需修复您的回声。

<?php 
 echo $_POST["fullname"]. '<br />';
 echo $_POST["address"]. '<br />';
 echo $_POST["email"]. '<br />';
 echo $_POST["phonenumber"]. '<br />';
?>

如果您尝试在confirmation.php以外的某个位置访问这些值,则需要使用会话。

相关问题