473,788 Members | 2,759 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP email form values

stepterr
157 New Member
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 $_POST['fieldname'] . The page goes like this:
1.) formtest.php : They fill in the form, hit submit.
2.) The page submits to itself (formtest.php) and it goes through and validates the inputs.
3.) If any of the validation fail it displays the form with the error message so that they can correct it and resubmit.
4.) If the form has been filled out correctly then the form fields are hidden and we display what they filled out in order for them to confirm. Or they have the option to return to form and correct anything that they want changed.

I was hoping that since both the form and the confirmation were within the same <form> tag that when the confirmation was submitted (using the post method) that it would pass the information along to our email.php page and send the email with the values.

If I skip the confirmation and just submit the form and send it to email.php the values will fill in but we really need to have that confirmation first. Any help on this would be greatly appreciated! thanks!
Nov 18 '07 #1
5 2189
Lumpy
69 New Member
Without seeing the code form both pages, the form page and the email page, it is tough to say why the post variables are not being emailed to you.

Reading through your post, I did wonder if upon confirmation and final submittal to the email page if the email page is looking for the right post variables. But that is really only a guess without seeing the code for both the pages you are using.
Nov 18 '07 #2
stepterr
157 New Member
Here is the basics of it. Its a very large form so I've only listed one of the fields that we use so that you don't have to look through all of that

** This is the testform.php page
Expand|Select|Wrap|Line Numbers
  1.  
  2. <?php 
  3.   $flag=1;  
  4.   //form validation is done everytime this page loads .If a check fails the $flag gets set to 0.
  5.  
  6. ?>
  7.  
  8. //Begin HTML
  9. //create table, etc.
  10.  
  11.  
  12. <form name="form2" method="post" <?php if ($flag == "0") {?>action="formtest.php"<?php }else{?>action="email.php">
  13.          <?php }?>>
  14.  
  15.   if ($flag == "0") {    
  16.   //This will display any error messages as well as the fields so they can make the corrections needed
  17.   ?>
  18.  
  19.       <table width="580"  border="0" cellspacing="1">                
  20.       <tr>
  21.              <td colspan="3">
  22.              <p align="center">
  23.               <b><font face="Arial" size="2">Company Contact Information</font></b></td>
  24.         </tr>
  25.          <tr>
  26.              <td width="239"><p class="mainbody"><font color="#336699"><b>Company Name:</b> (required)</font><br>
  27.                <input name="coCompanyName" value="<?php echo $_POST['coCompanyName']?>" size=30 maxlength=100 tabindex="1"></font></td>
  28.           </tr>
  29.           </table>
  30.          <input type="submit" value="Submit" name="Submit">
  31.  
  32.    <?php }
  33.    else{
  34.    // This is the confirmation that just displays the information to the user 
  35.    ?>
  36.     <table>
  37.     <tr>
  38.         <td ><p class="mainbody"><font color="#336699"><b>Company Name: </b> 
  39.              <?php echo $_POST['coCompanyName']?></font></td>
  40.          </tr>
  41.          </table>
  42.  
  43.           <input type="submit" value="Confirm" name="Confirm">
  44.           <input type="submit" value="Return to Form" onClick="goback();" name="Return"></p>
  45.   <?php }?>     
  46. </form>
  47.  
  48.  
*** this is what is on the email.php page. Again, I've only left the one field on this so its not so long.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $to = "myemail@email.com";
  4. $from = "myemail@email.com";
  5. $subject = "Company Contact Information";
  6. $message = "A company has submitted its profile.Here is the company contact information:" . "\n\n";
  7. $message .="Company Name:"."\n";
  8. $message .= $_POST['coCompanyName'];
  9. $headers  = "From: $from\r\n";
  10. $headers .= "Content-type: text/html\r\n";
  11. $mail = mail($to, $subject, $message, $headers);
  12. ?>
  13.  
Nov 18 '07 #3
ak1dnar
1,584 Recognized Expert Top Contributor
Are you sure, is this the same code structure as original? Can't you post the entire Page here.
NOTE: Please use the [code=php] while posting source codes.
Nov 18 '07 #4
Lumpy
69 New Member
Thank you for posting some code, it makes it easier to see what the possible problems could be.

First thing I saw is on line 11 you have an extra ">" after, action="email.p hp">. You don't need that because you will be closing the form tag off after the php is complete.

The second thing I saw, and maybe I am just missing it, is if the form passes and goes to the confirmation part, there is no hidden post variables in which to send to the email page. You might want to add in something like....

Expand|Select|Wrap|Line Numbers
  1.  
  2. <input type="hidden" name="ConfirmedCampanyName" value=" <?php echo $_POST['coCampanyName']; ?>">
  3.  
  4.  
and then in your email processing call for the post variable ConfirmedCompan yName instead of the coCompanyName.

Hope this helps!
Nov 18 '07 #5
stepterr
157 New Member
Thanks Lumpy, that worked perfectly!
Nov 18 '07 #6

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
1259
by: TJS | last post by:
after I allow users to modify form values with javascript the form values are no longer are available on the action page. how can I allow the user to modfy form values via javascript and still receive them on the action page?
1
2172
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:
3
1823
by: Miguel Dias Moura | last post by:
Hello, i created an ASP.net / VB page with a really big form. Now i want to create 4 pages and in each one i will place 1/4 of the big form. The last page will send all the form values by email. How can i send the form values from one page to the next one?
3
2317
by: desh | last post by:
hello How to retain the values in form tag ,in case user enter wrong information.
9
4566
by: Steve Poe | last post by:
Configuration: PHP 4.3.9 Apache 2.0.52 Hello PHP group, I am a novice to PHP. I have searched through the newsgroup on my issue but I am not sure I know what I am missing.
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...
3
1319
by: copleyuk | last post by:
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...
0
9656
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
10373
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...
1
10118
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9969
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
8995
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...
1
7519
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
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();...
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2897
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.