Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7876021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:06:01+00:00 2026-06-03T03:06:01+00:00

I have been working off a tutorial on Net Tuts to create a contact

  • 0

I have been working off a tutorial on Net Tuts to create a contact form for my website. Link for tutorial below:

http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/

I have it functioning however have been dabbling with a ways to add an additional field into the form for comments. All other fields are submitted fine to both email addresses (my website email and the sender gets copy also) but the comment field keeps displaying “No comment entered”

The code for my form is as follows:

[contact.php page]

<div id="content">
<div id="contact_form">
    <div class="padding">
<h2>Contact Me</h2>
<p>If you would like to contact me regarding a quote or indeed anything relating to the website
please use the form below and I will get to you as soon as possible. Thanks!</p>
<form name="contact" method="post" action="">
   <fieldset>
     <label for="name" id="name_label">Name</label>
     <input type="text" name="name" id="name" size="30" value="" class="text-input" />
     <label class="error" for="name" id="name_error">This field is required.</label><br />

     <label for="email" id="email_label">Return Email</label>
     <input type="text" name="email" id="email" size="30" value="" class="text-input" />
     <label class="error" for="email" id="email_error">This field is required.</label><br />

     <label for="phone" id="phone_label">Return Phone</label>
     <input type="text" name="phone" id="phone" size="30" value="" class="text-input" />
     <label class="error" for="phone" id="phone_error">This field is required.</label><br />


     <label for="comment" id="comment_label">Comment</label>
     <textarea name="comments" rows="10" cols="30" ></textarea>
     <input type="text" name="comment" id="comment" size="300" value="" class="text-input" />
     <label class="error" for="comment" id="comment_error">This field is required.</label><br />
     <input type="submit" name="submit" class="button" id="submit_btn" value="Send" />
   </fieldset>
 </form>    
    </div>
</div>
</div>

[process.php]

   <?php
if ((isset($_POST['name'])) && (strlen(trim($_POST['name'])) > 0)) {
    $name = stripslashes(strip_tags($_POST['name']));
} else {$name = 'No name entered';}
if ((isset($_POST['email'])) && (strlen(trim($_POST['email'])) > 0)) {
    $email = stripslashes(strip_tags($_POST['email']));
} else {$email = 'No email entered';}
if ((isset($_POST['phone'])) && (strlen(trim($_POST['phone'])) > 0)) {
    $phone = stripslashes(strip_tags($_POST['phone']));
} else {$phone = 'No phone entered';}
if ((isset($_POST['comment'])) && (strlen(trim($_POST['comment'])) > 0)) {
    $comment = stripslashes(strip_tags($_POST['comment']));
} else {$comment = 'No comment entered';}
ob_start();
?>
<html>
<head>
<style type="text/css">
</style>
</head>
<body>
<table width="550" border="1" cellspacing="2" cellpadding="2">
  <tr bgcolor="#eeffee">
    <td>Name</td>
    <td><?=$name;?></td>
  </tr>
  <tr bgcolor="#eeeeff">
    <td>Email</td>
    <td><?=$email;?></td>
  </tr>
  <tr bgcolor="#eeffee">
    <td>Phone</td>
    <td><?=$phone;?></td>
  </tr>
   <tr bgcolor="#eeffee">
    <td>Comment</td>
    <td><?=$comment;?></td>
   </tr>
</table>
</body>
</html>
<?php
$body = ob_get_contents();

$to = '';
$email = '';
$fromaddress = "";
$fromname = "Online Contact";
$test = $comment;

require("phpmailer.php");

$mail = new PHPMailer();

$mail->From     = $_POST['email'];
$mail->FromName = "Contact Form";
$mail->AddAddress("contact@ncwebcreative.co.uk","Name 2");


$mail->WordWrap = 50;
$mail->IsHTML(true);

$mail->Subject  =  "Contact form submitted";
$mail->Body     =  $body;
$mail->AltBody  =  "This is the text-only body";

if(!$mail->Send()) {
    $recipient = 'your_email@example.com';
    $subject = 'Contact form failed';
    $content = $body;
  mail($recipient, $subject, $content, "From: mail@yourdomain.com\r\nReply-To: $email\r\nX-Mailer: DT_formmail");
  exit;
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T03:06:03+00:00Added an answer on June 3, 2026 at 3:06 am

    Needed to change the code:

    $("input#comment").focus();
    

    to

    $("textarea#comment").focus();
    

    to be able to use text areas with jquery

    Thanks anyways

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working off of a tutorial of a tower defence game( http://www.guahanweb.com/2009/01/31/tower-defense-in-as3-part-iv/
This is a weird one. On and off as I have been working on
I have been working on and off on an assignment for my C class
Context: I have been working on and off on an application which uses a
I do html/css by trade, and I have been working on and off django
I have been working on a website using MVC Preview 1 since it came
For background I have been working on an RPG based off Ray Wenderlich's tutorials.
I have been working on a project that requires downloading a zipped file off
I have been working on and off with Java/Python. Now in this situation I
I have been working on Java off late, couldn't figure out what this (String...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.