473,473 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do you email form values in html?

39 New Member
I have created a form and am emailing it via php.

If I use plain text I can get all the entered information to email correctly. However, I wanted to have the information from the form laid out in html so that I can make it look like a completed document staff would normally see instead of just a series of lines with text.

I have tried a number of different combinations to get this to work but am getting nowhere fast!

Here is what I have so far:

Expand|Select|Wrap|Line Numbers
  1. $deptname = $_POST['deptname'] ;
  2. $add1 = $_POST['add1'] ;
  3. etc
  4.  
  5. $message = '
  6.  
  7. <html>
  8. <body>
  9.  
  10. Department Name: <?php $deptname ?>
  11. Address: <?php $add1 ?>
  12. etc
  13.  
  14. mail($to, $message, $headers )
  15.  
  16. </body>
  17. </html>
  18. ';
  19.  

I am receiving the email in HTML with the "Department Name:" part displayed but the user entered value is blank...


I'm fairly new to both html and php and cannot seem to find how to get this working so that I can apply the layout and formatting!!

Any help would be greatly appreciated!

Thanks

Carl
Sep 14 '10 #1
3 1307
Markus
6,050 Recognized Expert Expert
I'm too tired to write an explanation, so just look at this example.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. // Ignore that I'm doing no sanity-checking here
  4. $name = $_POST['name'];
  5. $age  = $_POST['age'];
  6.  
  7. $message = <<<MAIL
  8.   Name: $name
  9.   Age:  $age
  10. MAIL;
  11.  
  12. // $to and $headers would have to be defined
  13. if ( mail($to, $message, $headers) )
  14.   echo "Message sent successfully.";
  15. else
  16.   echo "Message not sent successfully.";
  17.  
References:
http://php.net/variables
http://uk3.php.net/manual/en/language.types.string.php
http://php.net/heredoc
http://php.net/mail
Sep 14 '10 #2
copleyuk
39 New Member
Thank you soooooo much Marcus!

Thats working perfectly!
I've been trying to figure that out for too long.

Thanks again

Carl
Sep 14 '10 #3
Markus
6,050 Recognized Expert Expert
You're welcome.
Sep 14 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Dave Karmens | last post by:
If I have say 10 fixed variables, how can I set their values = to that of a form that is built dynamically? column1 column2 email = formvalue(0) fname = formvalue(1) lname = formvalue(2)...
1
by: Randell D. | last post by:
HELP! I am determined to stick with this... I'm getting there... for those who haven't read my earlier posts, I'm createing what should be a simple function that I can call to check that...
8
by: djdave | last post by:
Pb with javascript. I've a 'main.html' script containing an 'iframe.html' IFRAME. The 'iframe.html' is containing a form. My problem is that i'm unable to get form fields values. What's the...
1
by: Robert Neville | last post by:
I would like to add filter functionality to my database whether through the Main form or the subform. This question may be rudimentary, yet I have not less experience with filtering data outside...
1
by: Miguel Dias Moura | last post by:
Hello, Can you help me out in making this work? What I want is as simple as sending form values to an email. The code I am using is the following:
1
by: Miguel Dias Moura | last post by:
Hello, Can you help me out in making this work? What I want is as simple as sending form values to an email. The code I am using is the following:
2
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
12
by: Matthew Wilson | last post by:
Hi, we are getting a lot of spam through our PHP Feedback form, and have set up a new field 'prove you're human', asking them to do some simple maths. What is the command for the PHP script...
5
stepterr
by: stepterr | last post by:
Hi Everyone, I'm new to PHP and have been working on an existing from that had been in Coldfusion but needed to be converted to PHP. I have most of it working except I ran into a problem when...
5
by: jmartmem | last post by:
Greetings, I have built an Update Record Form in an ASP page. This form contains a number of fields, such as text boxes and menus, to name a few. Upon clicking the 'submit' button, I want the...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.