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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:12:32+00:00 2026-05-25T19:12:32+00:00

This is my HTML form, which is inside a little box on my site.

  • 0

This is my HTML form, which is inside a little box on my site.

<form name="contactform" action="contact/form-mailer.php" method="post">


<p>*Name: <input name="Name" id="Name" size="25"></p>


<p>*Pickup from: <input name="pfrom" id="pform" size="25"></p>


<p>*Destination: <input name="destin" id="destin" size="25"></p>


<p>*E-mail: <input name="Email" id="Email" size="25"></p>


<p>*Phone: <input name="Phone" id="Phone" size="25"></p>

<p><input type="submit" value="Submit" name="submitform"><input type="reset" value="Reset" name="reset"></p>

</form>

And this is my current PHP for sending the mail using PEAR. I haven’t added all of the variables into the $body yet, as I’ve just been trying to get it to actually work.

<?php

   // Include the Mail package
   //require "Mail.php";
   include 'Mail.php';


   // Identify the sender, recipient, mail subject, and body
   $sender    = "XXXXXX";
   $recipient = "XXXXXX";
   $subject   = "FORM";
   $body      = $name; // Even when seting $name in the PHP file it still doesn't show!

   // Identify the mail server, username, password, and port
   $server   = "ssl://smtp.gmail.com";
   $username = "XXXXXXXX";
   $password = "XXXXXXXX";
   $port     = "465";

    // Get form var's   
    $name = "Test"; //  I set $name to "Test" in the PHP and still the variable does not appear in the email.
    $destin = $_POST['destin'];
    $email = $_POST['Email'];
    $pfrom = $_POST['pfrom'];

   // Set up the mail headers
   $headers = array(
      "From"    => $sender,
      "To"      => $recipient,
      "Subject" => $subject
   );

   // Configure the mailer mechanism
   $smtp = Mail::factory("smtp",
      array(
        "host"     => $server,
        "username" => $username,
        "password" => $password,
        "auth"     => true,
        "port"     => 465
      )
   );

   // Send the message
   $mail = $smtp->send($recipient, $headers, $body);

   if (PEAR::isError($mail)) {
      echo ($mail->getMessage());
   }

?>

So I have no idea why this isn’t working. I need body to be like this

$body = $name . " wants to go to " . $destin . " from " . $pfrom;

But it just doesn’t pickup any variables, regardless of whether I am trying to get them from the HTML form or set them in the PHP file itself. I was expecting this to be really easy, but this has stumped me for over a day now. Very frustrating. I can find no example anywhere that shows you how to do it, and only a handful have asked this exact question and received no definitive answer.

  • 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-05-25T19:12:32+00:00Added an answer on May 25, 2026 at 7:12 pm

    In the code you posted, you attempted to set the value of $body on line 13, but did not set the value of $name until line 22. $name is null at the time you assign it to $body, so $body does not contain the values you are hoping for.

    To fix this problem, move the $body = ... line below the other assignments. Something like this:

    ...
    // Get form var's   
    $name = "Test"; //  I set $name to "Test" in the PHP and still the variable does not appear in the email.
    $destin = $_POST['destin'];
    $email = $_POST['Email'];
    $pfrom = $_POST['pfrom'];
    
    // Populate $body
    $body = $name . " wants to go to " . $destin . " from " . $pfrom;
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have this html <ul> <li><form action=# name=formName></li> <li><input type=text name=someName /></li> <li><input type=text
I have this html form which has options: <tr> <td width=30 height=35><font size=3>*List:</td> <td
I have this HTML dropdown: <form> <input type=text id=realtxt onkeyup=searchSel()> <select id=select name=basic-combo size=1>
I have a html form with the data by this post method 'form id='form1'
This piece of valid json (it has been generated using php's json_encode): {html:form is
I am creating a select box for a form using this in _form.html.erb <%=
How can I the HTML string <br> from this HTML FORM pass to the
When I create a html form like this: $form = new Zend_Form(); $form->setMethod('post'); $form2->addElement('textarea',
I am trying to use an HTML form and javascript (i mention this, because
I have a form on my site which sends data to some remote site

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.