Actually this gives an error that the required fields are empty. When I remove the code that checks the required fields, then it sends no data. I'm assuming that if it sent any data then the required fields would not be empty.
This is my process.php:
<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','First_name');
pt_register('POST','Last_name');
pt_register('POST','First_name_on_badge');
pt_register('POST','Organization');
pt_register('POST','Mailing_Address');
$Mailing_Address=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $Mailing_Address);
pt_register('POST','Phone_Number');
pt_register('POST','Email_Address');
pt_register('POST','Lunch_Preference');
pt_register('POST','Dietary_restrictions_or_concerns');
pt_register('POST','Basic_videorecordings');
pt_register('POST','Advanced_videorecordings');
pt_register('POST','New_video_formats');
pt_register('POST','Streaming_video');
pt_register('POST','Realia');
pt_register('POST','Archival_materials');
pt_register('POST','Basic_sound_recordings');
pt_register('POST','Advanced_sound_recordings');
pt_register('POST','Form_and_genre_headings');
pt_register('POST','Graphic_materials');
pt_register('POST','Electronic_resources');
pt_register('POST','Ebooks');
if($First_name=="" || $Last_name=="" || $Email_Address=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="First name: ".$First_name."
Last name: ".$Last_name."
First name to appear on badge: ".$First_name_on_badge."
Organization: ".$Organization."
Mailing Address: ".$Mailing_Address."
Phone Number: ".$Phone_Number."
Email Address: ".$Email_Address."
Lunch Preference: ".$Lunch_Preference."
Dietary restrictions or concerns: ".$Dietary_restrictions_or_concerns."
Basic videorecordings: ".$Basic_videorecordings."
Advanced videorecordings: ".$Advanced_videorecordings."
New video formats: ".$New_video_formats."
Streaming video: ".$Streaming_video."
Realia: ".$Realia."
Archival materials: ".$Archival_materials."
Basic sound recordings: ".$Basic_sound_recordings."
Advanced sound recordings: ".$Advanced_sound_recordings."
Form and genre headings: ".$Form_and_genre_headings."
Graphic materials: ".$Graphic_materials."
Electronic resources: ".$Electronic_resources."
Ebooks: ".$Ebooks."
";
$message = stripslashes($message);
mail("chittenden_l@fortlewis.edu","Form Submitted at your website",$message,"From: phpFormGenerator");
It all looks good so I don't know eactly what your issue is. My guess would be that there is some server setting that requires a different method of handling POST variables.
Try this change:
Example:
change
$message="First name: ".$First_name."
Last name: ".$Last_name."
to
$message="First name: ".$_POST."
Last name: ".$_POST."
and you can eliminate:
pt_register('POST','First_name');
pt_register('POST','Last_name');
You will also want to change
if($_POST=="" || $_POST=="" || $Email_Address=="" ){
to
if($First_name=="" || $Last_name=="" || $Email_Address=="" ){
If this works change all other variables in the same way.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I also have a question about permissions. The readme file that I saw said to set file permissions to 777, but my host says they should be 644. In fact, they won't allow any script to work when the file has permissions of 777. Could that be my problem? My permissions are set to 644.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It is now sending an email with data. I tested the method that tnteveret1 suggested. It still claims that the required fields have no data when they do. So I tried removing the validation code. I also removed the whole mailing address line, because I don't know how to deal with a text area. It is sending data. I still have a couple of problems.
How should the text area line look? It used to have this line in the pt_register part that is now gone:
$MailingAddress=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $MailingAddress);pt_register('POST','PhoneNumber');
Do I need that?
Also another problem. The output email is a little weird. This is what it sends:
First name: Lloyd
Last name: Chittenden
First name to appear on badge: Hank
Organization: Fort Lewis College
Phone Number: 9706548778
Email Address: chittenden_l@fortlewis.edu Lunch Preference: Pork Dietary restrictions or concerns: None Basic videorecordings: 1 Advanced videorecordings: 1 New video formats: 3 Streaming video: 2
Realia: 3
Archival materials: 6
Basic sound recordings: 2
Advanced sound recordings: 3
Form and genre headings: 1
Graphic materials: 2
Electronic resources: -
Ebooks: -
There are now breaks after email address and for the next 6 or 7 fields, then there are breaks again. How do I fix that?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The mesage is sent as text so the preg_replace on the Mailing Address is not necessarily appropriate. There are multiple ways to handle the email but for this basic problem just remove or comment out the line:
"$Mailing_Address=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $Mailing_Address);"
and this should solve your problem.
It is actually a better practice to clean all but the exact string entered into the form and then add CRLF back to the message if and where necessary.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for your help tnteveret1. It's working now. I just added a blank line in the php file after the email line and that transferred into the message, and for some reason the rest of the breaks came out correctly.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I realized I first posted this in the wrong place. Sorry.
I'm trying to use PHPFormGenerator for the first time. I do not know PHP. I'm using version 2.09, which is what my host provides.
The problem is that the form sends an email, but the email only contains the field labels, no data. It looks like this:
First name:
Last name:
First name to appear on badge:
Organization:
Mailing Address:
Phone Number:
Email Address:
etc.
Here is my form:
<HTML><HEAD><TITLE>My Form - created with phpFormGenerator</TITLE></HEAD>
<BODY>
<font face='arial' size=2><b>All fields marked with a * are required:<br>
<form enctype='multipart/form-data' action='process.php' method='post'>
<table width='50%' border=0>
<tr><td> First name<font color='#ff0000'>*</font></td>
<td>
<input type=text name='First_name' size=40></td></tr>
<tr><td> Last name<font color='#ff0000'>*</font></td>
<td>
<input type=text name='Last_name' size=40></td></tr>
<tr><td> First name on badge</td>
<td>
<input type=text name='First_name_on_badge' size=40></td></tr>
<tr><td> Organization</td>
<td>
<input type=text name='Organization' size=50></td></tr>
<tr><td> Mailing Address</td>
<td>
<textarea name='Mailing_Address' rows=4 cols=50></textarea></td></tr>
<tr><td> Phone Number</td>
<td>
<input type=text name='Phone_Number' size=15></td></tr>
<tr><td> Email Address<font color='#ff0000'>*</font></td>
<td>
<input type=email name='Email_Address' size=40></td></tr>
<tr><td> Lunch Preference</td>
<td>
<input type=radio name='Lunch_Preference' value='Chicken'>Chicken<br><input type=radio name='Lunch_Preference' value='Pork'>Pork<br><input type=radio name='Lunch_Preference' value='Vegetarian'>Vegetarian<br></td></tr>
<tr><td> Dietary restrictions or concerns</td>
<td>
<input type=text name='Dietary_restrictions_or_concerns' size=40></td></tr>
<tr><td> Basic videorecordings</td>
<td>
<select name='Basic_videorecordings'><option value='-'>-<option value='1'>1<option value='2'>2<option value='3'>3<option value='4'>4<option value='5'>5<option value='6'>6<option value='7'>7<option value='8'>8</select></td></tr>
<tr><td> Advanced videorecordings</td>
<td>
<select name='Advanced_videorecordings'><option value='-'>-<option value='1'>1<option value='2'>2<option value='3'>3<option value='4'>4<option value='5'>5<option value='6'>6<option value='7'>7<option value='8'>8</select></td></tr>
<tr><td> New video formats</td>
<td>
<select name='New_video_formats'><option value='-'>-<option value='1'>1<option value='2'>2<option value='3'>3<option value='4'>4<option value='5'>5<option value='6'>6<option value='7'>7<option value='8'>8</select></td></tr>
<tr><td> Streaming video</td>
<td>
<select name='Streaming_video'><option value='-'>-<option value='1'>1<option value='2'>2<option value='3'>3<option value='4'>4<option value='5'>5<option value='6'>6<option value='7'>7<option value='8'>8</select></td></tr>
<tr><td> Realia</td>
<td>
<select name='Realia'><option value='-'>-<option value='1'>1<option value='2'>2<option value='3'>3<option value='4'>4<option value='5'>5<option value='6'>6<option value='7'>7<option value='8'>8</select></td></tr>
<tr><td> Archival materials</td>
<td>
<select name='Archival_materials'><option value='-'>-<option value='1'>1<option value='2'>2<option value='3'>3<option value='4'>4<option value='5'>5<option value='6'>6<option value='7'>7<option value='8'>8</select></td></tr>
<tr><td> Basic sound recordings</td>
<td>
<select name='Basic_sound_recordings'><option value='-'>-<option value='1'>1<option value='2'>2<option value='3'>3<option value='4'>4<option value='5'>5<option value='6'>6<option value='7'>7<option value='8'>8</select></td></tr>
<tr><td> Advanced sound recordings</td>
<td>
<select name='Advanced_sound_recordings'><option value='-'>-<option value='1'>1<option value='2'>2<option value='3'>3<option value='4'>4<option value='5'>5<option value='6'>6<option value='7'>7<option value='8'>8</select></td></tr>
<tr><td> Form and genre headings</td>
<td>
<select name='Form_and_genre_headings'><option value='-'>-<option value='1'>1<option value='2'>2<option value='3'>3<option value='4'>4<option value='5'>5<option value='6'>6<option value='7'>7<option value='8'>8</select></td></tr>
<tr><td> Graphic materials</td>
<td>
<select name='Graphic_materials'><option value='-'>-<option value='1'>1<option value='2'>2<option value='3'>3<option value='4'>4<option value='5'>5<option value='6'>6<option value='7'>7<option value='8'>8</select></td></tr>
<tr><td> Electronic resources</td>
<td>
<select name='Electronic_resources'><option value='-'>-<option value='1'>1<option value='2'>2<option value='3'>3<option value='4'>4<option value='5'>5<option value='6'>6<option value='7'>7<option value='8'>8</select></td></tr>
<tr><td> Ebooks</td>
<td>
<select name='Ebooks'><option value='-'>-<option value='1'>1<option value='2'>2<option value='3'>3<option value='4'>4<option value='5'>5<option value='6'>6<option value='7'>7<option value='8'>8</select></td></tr>
</table>
<input type='submit' value='Submit Form'> <input type=reset value='Clear Form'></form>
<br><br><br><a href='http://phpformgen.sourceforge.net'><img src='button.jpg' border=0></a>
</BODY></HTML>
Actually this gives an error that the required fields are empty. When I remove the code that checks the required fields, then it sends no data. I'm assuming that if it sent any data then the required fields would not be empty.
This is my process.php:
<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','First_name');
pt_register('POST','Last_name');
pt_register('POST','First_name_on_badge');
pt_register('POST','Organization');
pt_register('POST','Mailing_Address');
$Mailing_Address=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $Mailing_Address);
pt_register('POST','Phone_Number');
pt_register('POST','Email_Address');
pt_register('POST','Lunch_Preference');
pt_register('POST','Dietary_restrictions_or_concerns');
pt_register('POST','Basic_videorecordings');
pt_register('POST','Advanced_videorecordings');
pt_register('POST','New_video_formats');
pt_register('POST','Streaming_video');
pt_register('POST','Realia');
pt_register('POST','Archival_materials');
pt_register('POST','Basic_sound_recordings');
pt_register('POST','Advanced_sound_recordings');
pt_register('POST','Form_and_genre_headings');
pt_register('POST','Graphic_materials');
pt_register('POST','Electronic_resources');
pt_register('POST','Ebooks');
if($First_name=="" || $Last_name=="" || $Email_Address=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="First name: ".$First_name."
Last name: ".$Last_name."
First name to appear on badge: ".$First_name_on_badge."
Organization: ".$Organization."
Mailing Address: ".$Mailing_Address."
Phone Number: ".$Phone_Number."
Email Address: ".$Email_Address."
Lunch Preference: ".$Lunch_Preference."
Dietary restrictions or concerns: ".$Dietary_restrictions_or_concerns."
Basic videorecordings: ".$Basic_videorecordings."
Advanced videorecordings: ".$Advanced_videorecordings."
New video formats: ".$New_video_formats."
Streaming video: ".$Streaming_video."
Realia: ".$Realia."
Archival materials: ".$Archival_materials."
Basic sound recordings: ".$Basic_sound_recordings."
Advanced sound recordings: ".$Advanced_sound_recordings."
Form and genre headings: ".$Form_and_genre_headings."
Graphic materials: ".$Graphic_materials."
Electronic resources: ".$Electronic_resources."
Ebooks: ".$Ebooks."
";
$message = stripslashes($message);
mail("chittenden_l@fortlewis.edu","Form Submitted at your website",$message,"From: phpFormGenerator");
header("Refresh: 0;url=http://www.olacinc.org/drupal/conference/2010/Payment.html");
?><?php
}
?>
It all looks good so I don't know eactly what your issue is. My guess would be that there is some server setting that requires a different method of handling POST variables.
Try this change:
Example:
change
$message="First name: ".$First_name."
Last name: ".$Last_name."
to
$message="First name: ".$_POST."
Last name: ".$_POST."
and you can eliminate:
pt_register('POST','First_name');
pt_register('POST','Last_name');
You will also want to change
if($_POST=="" || $_POST=="" || $Email_Address=="" ){
to
if($First_name=="" || $Last_name=="" || $Email_Address=="" ){
If this works change all other variables in the same way.
OK, I'll try that, but I have some questions. You seem to deal with the first and last name field differently.
$message="First name: ".$_POST." Last name: ".$_POST."
Shouldn't it be $message="First name: ".$_POST." Last name: ".$_POST."
Or
$message="First name: ".$_POST." Last name: ".$_POST."?
Also, the mailing address field is a text area, and the line for that is completely different. How would that look in this new method?
I also have a question about permissions. The readme file that I saw said to set file permissions to 777, but my host says they should be 644. In fact, they won't allow any script to work when the file has permissions of 777. Could that be my problem? My permissions are set to 644.
I GOT IT WORKING!!!
It is now sending an email with data. I tested the method that tnteveret1 suggested. It still claims that the required fields have no data when they do. So I tried removing the validation code. I also removed the whole mailing address line, because I don't know how to deal with a text area. It is sending data. I still have a couple of problems.
How should the text area line look? It used to have this line in the pt_register part that is now gone:
$MailingAddress=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $MailingAddress);pt_register('POST','PhoneNumber');
Do I need that?
Also another problem. The output email is a little weird. This is what it sends:
First name: Lloyd
Last name: Chittenden
First name to appear on badge: Hank
Organization: Fort Lewis College
Phone Number: 9706548778
Email Address: chittenden_l@fortlewis.edu Lunch Preference: Pork Dietary restrictions or concerns: None Basic videorecordings: 1 Advanced videorecordings: 1 New video formats: 3 Streaming video: 2
Realia: 3
Archival materials: 6
Basic sound recordings: 2
Advanced sound recordings: 3
Form and genre headings: 1
Graphic materials: 2
Electronic resources: -
Ebooks: -
There are now breaks after email address and for the next 6 or 7 fields, then there are breaks again. How do I fix that?
OK, I added mailing address back in and it works. I guess that was never a problem. Now I don't know about the breaks in the final email.
Setting permissions to 664 is a good idea and it should still work.
The mesage is sent as text so the preg_replace on the Mailing Address is not necessarily appropriate. There are multiple ways to handle the email but for this basic problem just remove or comment out the line:
"$Mailing_Address=preg_replace("/(\015\012)|(\015)|(\012)/"," <br />", $Mailing_Address);"
and this should solve your problem.
It is actually a better practice to clean all but the exact string entered into the form and then add CRLF back to the message if and where necessary.
Thanks for your help tnteveret1. It's working now. I just added a blank line in the php file after the email line and that transferred into the message, and for some reason the rest of the breaks came out correctly.