473,800 Members | 2,623 Online
Bytes | Software Development & Data Engineering Community
+ 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 1321
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
2121
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) etc..
1
6028
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 required fields in a form have values. I'm writing the values to the client using document.write only so that I can confirm that the values are there to be played with - this is not the final result so please (unless it's leading to the script failure)...
8
13486
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 syntax ??? NB: the script has to be generic, because it has to work with any .html (i may don't know form's name and iframe's name). Thanks
1
7853
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 from queries. Let me just add that Allen Browne excellent article about this subject may not apply to this scenario on an elementary level. (Here's the link to the article; Filter a Form on a Field in a Subform -...
1
2174
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
1077
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
7053
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, input box for units of service, description of the service and each row has its own dropdown list of unit fees that apply. Each dynamically created row will return 3 values fee1_choice, fee1_unit and fee1_money. Note The above informaton is...
12
3052
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 itself, to say "this field must be equal to 9 or return the error page"? Thanks! Matt
5
2191
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 trying to email the form, the values are showing up blank. I believe it has to do with the flow and how the last step before the email process doesn't actually have the values in input fields, rather just displays the information with in html tags using...
5
3208
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 form values to pass to a confirmation page that shows the values entered and selected, with a CDONTS auto email generated at the same time. My problem is that I'm having trouble passing the values from the form to both the confirmation page and the...
0
9691
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10507
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10279
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10036
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9092
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6815
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4150
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 we have to send another system
3
2948
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.