Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP表单在数据库中添加空行_Php_Mysql_Forms - Fatal编程技术网

PHP表单在数据库中添加空行

PHP表单在数据库中添加空行,php,mysql,forms,Php,Mysql,Forms,我使用这个表单已经有一段时间了,我不明白为什么它会在一些条目中添加空白行。我一直试图复制这个bug,但没有成功。有什么想法吗 HTML格式: <form action="connect.php" method="post" enctype="multipart/form-data" onSubmit="alert('Hemos recibido correctamente tu petición, muchas gracias.')"> <p id="form_titl

我使用这个表单已经有一段时间了,我不明白为什么它会在一些条目中添加空白行。我一直试图复制这个bug,但没有成功。有什么想法吗

HTML格式:

<form action="connect.php" method="post" enctype="multipart/form-data" onSubmit="alert('Hemos recibido correctamente tu petición, muchas gracias.')">
    <p id="form_title">COMPLETA TUS DATOS Y ENVIA ESTA SOLICITUD
        <br>A LAS AUTORIDADES</p>
    <label></label>
    <input class="field" name="user_name" type="text" required="required" placeholder="Nombre:">
    <label></label>
    <input class="field" name="user_last" type="text" required="required" placeholder="Apellido:">
    <label></label>
    <input class="field" name="pais" type="text" required="required" placeholder="País:">
    <label></label>
    <input class="field" name="user_email" type="email" required="required" placeholder="Email">
    <label></label>
    <input class="field" name="tel" type="number" required="required" placeholder="Teléfono (Código de país y área)">
    <div id="masinfo" style="width: 156px;">    <a href="http://www.ficargentina.org/images/stories/Documentos/publicidad_punto_de_venta.pdf" target="_blank"><p>Más Información</p></a>

    </div>
    <input id="submit" name="submit" type="submit" value="Enviar">
</form>
</div>

完成日期和环境请求
拉斯奥托里达德斯酒店

PHP Connect和Post脚本:

<?php

define('DB_NAME', 'fic01_alto');
define('DB_USER', 'fic01_alto');
define('DB_PASSWORD','*****');
define('DB_HOST','localhost');

$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

if (!$link) {
    die('Could not connect: ' .mysql_error());
}

$db_selected = mysql_select_db(DB_NAME, $link);

$value1 = $_POST ['user_name'];
$value2 = $_POST ['user_last'];
$value3 = $_POST ['pais'];
$value4 = $_POST ['tel'];
$value5 = $_POST ['user_email'];

$sql = "INSERT INTO registros VALUES ('', '$value1', '$value2', '$value3', '$value4', '$value5')";

if (!mysql_query($sql)) {
    die('Error: ' . mysql_error());
}

if (!$db_selected) {
    die ('Cant use' . DB_NAME . ': ' . mysql_error ());
}

mysql_close();

if($value1 !=''&& $value2 !=''&& $value3 !=''&& $value4 !=''&& $value5 !=''){
    header("Location: index.html");
    exit();
}


?>
<h2>Gracias!, hemos recibido su firma. Ahora, será redirigido.</h2>

哪个条目的空行,您是否确保所有字段都不是空的?这也许可以解释。你不检查,所以我可以按回车键,然后砰的一声空白rows@Dagon难道他不能用if($value1!==NULL){…所有字段都是“必需的”,所以它不允许你点击enter和submit!你的浏览器可能不会,我的机器人不会在乎。永远不要相信客户端技术