duanba7498 2016-06-06 09:42
浏览 55
已采纳

联系表单只修改一个字段php

i have a long contact form in my car website that as you can see customer must field the form with her or his name, car model car tip and mobile number and etc as you see i have a condition for email and if it was not valid it gives an error massage and clean all the previous fields which customer has filled,

<?php
error_reporting(0);
include("config_mashin.php");
$namee = mysqli_real_escape_string($connect, $_POST['namee']);
$modell = mysqli_real_escape_string($connect, $_POST['modell']);
$tipp = mysqli_real_escape_string($connect, $_POST['tipp']);
$colorr = mysqli_real_escape_string($connect, $_POST['colorr']);
$exchangee = mysqli_real_escape_string($connect, $_POST['exchangee']);
$pricee = mysqli_real_escape_string($connect, $_POST['pricee']);
$loan = mysqli_real_escape_string($connect, $_POST['loan']);

$family = mysqli_real_escape_string($connect, $_POST['family']);
if (!empty($_POST['emaill'])) {
    $emaill = $_POST['emaill'];
    if (!preg_match("/^[_a-z0-9]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $emaill)){ 
        $error .= "The e-mail address you entered is not valid. <br/>";
        echo"$error";
    }
}
$mobilee = mysqli_real_escape_string($connect, $_POST['mobilee']);
$phonee = mysqli_real_escape_string($connect, $_POST['phonee']);
if(isset($_POST['submit']) && empty($error)){ 
//insert to database
    $insert =mysqli_query($connect,"INSERT INTO $db_table VALUES (i dont write this part to simplify code)");

}

?>

is there any way to keep other fields intact and customer just modify the email part. please help

  • 写回答

1条回答 默认 最新

  • dongyun8138 2016-06-06 09:49
    关注

    You can do something like:

    <form method='post' action=''>
        <input type='text' name='name' value='<?php echo isset($_POST['name']) ? $_POST['name']: ""; ?>' />
        <input type='submit' name='submit' value='Submit' />
    </form>
    

    and so on for each of you fields.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?