doudi7782 2014-01-30 12:34
浏览 22

验证成功完成后重定向到email.php页面

Here i'm trying to send a contact form values to email id. I've posted contact.php page code. I've done server side validation on same page. After validation successfully completed it should redirect to email.php page. How should i do?

Contact.php

 <?php
    $errname = "";
    $errmotorcycle = "";
    //some codes

    if($_POST["contacts"] == "all")
    {
        // name validation
        if(empty($_POST["name"]))
        {
            $errname = '<span class="error">Should not be empty</span>';
        }
        else if(preg_match("/^[a-zA-Z ]+$/", $_POST["name"]) === 0)
        {
            $errname = '<span class="error">Name must be from letters and spaces only</span>';
        }
        else
        {
            $errname = '';
        }
        // motorcycle validation
        if($_POST["typeofmotor"] == "empty")
        {
            $errmotorcycle = '<span class="error">You must select one option</span>';
        }
        //some codes
    }
 ?>

<html>
<head><title></title></head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" >
<input type="hidden" name="contacts" value="all" />
<table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="281" height="40" class="rightalign">Name : </td>
    <td width="268"><input type="text" name="name" class="normal" value="<?php $_POST['name']; ?>" /></td>
    <td width="431" valign="middle"><?php if(isset($errname)) echo $errname; ?></td>
  </tr>
 //some codes
</table>
</form>
</body>
</html>
  • 写回答

2条回答 默认 最新

  • duankuaizhe8257 2014-01-30 12:38
    关注

    After sending the eMail, you could redirect the browser like that:

    <?php
    header('Location: http://www.example.com/email.php');
    die();
    ?>
    

    If you choose that solution, please keep in mind that headers may only be sent before any content is sent to the browser.

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP