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.

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

报告相同问题?

悬赏问题

  • ¥15 求一阶微分方程的幂级数
  • ¥15 关于#线性回归#的问题:【统计】回归系数要转化为相关系数才能进行Fisher' Z转化吗(相关搜索:回归模型)
  • ¥100 使用matlab解决含分段变量的优化问题
  • ¥15 matlab基于鲸鱼算法优化vmd
  • ¥20 PCB设计与制作问答
  • ¥20 课堂跑如何下载ppt
  • ¥15 STM32阿里云平台显示不了传感器采集的数据
  • ¥20 三菱FX系列PLC上位机串口下指令置位M64和M65,这两条指令分别是什么呢?
  • ¥15 有关结冰模拟程序咨询
  • ¥15 ubuntu服务器配置dns域名后无法访问其他域名