Jump to content

JaySharma

Members
  • Posts

    10
  • Joined

  • Last visited

JaySharma's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yes I am using ajax to submit . the form code is <div class="title"><span>Get in touch</span></div> <p class="tac">Contact via email </p> <div class="status alert alert-success" style="display: none"></div> <form id="contact-form" method="POST" class="row mt10 style1 contact-form" action="sendemail.php" name="contact-form"> <div class="col-md-6"> <input type="text" name="name" value="Enter your full name" required="required" onfocus="if(this.value=='Enter your full name')this.value=''" onblur="if(this.value=='')this.value='Enter your full name';" placeholder="name"/> </div> <div class="col-md-6"> <input type="text" name="email" placeholder="email" value="Enter your full e-mail" required="required" onfocus="if(this.value=='Enter your full e-mail')this.value=''" onblur="if(this.value=='')this.value='Enter your full e-mail';" /> </div> <div class="col-md-6"> <input type="text" name="subject" value="Enter your full name" required="required" onfocus="if(this.value=='Enter your full name')this.value=''" onblur="if(this.value=='')this.value='Enter your full name';" placeholder="subject"/> </div> <div class="col-md-12"> <textarea rows="7" cols="5" name="message" placeholder="message" id="message" required="required" onfocus="if($(this).val()=='Write your message...'){$(this).val('');}" onblur="if(this.value=='')this.value='Write your message...';" >Write your message...</textarea> <div class="submit_btn"> <div class="inner"> <input class="submit btn" type="submit" value="Submit" name="" /> </div> </div> </div> </form> Thats the code I am using for form . The javascript code is the following //Ajax contact var form = $('.contact-form'); form.submit(function () { $this = $(this); $.post($(this).attr('action'), function(data) { $this.prev().text(data.message).fadeIn().delay(3000).fadeOut(); },'json'); return false; }); Thanks
  2. I didnt wanted to use subject , so I kept it as is and didnt used in html . Do you think that might be creating the issue ?
  3. OKie I recieved an email now with content for the test page you wanted me to create. BUt why the script I am using is not working .
  4. <?php header('Content-type: application/json'); $status = array( 'type'=>'success', 'message'=>'Email sent!' ); $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 = 'free.bks@gmail.com'; $body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message; $headers = "From: mail <$email_from>\r\n"; $headers .= "MIME-Version: 1.0" ."\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; $success = mail($email_to, $subject, $body,$header); echo json_encode($status); die; Still got a blank mail
  5. echo json_encode($status); outputs the message after i click on submit button . Removing it only stops displaying the message , the emails are still blank . I am testing it on server
  6. <?php header('Content-type: application/json'); $status = array( 'type'=>'success', 'message'=>'Email sent!' ); $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 = 'free.bks@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; This above is the php email script I have . Form code I am using is below <div class="status alert alert-success" style="display: none"></div> <form id="contact-form" method="POST" class="row mt10 style1 contact-form" action="sendemail.php" name="contact-form"> <div class="col-md-6"> <input type="text" name="name" value="Enter your full name" required="required" onfocus="if(this.value=='Enter your full name')this.value=''" onblur="if(this.value=='')this.value='Enter your full name';" placeholder="name"/> </div> <div class="col-md-6"> <input type="text" name="email" placeholder="email" value="Enter your full e-mail" required="required" onfocus="if(this.value=='Enter your full e-mail')this.value=''" onblur="if(this.value=='')this.value='Enter your full e-mail';" /> </div> <div class="col-md-12"> <textarea rows="7" cols="5" name="message" placeholder="message" id="message" required="required" onfocus="if($(this).val()=='Write your message...'){$(this).val('');}" onblur="if(this.value=='')this.value='Write your message...';" >Write your message...</textarea> <div class="submit_btn"> <div class="inner"> <input class="submit btn" type="submit" value="Submit" name="" /> </div> </div> </div> </form> I am getting emails , been trying for the last few hours changing things , but its not working ; may be I am overlooking something important . I am learning php .
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.