noerodaba Posted April 1, 2014 Share Posted April 1, 2014 <section id="contact-page" class="container"> <div class="row-fluid"> <div class="span8"> <h4>Contacto</h4> <div class="status alert alert-success" style="display: none"></div> <form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php"> <div class="row-fluid"> <div class="span5"> <label>Nombre</label> <input type="text" class="input-block-level" required placeholder="..."> <label>Asunto</label> <input type="text" class="input-block-level" required placeholder="..."> <label>E-mail </label> <input type="text" class="input-block-level" required placeholder="..."> </div> <div class="span7"> <label>Mensaje</label> <textarea name="message" id="message" required class="input-block-level" rows="8"></textarea> </div> </div> <button type="submit" class="btn btn-primary btn-large pull-right">Enviar mensaje</button> <p> </p> </form> </div> This above is the html form code I have . php email script I am using is below <?php header('Content-type: application/json'); $status = array( 'type'=>'success', 'message'=>'Su e-mail ha sido enviado. Nos pondremos en contacto con usted lo antes posible' ); $name = @trim(stripslashes($_POST['Nombre'])); $email = @trim(stripslashes($_POST['E-mail'])); $subject = @trim(stripslashes($_POST['asunto'])); $message = @trim(stripslashes($_POST['Mensaje'])); $email_from = $email; $email_to = 'tallerdelinstrumento@gmail.com'; $body = 'Nombre: ' . $name . "\n\n" . 'E-mail: ' . $email . "\n\n" . 'Asunto: ' . $subject . "\n\n" . 'Mensaje: ' . $message; $success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>'); echo json_encode($status); die; ?> Thats the code I am using for form . The javascript code is the following jQuery(function($) { //Ajax contact var form = $('.contact-form'); form.submit(function () { $this = $(this); $.post($(this).attr('action'),$(this).serialize(), function(data) { $this.prev().text(data.message).fadeIn().delay(3000).fadeOut(); },'json'); return false; }); //Goto Top $('.gototop').click(function(event) { event.preventDefault(); $('html, body').animate({ scrollTop: $("body").offset().top }, 500); }); //End goto top }); I recieved the e-mail, but the content is blank. I don´t find the mistake. Please help, I´m new student in this topic. Thanks you!! Quote Link to comment https://forums.phpfreaks.com/topic/287437-email-script-sending-blank-email/ Share on other sites More sharing options...
mac_gyver Posted April 1, 2014 Share Posted April 1, 2014 most of your form fields don't have a name= " .... " attribute, which is required for the submitted data to be referenced, and for the one form field that does have a name attribute, the name doesn't match what you are using in the php code. Quote Link to comment https://forums.phpfreaks.com/topic/287437-email-script-sending-blank-email/#findComment-1474609 Share on other sites More sharing options...
noerodaba Posted April 1, 2014 Author Share Posted April 1, 2014 I changed the name, but still got a blank mail <section id="contact-page" class="container"> <div class="row-fluid"> <div class="span8"> <h4>Contacto</h4> <div class="status alert alert-success" style="display: none"></div> <form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php"> <div class="row-fluid"> <div class="span5"> <label>Nombre</label> <input type="text" name="name" class="input-block-level" required placeholder="..."> <label>E-mail</label> <input type="text" name="email" class="input-block-level" required placeholder="..."> <label>Asunto </label> <input type="text" name="subject" class="input-block-level" required placeholder="..."> </div> <div class="span7"> <label>Mensaje</label> <textarea name="message" id="message" required class="input-block-level" rows="8"></textarea> </div> </div> <button type="submit" class="btn btn-primary btn-large pull-right">Enviar mensaje</button> <p> </p> </form> </div> <?php header('Content-type: application/json'); $status = array( 'type'=>'success', 'message'=>'Su e-mail ha sido enviado. Nos pondremos en contacto con usted lo antes posible' ); $name = @trim(stripslashes($_POST['name'])); $email = @trim(stripslashes($_POST['email'])); $subject = @trim(stripslashes($_POST['subject'])); $message = @trim(stripslashes($_POST['message'])); $email_from = $email; $email_to = 'tallerdelinstrumento@gmail.com'; $body = 'name: ' . $name . "\n\n" . 'email: ' . $email . "\n\n" . 'subject: ' . $subject . "\n\n" . 'message: ' . $message; $success = @mail($email_to, $subject, $body, 'From: <'.$email_from.'>'); echo json_encode($status); die; ?> I don´t know where is the mistake. Quote Link to comment https://forums.phpfreaks.com/topic/287437-email-script-sending-blank-email/#findComment-1474631 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.