所以我能够让用户一直到感谢页面,但是当我检查我的电子邮件(在真实代码中是正确的)时,我什么都没有。任何帮助,将不胜感激。
<?php
$myemail = "myEmailInAString@gmail.com";
$name = check_input($_POST['full_name'], "Enter your name");
$phone = check_input($_POST['phone'], "Enter a phone number");
$email = check_input($_POST['email']);
$address = check_input($_POST['address'], "Enter your address");
$city = check_input($_POST['city'], "Enter your city");
$state = check_input($_POST['state'], "Enter your state");
$zip_code = check_input($_POST['zip_code'], "Enter your zip_code");
$asking_price = check_input($_POST['asking_price'], "Enter your asking_price");
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)){
    show_error("E-mail address not valid");
}
$message = "
Name: $name
E-mail: $email
Phone Number: $phone
Address: $address
$city, $state, $zip_code
Asking Price: $asking_price";
mail($myemail, "$city Inquiry", $message);
header('Location: thanks.html');
exit();
function check_input($data, $problem=''){
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    if ($problem && strlen($data) == 0){
        show_error($problem);
    }
    return $data;
}
function show_error($myError){
    ?><html>
    <body>
    <p>Please correct the following error:</p>
    <strong><?php echo $myError; ?></strong>
    <p>Hit the back button and try again</p>
    </body>
    </html><?php
    exit();
}
?>
此外,任何关于 php 表单的提示将不胜感激。说到表格,我是个菜鸟……