猿问

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

你们能帮我在表单提交和电子邮件确认后重定向吗?这是一个酒店预订代码。我已经尝试了几乎所有的东西......我在这个论坛上搜索了很多东西,但我无法解决我的问题:(((


<input type="submit" name="submit" class="btn btn-primary">

<?php

if ( 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>````


BIG阳
浏览 190回答 3
3回答

幕布斯7119047

你可以这样使用:&nbsp; $to = "jatinjhambji@gmail.com";&nbsp; $subject = "Confirmation mail";&nbsp; $message = " This message is to confirm your account has been created. "&nbsp; $headers = "From: youremail@example.com" . "\r\n" .&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "CC: somebodyelse@example.com";&nbsp; if(mail($to,$subject,$message,$headers)){&nbsp; &nbsp; &nbsp; header('Location: /yourredirectionpage.php');&nbsp; }

收到一只叮咚

请在下面的代码if (mysqli_query($con,$newUser))&nbsp;{&nbsp; &nbsp; sentBookingMail($mailData);&nbsp; &nbsp; header('Location: next_page.php');&nbsp; &nbsp; &nbsp;echo "<script type='text/javascript'> alert('Your Booking&nbsp; has been sent,you will receive a confirmation email shortly')</script>";&nbsp;&nbsp; } else {&nbsp; &nbsp; echo "<script type='text/javascript'> alert('Error adding user in database')</script>";&nbsp;&nbsp; }&nbsp; function sentBookingMail($mailData){&nbsp; &nbsp;// your mail code will be here&nbsp; }
随时随地看视频慕课网APP
我要回答