PHP Help on Site
Posted: Sat Nov 08, 2008 2:24 am
Hello Everyone. I am new on these boards, and new to PHP. I am in a bit of a dilema. I created a site for a church, i which on one page, they want a user to be able to contact them using a form. This form includes their Name, Phone, Email, Comment Type, and Comment. After the user clicks submit, they would like the information from the form to be emailed to them. I am unsure how I do this using PHP. The site is hosted through godaddy.com and is on a Linux server. Godaddy supplies a PHP file, but I cant make anything of it. I am attaching the coding for the form, as well as the file godaddy supplies. I assume I have to use the coding in it somehow. Thanks for your help! If you would like to visit the site where the form is located, you can do so at: http://stpmbcchicago.com/pages/Contact.html
Also, I know the form method and action are left blank. I purposely did that, to prevent an error from occurring if someone did try to use the form.
//Form Code
<form method="" action="" id="Contact" name="Contact">
<table width="688" height="304" border="0" align="center" cellpadding="0" cellspacing="0" id="FormLayout">
<tr>
<td height="64" colspan="2" valign="middle" bgcolor="#FFFFFF"><blockquote>
<p class="style27"><strong>Please use the form below to send your prayer request praise report, meeting request, or website comments and we will direct it to the appropriate person.</strong></p>
</blockquote></td>
</tr>
<tr>
<td width="129" height="26" align="right" bgcolor="#FFFFFF"><label for="Name" class="style27">Name</label>:</td>
<td width="559" align="left" bgcolor="#FFFFFF"><span id="sprytextfield1">
<input type="text" name="Name" id="Name" />
</span></td>
</tr>
<tr align="right">
<td height="25" align="right" bgcolor="#FFFFFF"><label for="Email" class="style27">*Email:</label></td>
<td align="left" bgcolor="#FFFFFF"><span id="sprytextfield2">
<input type="text" name="Email" id="Email" />
</span></td>
</tr>
<tr>
<td height="25" align="right" bgcolor="#FFFFFF"><label for="Phone" class="style27">*Phone:</label></td>
<td align="left" bgcolor="#FFFFFF"><span id="sprytextfield3">
<input type="text" name="Phone" id="Phone" />
</span></td>
</tr>
<tr align="right">
<td height="26" align="right" bgcolor="#FFFFFF"><label for="Type" class="style27">Type:</label></td>
<td align="left" bgcolor="#FFFFFF"><span id="spryselect1">
<select name="Type" id="Type">
<option>Please Select A Type:</option>
<option value="Prayer">Prayer Request</option>
<option value="Praise">Praise Report</option>
<option value="Website">Website Comment</option>
</select>
</span></td>
</tr>
<tr>
<td align="right" valign="top" bgcolor="#FFFFFF"><label for="Comment" class="style27">Comments:</label></td>
<td align="left" valign="top" bgcolor="#FFFFFF"><span id="sprytextarea1">
<textarea name="Comment" id="Comment" cols="45" rows="5"></textarea>
</span></td>
</tr>
<tr>
<td height="27" align="right" bgcolor="#FFFFFF"> </td>
<td height="27" align="left" bgcolor="#FFFFFF"><input type="submit" name="button" id="button" value="Submit" /></td>
</tr>
<tr>
<td height="8" align="right" bgcolor="#FFFFFF"> </td>
<td height="8" align="left" bgcolor="#FFFFFF"><span class="style27">* optional</span></td>
</tr>
<tr>
<td height="9" colspan="2" align="right" bgcolor="#FFFFFF"> </td>
</tr>
</table>
</form>
//Godaddy PHP File
<?php
$request_method = $_SERVER["REQUEST_METHOD"];
if($request_method == "GET"){
$query_vars = $_GET;
} elseif ($request_method == "POST"){
$query_vars = $_POST;
}
reset($query_vars);
$t = date("U");
$file = $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" . $t;
$fp = fopen($file,"w");
while (list ($key, $val) = each ($query_vars)) {
fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
fputs($fp,"$val\n");
fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");
if ($key == "redirect") { $landing_page = $val;}
}
fclose($fp);
if ($landing_page != ""){
header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
} else {
header("Location: http://".$_SERVER["HTTP_HOST"]."/");
}
?>
//Godaddy PHP.ini file
register_globals = off
allow_url_fopen = off
expose_php = Off
max_input_time = 60
variables_order = "EGPCS"
extension_dir = ./
upload_tmp_dir = /tmp
precision = 12
SMTP = relay-hosting.secureserver.net
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="
[Zend]
zend_extension=/usr/local/zo/ZendExtensionManager.so
zend_extension=/usr/local/zo/4_3/ZendOptimizer.so
Also, I know the form method and action are left blank. I purposely did that, to prevent an error from occurring if someone did try to use the form.
//Form Code
<form method="" action="" id="Contact" name="Contact">
<table width="688" height="304" border="0" align="center" cellpadding="0" cellspacing="0" id="FormLayout">
<tr>
<td height="64" colspan="2" valign="middle" bgcolor="#FFFFFF"><blockquote>
<p class="style27"><strong>Please use the form below to send your prayer request praise report, meeting request, or website comments and we will direct it to the appropriate person.</strong></p>
</blockquote></td>
</tr>
<tr>
<td width="129" height="26" align="right" bgcolor="#FFFFFF"><label for="Name" class="style27">Name</label>:</td>
<td width="559" align="left" bgcolor="#FFFFFF"><span id="sprytextfield1">
<input type="text" name="Name" id="Name" />
</span></td>
</tr>
<tr align="right">
<td height="25" align="right" bgcolor="#FFFFFF"><label for="Email" class="style27">*Email:</label></td>
<td align="left" bgcolor="#FFFFFF"><span id="sprytextfield2">
<input type="text" name="Email" id="Email" />
</span></td>
</tr>
<tr>
<td height="25" align="right" bgcolor="#FFFFFF"><label for="Phone" class="style27">*Phone:</label></td>
<td align="left" bgcolor="#FFFFFF"><span id="sprytextfield3">
<input type="text" name="Phone" id="Phone" />
</span></td>
</tr>
<tr align="right">
<td height="26" align="right" bgcolor="#FFFFFF"><label for="Type" class="style27">Type:</label></td>
<td align="left" bgcolor="#FFFFFF"><span id="spryselect1">
<select name="Type" id="Type">
<option>Please Select A Type:</option>
<option value="Prayer">Prayer Request</option>
<option value="Praise">Praise Report</option>
<option value="Website">Website Comment</option>
</select>
</span></td>
</tr>
<tr>
<td align="right" valign="top" bgcolor="#FFFFFF"><label for="Comment" class="style27">Comments:</label></td>
<td align="left" valign="top" bgcolor="#FFFFFF"><span id="sprytextarea1">
<textarea name="Comment" id="Comment" cols="45" rows="5"></textarea>
</span></td>
</tr>
<tr>
<td height="27" align="right" bgcolor="#FFFFFF"> </td>
<td height="27" align="left" bgcolor="#FFFFFF"><input type="submit" name="button" id="button" value="Submit" /></td>
</tr>
<tr>
<td height="8" align="right" bgcolor="#FFFFFF"> </td>
<td height="8" align="left" bgcolor="#FFFFFF"><span class="style27">* optional</span></td>
</tr>
<tr>
<td height="9" colspan="2" align="right" bgcolor="#FFFFFF"> </td>
</tr>
</table>
</form>
//Godaddy PHP File
<?php
$request_method = $_SERVER["REQUEST_METHOD"];
if($request_method == "GET"){
$query_vars = $_GET;
} elseif ($request_method == "POST"){
$query_vars = $_POST;
}
reset($query_vars);
$t = date("U");
$file = $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" . $t;
$fp = fopen($file,"w");
while (list ($key, $val) = each ($query_vars)) {
fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
fputs($fp,"$val\n");
fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");
if ($key == "redirect") { $landing_page = $val;}
}
fclose($fp);
if ($landing_page != ""){
header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
} else {
header("Location: http://".$_SERVER["HTTP_HOST"]."/");
}
?>
//Godaddy PHP.ini file
register_globals = off
allow_url_fopen = off
expose_php = Off
max_input_time = 60
variables_order = "EGPCS"
extension_dir = ./
upload_tmp_dir = /tmp
precision = 12
SMTP = relay-hosting.secureserver.net
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="
[Zend]
zend_extension=/usr/local/zo/ZendExtensionManager.so
zend_extension=/usr/local/zo/4_3/ZendOptimizer.so