doudou1309 2013-11-08 03:39
浏览 7

PHP代码似乎死了没有获取数据

here is my php code it gets the data, but seems to just die, it does echo the error codes I can;t seem to find the reason for this it was working at one point. this pulls data from an html form i can load it if needed.

thanks for looking.

    <?php
       if(isset($_POST['email'])) {

          // EDIT THE 2 LINES BELOW AS REQUIRED
          $email_to = "blahblah@gmail.com";
          $email_subject = "Runner Registration";


    function died($error) {
        // your error code can go here
        echo "We are very sorry, but there were error(s) found with the form you submitted.  ";
        echo "These errors appear below.<br /><br />";
        echo $error."<br /><br />";
        echo "Please go back and fix these errors.<br /><br />";
        die();
    }

        $gender = 'unchecked';
        $size = 'unchecked';

    if (isset($_POST['gender'])) {
        $selected_radio = $_POST['gender'];
            if ($selected_radio == 'male') {
                $gender = 'Male';
            }
            else if ($selected_radio == 'female') {
                $gender = 'Female';
            }
    }



    if (isset($_POST['size'])) {
        $selected_radio = $_POST['size'];
            if ($selected_radio == 'small') {
                $size = 'Small';
            }
            else if ($selected_radio == 'medium') {
                $size = 'Medium';
            }
            else if ($selected_radio == 'large') {
                $size = 'Large';
            }
            else if ($selected_radio == 'xlarge') {
                $size = 'X-Large';
            }
            else 
                $size = 'XX-Large';

    }



    // validation expected data exists
    if(!isset($_POST['last-name']) ||
        !isset($_POST['first-name']) ||
        !isset($_POST['initial']) ||
        !isset($_POST['address']) ||
        !isset($_POST['city']) ||
        !isset($_POST['state']) ||
        !isset($_POST['zip']) ||
        !isset($_POST['phone']) ||
        !isset($_POST['email']) ||
        !isset($_POST['econtact']) ||
        !isset($_POST['ephone']) ||
        !isset($_POST['age'])) {
        died('We are sorry, but there appears to be a problem with the form you submitted.');
    }

    $first_name = $_POST['first-name']; // required
    $last_name = $_POST['last-name']; // required
    $initial = $_POST['initial']; // required
    $address = $_POST['address']; // required
    $city = $_POST['city']; // required
    $state = $_POST['state']; // required
    $zip = $_POST['zip']; // required
    $phone = $_POST['phone']; // required
    $email = $_POST['email']; // required
    $econtact = $_POST['econtact']; // required
    $ephone = $_POST['ephone']; // required
    $age = $_POST['age']; // required
    $size = $_POST['size']; // required


    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';

  if(!preg_match($email_exp,$email)) {
    $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
    $string_exp = "/^[A-Za-z .'-]+$/";
  if(!preg_match($string_exp,$first_name)) {
    $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }
  if(!preg_match($string_exp,$last_name)) {
    $error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }

  if(strlen($error_message) > 0) {
    died($error_message);
  }
    $email_message = "Form details below.

";

    function clean_string($string) {
      $bad = array("content-type","bcc:","to:","cc:","href");
      return str_replace($bad,"",$string);
    }

    $email_message .= "First Name: ".clean_string($first_name)."
";
    $email_message .= "Last Name: ".clean_string($last_name)."
";
    $email_message .= "Initial: ".clean_string($initial)."
";
    $email_message .= "Address: ".clean_string($address)."
";
    $email_message .= "City: ".clean_string($city)."
";
    $email_message .= "State: ".clean_string($state)."
";
    $email_message .= "Zip: ".clean_string($zip)."
";
    $email_message .= "Phone: ".clean_string($phone)."
";
    $email_message .= "Email: ".clean_string($email)."
";
    $email_message .= "Emergency Contact: ".clean_string($econtact)."
";
    $email_message .= "Emergency Phone: ".clean_string($ephone)."
";
    $email_message .= "Gender: ".clean_string($gender)."
";
    $email_message .= "Age: ".clean_string($age)."
";
    $email_message .= "Shirt Size: ".clean_string($size)."
";

// create email headers
$headers = 'From: '.$email."
".
'Reply-To: '.$email."
" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);  
?>


Thank you for contacting us. We will be in touch with you very soon.

<?php
}
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
    • ¥20 关于URL获取的参数,无法执行二选一查询
    • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
    • ¥15 marlin编译错误,如何解决?
    • ¥15 有偿四位数,节约算法和扫描算法
    • ¥15 VUE项目怎么运行,系统打不开
    • ¥50 pointpillars等目标检测算法怎么融合注意力机制
    • ¥20 Vs code Mac系统 PHP Debug调试环境配置
    • ¥60 大一项目课,微信小程序
    • ¥15 求视频摘要youtube和ovp数据集