簡體   English   中英

提交表單后未出現確認頁面

[英]Confirmation page not appearing after submitting the form

我是編程新手,已經制作了一個HTML表單,該表單可以從客戶那里收集數據,然后將其保存到數據庫中(正在運行)。我唯一要堅持的兩部分是確認頁面,應該顯示一個頁面,上面寫着感謝信息但現在它直接進入主頁。

其次,有一個Facebook跟蹤器編碼似乎沒有執行,我不知道為什么。

請任何人能幫助我嗎?

索引頁的編碼:

<!DOCTYPE html>
    <html>
    <head>
        <title>University of Salford -</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale = 1.0,user-scalable=no, maximum-scale=1.0" />
        <link href="css/style.css" rel="stylesheet"/>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>

        <!-- Add HTML 5 vaildation for older browser -->
        <script src="js/forms/modernizr-custom.js" type="text/javascript"></script> 
        <script src="js/forms/polyfiller.js" type="text/javascript"></script> 
        <script src="js/forms/validation.js" type="text/javascript"></script>
    </head>

    <body>
        <div id="headerImg"><img alt="header" src="images/salfordlogo.png"/></div>
        <div id="intro">Welcome to the University of Salford</div>
        <div class="para">
            <ul>
                <li>We welcome over 3000 international students per year from over 100 countries.</li>
                <li>Our presence at MediaCityUK offers invaluable employability enhancing experience to our students across all disciplines.</li>
                <li>To find out what we can offer you, why not come along to meet us in your country over the coming months.</li>
                <li>Please fill in your details below to get more information about our courses and generous scholarship scheme.</li>
            </ul>
        </div>

        <form action="process.php" name="form" id="form" >
            <input type="text" name="firstName" id="firstName" placeholder="First Name" required="required"/>
            <input type="text" name="surname" id="surname" placeholder="Family Name" required="required"/>
            <input type="text" name="dob" id="dob" placeholder="DOB (01/01/88)" required="required"/>
                <select name="nationality">
                <option value="">Nationality</option>
                <option value="Emirati">Emirati</option>
                <option value="Ghanaian">Ghanaian</option>
                <option value="Indian">Indian</option>
                <option value="Iranian">Iranian</option>
                <option value="Malaysian">Malaysian</option>
                <option value="Nigerian">Nigerian</option>
                <option value="Omani">Omani</option>
                <option value="Pakistani">Pakistani</option>
                <option value="Saudi">Saudi</option>
                <option value="Sri Lankan">Sri Lankan</option>
               </select>
            <input type="email" name="email" id="email" placeholder="E-Mail" required="required"/>
            <select name="areaCode" id="areaCode">
                <option value="">Area Code</option>
                <!--<option value="0044">+44 (UK)</option>-->
                <option value="00233">+233 (GH)</option>
                <option value="0091">+91 (IN)</option>
                <option value="0098">+98 (IR)</option>
                <option value="0060">+60 (MY)</option>
                <option value="00234">+234 (NG)</option>
                <option value="00968">+968 (OM)</option>
                <option value="0092">+92 (PK)</option>
                <option value="00966">+966 (SA)</option>
                <option value="0094">+94 (LK)</option>
                <option value="00971">+971 (AE)</option>
            </select>
            <input type="tel" id="mobile" name="mobile" placeholder="Mobile Number" required="required"/>
            <input type="submit" value="Submit"/>

        </form>
        <div id="footer"><img alt="header" src="images/salfordheader.png"/></div>
    </body>
    </html>

流程頁面的編碼

<?php
error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
ini_set('display_errors',1);

    //Start SMS API
    //STEP 1: Configure SMS text and then input bitly link for confirm.php
    require_once '../admin/lib/SmsApi/SmsApi.php';

    $sendSms  = new SmsApi();

    $config = parse_ini_file("config/config.ini");

    $body="Free Msg: \nHi [NAME], thank you for your interest in Salford. Click the link for more details http://bit.ly/salfordman ";

    //End SMS API

    //Connect to the mysql Db $con = 
    //mysql_connect($config['host'], $config['username'], $config['password']);

    try{
        $con = new PDO('mysql:host='.$config['host'].";dbname=".$config['database'].";charset=utf8",$config['username'],$config['password']);
    } catch (PDOException $e){
          header("Location: confirm.php?success=false");
        exit;
    }

    $con->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);



    //Select table to insert incoming data to. The tabel name is define in 
    //config.ini table = "{table}" mysql_select_db($config['database'],$con);

    //check if the any of the get Value have data otherwise show error

    foreach ($_GET as $value) {
         if($value==""){
            header("Location: confirm.php?success=false");
            exit;
         };

}
        //STEP 2: Perform Find/Replace or add in corresponding fields
        //User data fields from form in index file
        $firstName =$_GET['firstName'];
        $surname =$_GET['surname'];
        $dob =$_GET['dob'];
        $nationality =$_GET['nationality'];
        $email =$_GET['email'];
        $areaCode = $_GET['areaCode'];
        $mobile =$_GET['mobile'];

      //NEW MAIL VALIDATION NO NEED TO TOUCH!!!!!!! 
      if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            header("Location: confirm.php?success=false");
            exit;
        }

     //build Mysql query   
        $preparedQuery = $con->prepare("INSERT INTO salford (firstName,surname,dob,nationality,email,areaCode,mobile)
          VALUES (:firstName,:surname,:dob,:nationality,:email,:areaCode,:mobile)");

        $result = $preparedQuery->execute(array(
         ':firstName' => $firstName,
         ':surname'  => $surname,
         ':dob' => $dob,
         'nationality' => $nationality,
         ':email' => $email,
         'areaCode' => $areaCode,
         'mobile' => $mobile
     ));

    $con = null;

    if (!$result){

        //error page 
            header("Location: confirm.php?success=false&type=2");
                exit;
            }else{

            header("Location: http://educate.netmuk.com/salford/minisite");

        //Replace placeholder with dynamic text;
            $body = str_replace("[NAME]", $fullname, $body);

        //Check if leading 0 is present, for the area code
            if(preg_match("/^0/",$mobile)){
                $msisdn = preg_replace("/^0/", $areacode, $mobile); 
            }else{
                $msisdn =$areacode.$mobile;
            }

//build api sms query 
//below block commented by steve. switched to use iGate class
/*$urlQuery = "?body=".urlencode($body)."&msisdn=".$msisdn."&oadc=cccu";

$ch = curl_init();
    curl_setopt_array($ch, array(
    CURLOPT_URL => $config['smsApi'].$urlQuery,
    CURLOPT_RETURNTRANSFER=> TRUE   
));

curl_exec($ch);
curl_close($ch);*/ 




$sendSms->addMessage(
    array('msisdn'=> $msisdn,
        //Add content here
     '      message'=>  $body
)); 

//Set Sender Here
    $sendSms->setSender('Salford')->send();


//$iGateService->sendSMS returns TRUE on success, but we do nothing with it here
    }
?>

編碼具有Facebook跟蹤器和謝謝消息的確認頁面

 <!DOCTYPE html>
    <html>
        <head>
            <title>Salford</title>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <meta name="viewport" content="width=device-width, initial-scale = 1.0,user-scalable=no, maximum-scale=1.0" />
            <link href="css/style.css" rel="stylesheet"/>
        </head>
        <body>
            <div id="headerImg"><img alt="header" src="images/salfordlogo.png"/></div>

            <?php if($_GET['success']=="true"):?>
                <div id="intro">Submitted!</div>    
                <div>
                    Thank you, we will be in touch shortly
                </div>

            <?php else:?>
                <div>
                    There was an error, Please try again in a few moments.
                </div>

            <?php endif;?>

      <script type="text/javascript">
    var fb_param = {};
    fb_param.pixel_id = '6018025148480';
    fb_param.value = '0.00';
    fb_param.currency = 'GBP';
    (function(){
      var fpw = document.createElement('script');
      fpw.async = true;
      fpw.src = '//connect.facebook.net/en_US/fp.js';
      var ref = document.getElementsByTagName('script')[0];
      ref.parentNode.insertBefore(fpw, ref);
    })();
    </script>
    <noscript><img height="1" width="1" alt="" style="display:none" src="https://www.facebook.com/offsite_event.php?id=6018025148480&amp;value=0&amp;currency=GBP" /></noscript>
                      </body>

    </html>

在處理完所有代碼之后(在過程頁面的編碼中),您沒有重定向到的鏈接,只有在出現錯誤時才可以重定向。 因此,如果一切正常,在文件末尾,應該有一個這樣的重定向代碼:

header("Location: confirm.php?success=true");

因此,在隊伍頁面的?>之前添加此代碼!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM