Question

Get values using "GET" but not "POST"

Asked by: RosieisSweet

Hi,
I am new to PHP and am having a problem with a form to email information collected from an html form. When I use the "GET" parameter, the information gets to the intended email. When I use "POST" the email returns with empty fields. Can someone describe the difference between "GET" and "POST" that would cause this? My client does not want a database on his site. Just information emailed to him from these forms. Also, I am concerned with security using "GET" where the information is shown in the URL.

Here is the code I am using with "GET" and it is working but I think "POST" is what I will need for securitiy reasons. Can you use "POST" without a database?

<?php
// variables
$customer_name = $_GET['customer_name'];
$from = $_GET['customer_email'];
$customer_phone = $_GET['customer_phone'];
$customer_comment = $_GET['customer_comment'];

//to and subject
$to = "ozzie@bclean.com";
$subject = "Customer Inquiry";

//message body
$message = '
         <html>
                  <head>
                  </head>
                        <body>
                              <table width="90%" border="0" cellspacing="0" cellpadding="3">
                      <tr>
                        <td width="15%" align="left" valign="top">Name:</td>
                        <td align="left" valign="top"><b>'.$customer_name.'</b></td>
                      </tr>
                      <tr>
                        <td width="15%" align="left" valign="top">Email Address:</td>
                        <td align="left" valign="top"><b>'.$from.'</b></td>
                      </tr>
                      <tr>
                        <td width="15%" align="left" valign="top">Phone Number:</td>
                        <td align="left" valign="top"><b>'.$customer_phone.'</b><br></td>
                      </tr>
                      <tr>
                        <td colspan="2"><h2>How may we be of assistance?</h2></td>
                      </tr>
                      <tr>
                        <td colspan="2"><p>'.$customer_comment.'</p></td>
                      </tr>
                    </table>
                        </body>
            </html>
';

//make sure text wraps if it is to long
$message = wordwrap($message, 70);

//set html content type
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' .$from. "\r\n";

mail($to, $subject, $message, $headers);
?>

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2007-12-10 at 12:08:21ID23013924
Tags

php

Topics

Hypertext Markup Language (HTML)

,

PHP and Databases

,

PHP Scripting Language

Participating Experts
5
Points
125
Comments
30

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. MIME
    I'd like to have some sort of explanation about how MIME works.. I mean I know we can open a pdf in a browser, a word document or anyother document.. But I don't get it.. how come sometime, when I click a document.pdf link, sometime it ask me to save it, some other time it ...
  2. vAlign=top not working
    Hi, I am putting this in ASP.Net because I suspect that this problem has something to do with the way ASP.Net is rendering the controls. I've never seen this before outside of ASP.Net. My problem: when I set the vAlign to top for each of the cells in a table in a repeater s...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: ZylochPosted on 2007-12-10 at 12:12:41ID: 20444636

If you want to use post, you set the form method to POST and then use $_POST instead of $_GET. Post has no restrictions on how much data you can transmit, while GET has a limit of around 256 characters or something similar to that (don't remember exactly).

 

by: nplibPosted on 2007-12-10 at 12:13:09ID: 20444638

get and post have nothing to do with databases, it has to do with your method on your form

<form method="GET">
<form method="POST">

change your form and then change the way you retrieve the variables.

 

by: nplibPosted on 2007-12-10 at 12:13:33ID: 20444642

get and post have nothing to do with databases, it has to do with your method on your form

<form method="GET">
<form method="POST">

change your form and then change the way you retrieve the variables.

 

by: nizsmoPosted on 2007-12-10 at 12:14:08ID: 20444648

hi RosieisSweet,

You partially answered the question yourself, the difference between POST and get is that GET method the values are passed through the url, eg:
http://www.mydomain.com/index.php?myparameter=myvalue

in this case you can use the $_GET to get the 'myvalue', however POST will not work as POST looks for values submitted through the <form> tags, in your previous html page.

In terms of security, they are pretty much the same, no difference, one can reproduce POST submissions (by manually inserting values) as easily as GET.

Hope this helps.

 

by: nizsmoPosted on 2007-12-10 at 12:15:23ID: 20444658

rephrase:

>>POST looks for values submitted through the <form> tags, specified by your method, which is defaulted to "POST", in your previous html page.

 

by: RosieisSweetPosted on 2007-12-10 at 12:23:05ID: 20444728

Thank you for the comments but I am still confused as to why when I change this to POST, it is not forwarding the form values. Does the html form have to contain other PHP information (other than the method="POST") to get the information to forward to the action page when the submit button is clicked?

 

by: nizsmoPosted on 2007-12-10 at 12:24:06ID: 20444743

nope, should not. please show your code so that we can see? :)

 

by: RosieisSweetPosted on 2007-12-10 at 12:27:28ID: 20444768

Here is the form page which uses the action code I showed above:
        <form name="contact_form" id="contact_form" method="get" enctype="text/plain" action="response.php">
                    <table width="98%" border="0" cellspacing="0" cellpadding="6">
                      <tr>
                        <td width="20%" align="left" valign="top">Name:</td>
                        <td width="80%" align="left" valign="top"><input name="customer_name" type="text" id="customer_name" size="50" maxlength="60"></td>
                      </tr>
                      <tr>
                        <td align="left" valign="top">Email Address:</td>
                        <td align="left" valign="top"><input name="customer_email" type="text" id="customer_email" size="50" maxlength="60"></td>
                      </tr>
                      <tr>
                        <td align="left" valign="top">Phone Number:</td>
                        <td align="left" valign="top"><input name="customer_phone" type="text" id="customer_phone" size="15" maxlength="15"></td>
                      </tr>
                      <tr>
                        <td colspan="2" align="left" valign="top"><img src="assets/spacerw.gif" width="1" height="12"></td>
                      </tr>
                      <tr>
                        <td colspan="2" align="left" valign="top"><p class="supplier_link">How may we be of assistance?</p>                        </td>
                      </tr>
                      <tr>
                        <td colspan="2" align="left" valign="top"><textarea name="customer_comment" id="customer_comment" cols="75" rows="5"></textarea></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td><input name="submit" type="submit" id="submit" onClick="MM_validateForm('customer_name','','R','customer_email','','R','customer_phone','','R','customer_comment','','R');return document.MM_returnValue" value="Submit Request">
                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <input type="reset" name="clear_form" id="clear_form" value="Clear Form"></td>
                      </tr>
                    </table>
          </form>  

When I change GET to POST, the form does not send the info. I hope you can help as I am very confused at this point.

 

by: R7AFPosted on 2007-12-10 at 12:28:50ID: 20444787

It's important to know when to use GET and when to use POST. In fact, the name says it all. You use GET to retrieve information, to "get" the information out of the database. This typically happens with search engines, or when you want to see your profile (like when you subscribe to a forum).

When you want to insert or update information that is stored in a database, like when you want to change your profile or send an (web based) email, you use POST, meaning that you "post" information to the server.

As is told already, GET parameters and values are shown in the URL. This has the advantage that you can bookmark it. So you can copy the URL of a google-search, and mail it to someone else, and it works. You don't want to do this when you edit your profile, or submit a comment on a forum. Besides that, POST values like in a forum can be long texts, hundreds of lines, and you don't want that in the URL.

 

by: nplibPosted on 2007-12-10 at 12:29:00ID: 20444788

<form name="contact_form" id="contact_form" method="get" enctype="text/plain" action="response.php">
change to
<form name="contact_form" id="contact_form" method="post" enctype="text/plain" action="response.php">

 

by: nizsmoPosted on 2007-12-10 at 12:33:35ID: 20444833

Try this:

<form name="contact_form" id="contact_form" method="POST" action="test2.php">
                    <table width="98%" border="0" cellspacing="0" cellpadding="6">
                      <tr>
                        <td width="20%" align="left" valign="top">Name:</td>
                        <td width="80%" align="left" valign="top"><input name="customer_name" type="text" id="customer_name" size="50" maxlength="60"></td>
                      </tr>
                      <tr>
                        <td align="left" valign="top">Email Address:</td>
                        <td align="left" valign="top"><input name="customer_email" type="text" id="customer_email" size="50" maxlength="60"></td>
                      </tr>
                      <tr>
                        <td align="left" valign="top">Phone Number:</td>
                        <td align="left" valign="top"><input name="customer_phone" type="text" id="customer_phone" size="15" maxlength="15"></td>
                      </tr>
                      <tr>
                        <td colspan="2" align="left" valign="top"><img src="assets/spacerw.gif" width="1" height="12"></td>
                      </tr>
                      <tr>
                        <td colspan="2" align="left" valign="top"><p class="supplier_link">How may we be of assistance?</p>                        </td>
                      </tr>
                      <tr>
                        <td colspan="2" align="left" valign="top"><textarea name="customer_comment" id="customer_comment" cols="75" rows="5"></textarea></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td><input name="submit" type="submit" id="submit" onClick="MM_validateForm('customer_name','','R','customer_email','','R','customer_phone','','R','customer_comment','','R');return document.MM_returnValue" value="Submit Request">
                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <input type="reset" name="clear_form" id="clear_form" value="Clear Form"></td>
                      </tr>
                    </table>
          </form>   

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:

Select allOpen in new window

 

by: RosieisSweetPosted on 2007-12-10 at 12:38:13ID: 20444872

Okay. I went into the form and changed it to this:

        <form name="contact_form" id="contact_form" method="post" enctype="text/plain" action="response.php">
                    <table width="98%" border="0" cellspacing="0" cellpadding="6">
                      <tr>
                        <td width="20%" align="left" valign="top">Name:</td>
                        <td width="80%" align="left" valign="top"><input name="customer_name" type="text" id="customer_name" size="50" maxlength="60"></td>
                      </tr>
                      <tr>
                        <td align="left" valign="top">Email Address:</td>
                        <td align="left" valign="top"><input name="customer_email" type="text" id="customer_email" size="50" maxlength="60"></td>
                      </tr>
                      <tr>
                        <td align="left" valign="top">Phone Number:</td>
                        <td align="left" valign="top"><input name="customer_phone" type="text" id="customer_phone" size="15" maxlength="15"></td>
                      </tr>
                      <tr>
                        <td colspan="2" align="left" valign="top"><img src="assets/spacerw.gif" width="1" height="12"></td>
                      </tr>
                      <tr>
                        <td colspan="2" align="left" valign="top"><p class="supplier_link">How may we be of assistance?</p>                        </td>
                      </tr>
                      <tr>
                        <td colspan="2" align="left" valign="top"><textarea name="customer_comment" id="customer_comment" cols="75" rows="5"></textarea></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td><input name="submit" type="submit" id="submit" onClick="MM_validateForm('customer_name','','R','customer_email','','R','customer_phone','','R','customer_comment','','R');return document.MM_returnValue" value="Submit Request">
                        <input type="reset" name="clear_form" id="clear_form" value="Clear Form"></td>
                      </tr>
                    </table>
          </form>

And I changed the action form to this:

<?php
// variables
$customer_name = $_POST['customer_name'];
$from = $_POST['customer_email'];
$customer_phone = $_POST['customer_phone'];
$customer_comment = $_POST['customer_comment'];

//to and subject
$to = "rsweetsprint@earthlink.net";
$subject = "Customer Inquiry";

//message body
$message = '
         <html>
                  <head>
                  </head>
                        <body>
                              <table width="90%" border="0" cellspacing="0" cellpadding="3">
                      <tr>
                        <td width="15%" align="left" valign="top">Name:</td>
                        <td align="left" valign="top"><b>'.$customer_name.'</b></td>
                      </tr>
                      <tr>
                        <td width="15%" align="left" valign="top">Email Address:</td>
                        <td align="left" valign="top"><b>'.$from.'</b></td>
                      </tr>
                      <tr>
                        <td width="15%" align="left" valign="top">Phone Number:</td>
                        <td align="left" valign="top"><b>'.$customer_phone.'</b><br></td>
                      </tr>
                      <tr>
                        <td colspan="2"><h2>How may we be of assistance?</h2></td>
                      </tr>
                      <tr>
                        <td colspan="2"><p>'.$customer_comment.'</p></td>
                      </tr>
                    </table>
                        </body>
            </html>
';

//make sure text wraps if it is to long
$message = wordwrap($message, 70);

//set html content type
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' .$from. "\r\n";

mail($to, $subject, $message, $headers);
?>

Now when I submit the form all the information areas (the variables) come up empty. What am I missing here?

 

by: nizsmoPosted on 2007-12-10 at 12:49:03ID: 20444979

remove:
enctype="text/plain"

and try again.

 

by: RosieisSweetPosted on 2007-12-10 at 12:58:20ID: 20445067

Thank you so much for your patience with me nizsmo. I removed the enctype="text/plain" and retested. The mail still returns with blank information. Do you have any other suggestions?

 

by: nizsmoPosted on 2007-12-10 at 13:00:42ID: 20445090

hmm thats weird, i removed enctype, then change the method to POST, and tried:

<?php
echo $_POST["customer_email"];
?>

and it echo's out the correct value?

 

by: RosieisSweetPosted on 2007-12-10 at 13:07:31ID: 20445156

Do I need to put the word echo into my response?

As in change from :
<td align="left" valign="top"><b>'.$customer_name.'</b></td>
To:
<td align="left" valign="top"><b> echo $_POST["customer_name"]</b></td>

 

by: RosieisSweetPosted on 2007-12-10 at 13:31:38ID: 20445370

Okay I tried changing the line to:

<td align="left" valign="top"><b>'. $_POST["customer_name"] .'</b></td>

thereby eliminating the variable but still the same result. What am I missing that it works with GET but not POST?

 

by: HeroGuranPosted on 2007-12-11 at 02:02:31ID: 20448224

Try removing the following rows in your HTML.
I got a result without them and apparently there is something wrong there.

<tr>
<td colspan="2" align="left" valign="top"><img src="assets/spacerw.gif" width="1" height="12"></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top"><p class="supplier_link">How may we be of assistance?</p> </td>
</tr>

                                              
1:
2:
3:
4:
5:
6:

Select allOpen in new window

 

by: HeroGuranPosted on 2007-12-11 at 02:13:51ID: 20448267

Here's my form file. I removes some validation etc on the form. So try adding that.. After you see if it works.

<html>
<body>
<form name="contact_form" id="contact_form" method="post" action="response.php">
<table width="98%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td width="20%" align="left" valign="top">Name:</td>
<td width="80%" align="left" valign="top"><input name="customer_name" type="text" id="customer_name" size="50" maxlength="60"></td>
</tr>
<tr>
<td align="left" valign="top">Email Address:</td>
<td align="left" valign="top"><input name="customer_email" type="text" id="customer_email" size="50" maxlength="60"></td>
</tr>
<tr>
<td align="left" valign="top">Phone Number:</td>
<td align="left" valign="top"><input name="customer_phone" type="text" id="customer_phone" size="15" maxlength="15"></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top"><img src="assets/spacerw.gif" width="1" height="12"></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top"><p class="supplier_link">How may we be of assistance?</p> </td>
</tr>
<tr>
<td colspan="2" align="left" valign="top"><textarea name="customer_comment" id="customer_comment" cols="75" rows="5"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" value="Submit Request"></td>
</tr>
</table>
</form>
</body>
</html>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:

Select allOpen in new window

 

by: RosieisSweetPosted on 2007-12-11 at 11:26:31ID: 20451847

Thank you HeroGuran but it still is working only with GET and not POST. I welcome any help I can get on this. Than you to everyone who has given me assistance.

 

by: nplibPosted on 2007-12-11 at 12:31:35ID: 20452448

Post your current code, with the modifications, there must be something over looked.

 

by: RosieisSweetPosted on 2007-12-11 at 23:30:26ID: 20455626

Here is the current form code:

<form name="contact_form" id="contact_form" method="post" action="responsetest.php">
<table width="98%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td width="20%" align="left" valign="top">Name:</td>
<td width="80%" align="left" valign="top"><input name="customer_name" type="text" id="customer_name" size="50" maxlength="60"></td>
</tr>
<tr>
<td align="left" valign="top">Email Address:</td>
<td align="left" valign="top"><input name="customer_email" type="text" id="customer_email" size="50" maxlength="60"></td>
</tr>
<tr>
<td align="left" valign="top">Phone Number:</td>
<td align="left" valign="top"><input name="customer_phone" type="text" id="customer_phone" size="15" maxlength="15"></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top"><img src="assets/spacerw.gif" width="1" height="12"></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top"><p class="supplier_link">How may we be of assistance?</p> </td>
</tr>
<tr>
<td colspan="2" align="left" valign="top"><textarea name="customer_comment" id="customer_comment" cols="75" rows="5"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" value="Submit Request"></td>
</tr>
</table>
</form>

Here is the code from the action page:

<?php
// variables
$cust_name = $_POST['cust_name'];
$from = $_POST['cust_email'];
$cust_phone = $_POST['cust_phone'];
$cust_comment = $_POST['cust_comment'];

//to and subject
$to = "ozzie@bclean.com";
$subject = "Customer Inquiry";

//message body
$message = '
         <html>
                  <head>
                  </head>
                        <body>
                              <table width="90%" border="0" cellspacing="0" cellpadding="3">
                      <tr>
                        <td width="15%" align="left" valign="top">Name:</td>
                        <td align="left" valign="top"><b>'.$cust_name.'</b></td>
                      </tr>
                      <tr>
                        <td width="15%" align="left" valign="top">Email Address:</td>
                        <td align="left" valign="top"><b>'.$from.'</b></td>
                      </tr>
                      <tr>
                        <td width="15%" align="left" valign="top">Phone Number:</td>
                        <td align="left" valign="top"><b>'.$cust_phone.'</b><br></td>
                      </tr>
                      <tr>
                        <td colspan="2"><h2>How may we be of assistance?</h2></td>
                      </tr>
                      <tr>
                        <td colspan="2"><p>'.$cust_comment.'</p></td>
                      </tr>
                    </table>
                        </body>
            </html>
';

//make sure text wraps if it is to long
$message = wordwrap($message, 70);

//set html content type
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' .$from. "\r\n";

mail($to, $subject, $message, $headers);
?>

These of course are each part of a standard html page. Do you need the code for the entire form and action page including the html frame?

 

by: HeroGuranPosted on 2007-12-12 at 03:30:10ID: 20456345

Your code works fine for me.
I use the file response below and get the message printed correctly.

If you still have problems. Try using "print_r($_POST);" in response.php. There you can see what's in there. Second, remove the action on the form, which will set the target page to itself. Then do a "print_r($_POST);" on that page to. That might give a picture of what gets passed and where it goes wrong..

I pasted my response file below to.

<?
// variables
$customer_name = $_POST['customer_name'];
$from = $_POST['customer_email'];
$customer_phone = $_POST['customer_phone'];
$customer_comment = $_POST['customer_comment'];
//to and subject
$to = "rsweetsprint@earthlink.net";
$subject = "Customer Inquiry";
 
//message body
$message = '
<html>
<head>
</head>
<body>
<table width="90%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="15%" align="left" valign="top">Name:</td>
<td align="left" valign="top"><b>'.$customer_name.'</b></td>
</tr>
<tr>
<td width="15%" align="left" valign="top">Email Address:</td>
<td align="left" valign="top"><b>'.$from.'</b></td>
</tr>
<tr>
<td width="15%" align="left" valign="top">Phone Number:</td>
<td align="left" valign="top"><b>'.$customer_phone.'</b><br></td>
</tr>
<tr>
<td colspan="2"><h2>How may we be of assistance?</h2></td>
</tr>
<tr>
<td colspan="2"><p>'.$customer_comment.'</p></td>
</tr>
</table>
</body>
</html>
';
print $message;
 
//make sure text wraps if it is to long
$message = wordwrap($message, 70);
 
//set html content type
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' .$from. "\r\n";
 
//mail($to, $subject, $message, $headers);
 
?>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:

Select allOpen in new window

 

by: RosieisSweetPosted on 2007-12-12 at 07:10:59ID: 20457457

I run on a server from another company. Is it possible that they have a setting of some sort turned off?

 

by: HeroGuranPosted on 2007-12-12 at 07:27:19ID: 20457557

Yes, it is possible, but you should get a warning then.
Running the following should determinte wether there is a $_post array available:
if(isset($_POST)
  print "I'm here";
else
  print "I'm not here, doh!";

Regards,
Andreas

 

by: HeroGuranPosted on 2007-12-12 at 07:28:46ID: 20457563

Missed a parenthesis there.

if(isset($_POST))
  print "I'm here";
else
  print "I'm not here, doh!";

                                              
1:
2:
3:
4:

Select allOpen in new window

 

by: HeroGuranPosted on 2007-12-12 at 07:35:02ID: 20457595

 

by: nplibPosted on 2007-12-13 at 07:18:52ID: 20464776

in the code you posted just recently
your $_POST variables don't match your input names
for example

<input name="customer_name" type="text" id="customer_name" size="50" maxlength="60">
$cust_name = $_POST['cust_name'];
this will never work
your $_POST variables must match your input, select, or textarea names like this

<input name="customer_name" type="text" id="customer_name" size="50" maxlength="60">
$cust_name = $_POST['customer_name'];

 

by: RosieisSweetPosted on 2007-12-14 at 12:13:49ID: 20474115

I am sorry about that. I picked up an incorrect file when I posted. Here is the correct form file.

<form name="contact_form" id="contact_form" method="post" action="responsetest.php">
<table width="98%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td width="20%" align="left" valign="top">Name:</td>
<td width="80%" align="left" valign="top"><input name="cust_name" type="text" id="cust_name" size="50" maxlength="60"></td>
</tr>
<tr>
<td align="left" valign="top">Email Address:</td>
<td align="left" valign="top"><input name="cust_email" type="text" id="cust_email" size="50" maxlength="60"></td>
</tr>
<tr>
<td align="left" valign="top">Phone Number:</td>
<td align="left" valign="top"><input name="cust_phone" type="text" id="cust_phone" size="15" maxlength="15"></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top"><img src="assets/spacerw.gif" width="1" height="12"></td>
</tr>
<tr>
<td colspan="2" align="left" valign="top"><p class="supplier_link">How may we be of assistance?</p> </td>
</tr>
<tr>
<td colspan="2" align="left" valign="top"><textarea name="cust_comment" id="cust_comment" cols="75" rows="5"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" value="Submit Request"></td>
</tr>
</table>
</form>

And the correct response file.

<?php
// variables
$cust_name = $_POST['cust_name'];
$from = $_POST['cust_email'];
$cust_phone = $_POST['cust_phone'];
$cust_comment = $_POST['cust_comment'];

//to and subject
$to = "ozzie@bclean.com";
$subject = "Customer Inquiry";

//message body
$message = '
         <html>
                  <head>
                  </head>
                        <body>
                              <table width="90%" border="0" cellspacing="0" cellpadding="3">
                      <tr>
                        <td width="15%" align="left" valign="top">Name:</td>
                        <td align="left" valign="top"><b>'.$cust_name.'</b></td>
                      </tr>
                      <tr>
                        <td width="15%" align="left" valign="top">Email Address:</td>
                        <td align="left" valign="top"><b>'.$from.'</b></td>
                      </tr>
                      <tr>
                        <td width="15%" align="left" valign="top">Phone Number:</td>
                        <td align="left" valign="top"><b>'.$cust_phone.'</b><br></td>
                      </tr>
                      <tr>
                        <td colspan="2"><h2>How may we be of assistance?</h2></td>
                      </tr>
                      <tr>
                        <td colspan="2"><p>'.$cust_comment.'</p></td>
                      </tr>
                    </table>
                        </body>
            </html>
';

//make sure text wraps if it is to long
$message = wordwrap($message, 70);

//set html content type
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' .$from. "\r\n";

mail($to, $subject, $message, $headers);
?>

I have contacted the support group at my server company and sent them the link that HeroGuran posted. I am waiting for a response from them to see if this issue is based on their server settings.

Thank you all for your patience and assistance. I will post as  soon as I get a response from them.

 

by: RosieisSweetPosted on 2007-12-16 at 11:20:53ID: 31414002

I would sincerely like ot thank everyone that helped. While the issue of the server settings played a part in the problem, the technician at the company was able to add a line of code to my file that made it run correctly.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...