为了账号安全,请及时绑定邮箱和手机立即绑定

表单提交后如何重定向到主页并发送确认电子邮件

表单提交后如何重定向到主页并发送确认电子邮件

PHP
BIG阳 2021-10-15 14:48:33
你们能帮我在表单提交和电子邮件确认后重定向吗?这是一个酒店预订代码。我已经尝试了几乎所有的东西......我在这个论坛上搜索了很多东西,但我无法解决我的问题:(((<input type="submit" name="submit" class="btn btn-primary"><?phpif ( isset( $_POST['submit'] ) ) {    $code1 = $_POST['code1'];    $code  = $_POST['code'];    if ( $code1 != "$code" ) {        $msg = "Invalide code";    } else {        $con   = mysqli_connect( "localhost", "root", "", "hotel" );        $check = "SELECT * FROM roombook WHERE email = '$_POST[email]'";        $rs    = mysqli_query( $con, $check );        $data  = mysqli_fetch_array( $rs, MYSQLI_NUM );        if ( $data[0] > 1 ) {            echo "<script type='text/javascript'> alert('User Already in Exists')</script>";        } else {            $new     = "Not Conform";            $newUser = "INSERT INTO `roombook`(`Title`, `FName`, `LName`, `Email`, `National`, `Country`, `Phone`, `TRoom`, `Bed`, `NRoom`, `Meal`, `cin`, `cout`,`stat`,`nodays`) VALUES ('$_POST[title]','$_POST[fname]','$_POST[lname]','$_POST[email]','$_POST[nation]','$_POST[country]','$_POST[phone]','$_POST[troom]','$_POST[bed]','$_POST[nroom]','$_POST[meal]','$_POST[cin]','$_POST[cout]','$new',datediff('$_POST[cout]','$_POST[cin]'))";            if ( mysqli_query( $con, $newUser ) ) {                echo "<script type='text/javascript'> alert('Your Booking  has been sent,you will receive a confirmation email shortly')</script>"                                  } else {                echo "<script type='text/javascript'> alert('Error adding user in database')</script>";            }        }        $msg = "Your code is correct";    }}    ?></form></div></div></div></div>````
查看完整描述

3 回答

?
幕布斯7119047

TA贡献1794条经验 获得超8个赞

你可以这样使用:


  $to = "jatinjhambji@gmail.com";

  $subject = "Confirmation mail";

  $message = " This message is to confirm your account has been created. "

  $headers = "From: youremail@example.com" . "\r\n" .

              "CC: somebodyelse@example.com";

  if(mail($to,$subject,$message,$headers)){

      header('Location: /yourredirectionpage.php');

  }


查看完整回答
反对 回复 2021-10-15
?
收到一只叮咚

TA贡献1821条经验 获得超4个赞

请在下面的代码


if (mysqli_query($con,$newUser))

 {

    sentBookingMail($mailData);

    header('Location: next_page.php');

     echo "<script type='text/javascript'> alert('Your Booking  has been sent,you will receive a confirmation email shortly')</script>"; 

  } else {

    echo "<script type='text/javascript'> alert('Error adding user in database')</script>"; 


  }


  function sentBookingMail($mailData){

   // your mail code will be here

  }


查看完整回答
反对 回复 2021-10-15
  • 3 回答
  • 0 关注
  • 189 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信