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 8961741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:57:52+00:00 2026-06-15T15:57:52+00:00

I am having some trouble with a PHP contact form, when submitted this form

  • 0

I am having some trouble with a PHP contact form, when submitted this form returns only
phone number: and also enquiry: undefined . It should return Name, Phone Number and my Enquiry. Any idea why its not returning name and why Enquiry is undefined?

MY PHP

    $name=$_POST['name'];
    $phone=$_POST['phone'];
    $enquiry=$_POST['enquiry'];

    $subject="NINJA2k - EMAIL INQUIRY FROM: $name";
    $message="
          Phone:<br>
          <strong>$phone</strong><br>
          <br>
          Enquiry:<br>
          <strong>$enquiry</strong><br>
          <br>
    ";

    mysql_close();

    include("class.phpmailer.php");
    include("class.smtp.php");

    $mail = new PHPMailer();
    $mail->IsSMTP();// send via SMTP
    $mail->Host = "localhost"; // SMTP servers
    $mail->SMTPAuth = false; // turn on/off SMTP authentication
    $mail->From = "user1@mydomain.com";
    $mail->FromName = "http://mail.mydomain.com/";
    $mail->AddAddress("user1@mydomain.com");
    $mail->AddReplyTo("user1@mydomain.com");
    $mail->WordWrap = 50;// set word wrap
    //now Attach all files submitted

    $mail->Body = $message;
    //
    $mail->IsHTML(true);// send as HTML
    $mail->Subject = $subject;


    if($mail->Send()) 
    {
        echo "Thank You <b>$name</b><br>Your email has been sent.";
    } 
    else 
    {
        echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
    }
?>

$('.contact_form').dialog({
        width:500,
        height:450,
        modal:true,
        buttons: {
            "Send": function() {
                if(($("#ct_name").val()=="") || ($("#ct_phone").val()=="") || ($("#ct_enquiry").val()=="") || ($("#ct_captcha").val()==""))
                    alert("You must fill all the field");
                else
                {
                    var capt=$(div_list[ind]).attr("id");
                    if(capt!=$("#ct_captcha").val().toLowerCase())
                        alert("Captcha Code is Invalid!");
                    else
                    {
                        var send_string;
                        send_string="name=";
                        send_string+=$("#ct_name").val();
                        send_string+="&phone=";
                        send_string+=$("#ct_phone").val();
                        send_string+="&enquiry=";
                        send_string+=$("#ct_enquiry").val();

                        $.ajax({
                             type: "POST",
                             url: "send_mail.php",
                             data:   send_string,
                             async: false,
                             success: function(msg){ 
                                alert("Your mail was sent successfully!");
                             } ,
                             error: function(msg){
                                alert("Sorry! We couldn't send email"); 
                             }
                        }); 
                    }
                }

            }
        }
    });

MY HTML

    <div class="contact_form" title="Dialog Title" style="display:none">
    <table width="100%" style="padding:30px">
        <tr><td>Name</td><td><input type="text" id="ct_name"/></td></tr>
        <tr><td>Phone Number</td><td><input type="text" id="ct_phone"/></td></tr>
        <tr><td>Enquiry Data</td><td><textarea rows="4"></textarea></td></tr>
        <tr>
        <td>Captcha</td>
        <td>
            <div>
                <div class="captcha" id="28ivw"><img src="images/captcha1.png" /></div>
                <div class="captcha" id="k4ez"><img src="images/captcha2.png" /></div>
                <div class="captcha" id="jw62k"><img src="images/captcha3.png" /></div>
                <div class="captcha" id="fh2de"><img src="images/captcha4.png" /></div>
                <div class="captcha" id="gwprp"><img src="images/captcha5.png" /></div>
                <div class="captcha" id="4d7ys"><img src="images/captcha6.png" /></div>
                <div class="captcha" id="e5hb"><img src="images/captcha7.png" /></div>
                <div class="captcha" id="xmqki"><img src="images/captcha8.png" /></div>
                <div class="captcha" id="6ne3"><img src="images/captcha9.png" /></div>
                <div class="captcha" id="xdhyn"><img src="images/captcha10.png" /></div>
                <div class="captcha" id="q98p"><img src="images/captcha11.png" /></div>
                <div class="captcha" id="hrai"><img src="images/captcha12.png" /></div>
            </div>
            <input type="text" style="margin-top:15px" id="ct_captcha"/>
        </td>
        </tr>
    </table>
</div>
  • 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-15T15:57:54+00:00Added an answer on June 15, 2026 at 3:57 pm

    You need to use name attribute in your HTML to be able to reach the value. So instead of

    <tr><td>Name</td><td><input type="text" id="ct_name"/></td></tr>
    

    you should have

    <tr><td>Name</td><td><input type="text" name="name" id="ct_name"/></td></tr>
    

    EDIT

    The “trick” is that name value is used as input’s key in $_POST array. But if you at the same work with i.e. jQuery, then you may still need id or class as it’s easier to reach the input using them in DOM than using name.

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

Sidebar

Related Questions

Having some trouble with this.. <?php EG204_ExoSkel(); function EG204_ExoSkel() { $to_be_end = 'Red'; everything_loop();
Having some trouble issuing a simple query from the PHP Mongo driver. This is
I'm having some trouble with this one thing I'm working on in php(though I
I'm having some trouble parsing malformed XML in PHP. In particular I'm querying a
Im having some trouble writing a getstring function, this is what I have so
Having some trouble sending properly formatted HTML e-mail from a PHP script. I am
I'm having some trouble with a SQL transaction using PHP and mySQL. Here is
I'm having some trouble extending Classes in PHP. Have been Googling for a while.
I'm having some trouble using sessions with php.. I think I have figured out
I'm having some trouble finishing my FTP file uploader using PHP. I'm using the

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.