We help IT Professionals succeed at work.

PHP Send_contact.php Form

bains1000
bains1000 asked
on
443 Views
Last Modified: 2013-01-05
Hi

I have moved webhost and am trying to create a contact form in PHP, i've never programmed in php before, as you can imagine I am struggling a little.

I have created a form and send_contact.php file with the following code, most of this is working however I would like to post two variables from my contact form in the message body.  I current have a single line of code:

$message=$_POST['enquiry'];

Open in new window

this works fine but I also want to include the following line:

$message=$_POST['contactnumber'];

Open in new window

When I post the second line the first line doesn't show up in the message body.  I have the code as the following:
$message=$_POST['enquiry'];
$message=$_POST['contactnumber'];

Open in new window


Ideally I would like the message body to be:

Enquiry Details: [Enquiry]
Contact Details: [Contactnumber]

The parts in the brackets need to be pulled from the form.

Could someone help me get this code correct.

thanks
Comment
Watch Question

Most Valuable Expert 2011
Author of the Year 2014

Commented:
Buy this book.  Trust me, it will make your life MUCH easier and more productive!
http://www.sitepoint.com/books/phpmysql5/
Most Valuable Expert 2011
Author of the Year 2014
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
I was missing the . in the additional lines

thanks for your quick response.
Most Valuable Expert 2011
Author of the Year 2014

Commented:
Thanks for the points and thanks for using EE, ~Ray
You are probably asking how to combine those two values into $message.

If you do this, then $message will always have the LAST value only:
$message=$_POST['enquiry'];
$message=$_POST['contactnumber'];

Open in new window

But if you want to add 2nd value to the 1st, then use ".=" instead of "=" only:
$message=$_POST['enquiry'];
$message.=$_POST['contactnumber'];

Open in new window

Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.