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

时间:2016-06-06 09:42:57

标签: php contact-form

我在我的汽车网站上有一个很长的联系表格,你可以看到客户必须在表格中填写她或他的名字,汽车模型汽车提示和手机号码等,因为你看我有电子邮件的条件,如果它无效,它会给出错误按摩并清理客户填写的所有先前字段,

<?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)");

}

?>

有没有办法保持其他字段不变,客户只需修改电子邮件部分。请帮忙

1 个答案:

答案 0 :(得分:0)

您可以执行以下操作:

<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>
每个字段的

等等。