无法在表单中添加'phone'字段



首先,我在网站上使用模板。

此模板的contact.php可以正常工作,是:

<?php 
include 'config.php';
$nombre = stripslashes($_POST['nombre']);
$correo = trim($_POST['correo']);
$asunto = stripslashes($_POST['asunto']);
$mensaje = stripslashes($_POST['mensaje']);
$headers= "De:".$correo."nPara:".WEBMASTER_EMAIL;
if(mail(WEBMASTER_EMAIL, $asunto, $correo, $mensaje, $headers))
{
   echo "<script>alert('Hemos recibido tu correo, nos pondremos en contacto contigo lo antes posible.'); location.href='http://www.myweb.com/';</script>";
}
else
{
    echo "<script>alert('Error, intentelo de nuevo o más tarde.'); location.href='http://www.myweb.com/';</script>";
}

这是形式的HTML:

<form action="assets/contact/contact.php" method="POST">
                <div class="col-md-12">
                    <p><input class="form-control" type="text" placeholder="Nombre" name="nombre" required=""></p>
                </div>
                <div class="col-md-12">
                    <p><input class="form-control" type="email" placeholder="Correo electrónico" name="correo" required=""></p>
                </div>
                <div class="col-md-12">
                    <p><input class="form-control" type="text" placeholder="Asunto" name="asunto" required=""></p>
                </div>
                <div class="col-md-12">
                    <textarea class="form-control" rows="3" name="mensaje" required=""></textarea>
                </div>
                <div class="col-md-12">
                    <input type="submit" class="btn-white" value="Enviar">
                </div>
            </form>

我试图添加电话字段:

html:

<div class="col-md-12">
                    <p><input class="form-control" type="tel" placeholder="Teléfono" name="telefono" required=""></p>
                </div>

contact.php

<?php 
$telefono = stripslashes($_POST['telefono']);
$headers= "De:".$correo."nPara:".WEBMASTER_EMAIL;

但不起作用:(

更改

$mensaje = stripslashes($_POST['mensaje']);

to

$telefono = stripslashes($_POST['telefono']);
$mensaje = stripslashes($_POST['mensaje']). PHP_EOL. "telefono" .$telefono;

此变量未添加到电子邮件中。小技巧适合您,使用英语进行编码。

最新更新