0

this is my site:

http://feriapixel.cl...nway/index.html

I've been trying other stuff and now i have the php code and the form in the same index.php file.

The form now looks like this

<form action="index.php" method="post">
            <div class="form-group">
              <input type="text" class="form-control" id="nombre" placeholder="Nombre" name="nombre">
            </div>
            <div class="form-group">
              <input type="text" class="form-control" id="apellido" placeholder="Apellido" name="apellido">
            </div>
            <div class="form-group">
              <input type="text" class="form-control" id="telefono" placeholder="Número Móvil" name="telefono">
            </div>
            <div class="form-group">
              <input type="mail" class="form-control" id="email" placeholder="Email" name="email">
            </div>
            
            <button type="submit" name="submit" id="submit" class="btn btn-ganarplata">QUIERO GANAR MÁS PLATA<br> VENDIENDO CLEAN WAY</button>
          </form>

And i have the php at the beginning of the file like this:

<?php
    $nombre = $_POST['nombre'];
    $apellido = $_POST['apellido'];
    $telefono = $_POST['telefono'];
    $mail = $_POST['mail'];
    $from = 'From: Cleanway'; 
    $to = 'alteizen@gmail.com'; 
    $subject = 'Formulario de contacto Cleanway';
    $body ="De: $nombre\n $apellido\n E-Mail: $mail\n Fono: $telefono\n ";
?>    
<?
if ($_POST['submit']) {
       if (mail ($to, $subject, $body, $from)) { 
        echo '<p>Su mensaje ha sido enviado</p>';
    } else { 
        echo '<p>No se pudo mandar su mensaje</p>'; 
    }
}
   
?>

And now i have checked out and it is not a hosting issue, because if i take out the following if statement:

if ($_POST['submit']) {

The mail is automatically sent when i load the page. So the problem is with the if statement, something is wrong there.

Problem solved, this was missing:

QUIERO GANAR MÁS PLATA
VENDIENDO CLEAN WAY

The button needed a "submit" value for sending the mail. That was all, thanks to me.

Felipe Pino
  • 131
  • 1
  • 7

1 Answers1

-2

You need to add an email address to $headers so that when you mail, the from address can be seen. Actually, your web server needs an MX record. Use it like this.

NOTE: If you use an email that is not your website's email(like xxx@gmail.com) it won't gonna work.

$headers .= "From: Name <email@example.com>";

So I think this will gonna work.

Doruk Ayar
  • 334
  • 1
  • 4
  • 17