[RESOLVED] Error in contact form
Results 1 to 3 of 3

Thread: [RESOLVED] Error in contact form

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    2

    resolved [RESOLVED] Error in contact form

    Hi,

    Sorry but I am new to php. I have a contact form but it doesn't work. Please, read below the source code:

    HTML Contact form:
    ----------------------

    <form id="contact" action="process.php">
    <fieldset>
    <label for="name" id="name_label">Nombre <span class="note">(requerido)</span></label>
    <input type="text" name="name" id="name" size="50" value="" class="text-input" />
    <label for="email" id="email_label">Email <span class="note">(requerido)</span></label>
    <input type="text" name="email" id="email" size="50" value="" class="text-input" />
    <label for="subject" id="subject_label">Asunto</label>
    <input type="text" name="subject" id="subject" value="" class="text-input" size="50" />
    <label for="msg" id="msg_label">Mensaje <span class="note">(requerido)</span></label>
    <textarea cols="10" rows="3" name="msg" id="msg" class="text-input"></textarea><br />
    <input type="submit" name="submit" class="button" id="submit_btn" value="Enviar mensaje"/><div class="clear"></div><!-- clear float --> <br />
    <span class="error" id="name_error">Por favor introduzca nombre</span>
    <span class="error" id="email_error">Por favor introduzca dirección de correo electrónico</span> <span class="error" id="email_error2">Por favor introduzca dirección de correo electrónico válida</span> <span class="error" id="msg_error">Por favor introduzca el mensaje</span>
    </fieldset>
    </form>

    process.php code:
    --------------------

    <?php
    $emailTo = 'contact@domain.es';
    $subject = $_REQUEST['subject'];
    $name=$_REQUEST['name'];
    $email=$_REQUEST['email'];
    $msg=$_REQUEST['msg'];

    $body = "Name: $name \n\nEmail: $email \n\nMessage: $msg";
    $headers = 'From: '.$name.' <'.$email.'>' . "\r\n" . 'Reply-To: ' . $email;



    mail($emailTo, $subject, $body, $headers);
    ?>

    How could I know what's happening?

    BR.

  2. #2
    Web Interface Architect
    Join Date
    Jan 2002
    Location
    Central Texas
    Posts
    989
    bienvedio al forum senor(a)!

    You should break this down into pieces. First, make sure your mail server is set up (99.9% chance it is but just be sure)

    make a page <?php
    $emailTo = 'contact@domain.es';
    $subject = $_REQUEST['subject'];
    $name=$_REQUEST['name'];
    $msg=$_REQUEST['msg'];
    echo mail('youremail@you.com','test','test','From: testing@you.com'); //that should be enough to get through
    ?>
    note the echo - you should see a 1 if it is working
    you can check mail logs as well. Also try emailing to another address and see if your send addr. is not rejecting it


    Once you know this works then just build it up step by step. Good post, but learn to trouble-shoot in small pieces - and welcom to PHP!

    Sam
    Hey! You may have inadvertently stumbled onto some genius there! :-)

  3. #3
    Junior Member
    Join Date
    Nov 2012
    Posts
    2

    Solved

    Hi Sam,

    Thank you very much for your response and suggestions.

    It already works. I don't know why but the mail address I was using doesn't work. But if I send an email from another mail address, it works. It is an account from google business and, as the "from" mail address is not validated, the mail server could be filtering. Nevertheless, with a gmail account (but not business) it works.

    I will investigate in this way.

    BR,
    Benji.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •