PDA

View Full Version : Contact Form


jessa
02-06-2009, 12:24 AM
I've never made a contact form before and I'm trying to follow the code I found online. The submission is not actually reaching my email. You can view the form on my testing server at: http://deptart2.memphis.edu/~jwilcoxen/web_portfolio/home.php . Click on contact. Here is the raw code:


</div>
<div class="AccordionPanel">
<div class="AccordionPanelTab">contact</div>
<div class="AccordionPanelContent">
<div id="accordian_textholder">
<form action="send_results.php" method="post" enctype="text/plain" name="contact_form" id="contact_form">
<table width="860" border="0" cellpadding="4">
<tr>
<td width="130">name*</td>
<td width="194"><span id="sprytextfield1">
<label>
<input type="text" name="name" id="name2" />
</label>
<span class="textfieldRequiredMsg">A value is required.</span></span> </td>
<td width="27">&nbsp;</td>
<td width="193">project description</td>
<td width="264"><span id="sprytextarea2">
<label>
<textarea name="project" id="project" cols="30" rows="4"></textarea>
</label>
</span> </td>
</tr>
<tr>
<td>company name</td>
<td><span id="sprytextfield2">
<label>
<input type="text" name="company_name" id="company_name" />
</label>
</span> </td>
<td width="27">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>e-mail address*</td>
<td><span id="sprytextfield3">
<label>
<input type="text" name="email " id="email " />
</label>
<span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span> </td>
<td width="27">&nbsp;</td>
<td>how did you hear about creative spark?</td>
<td><span id="sprytextarea3">
<label>
<textarea name="hear_about" id="hear_about" cols="30" rows="4"></textarea>
</label>
</span> </td>
</tr>
<tr>
<td>phone number</td>
<td><span id="sprytextfield4">
<label>
<input type="text" name="phone" id="phone" />
</label>
</span> </td>
<td width="27">&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>best method to reach you</td>
<td><span id="spryselect1">
<label>
<select name="email_phone" id="email_phone">
<option selected="selected">email</option>
<option>phone</option>
</select>
</label>
</span></td>
<td width="27">&nbsp;</td>
<td>&nbsp;</td>
<td><label>
<input type="submit" name="submit" id="submit" value="send request" />
</label>
</td>
</tr>
</table>
</form>
</div>
</div>
</div>
</div
>

domedia
02-06-2009, 03:43 AM
This is just the HTML. HTML cannot send email.

edbr
02-06-2009, 03:57 AM
there is a mail form on this forum (php) you could use

jessa
02-07-2009, 04:02 PM
Here is the code from my send_results.php page that is connected to my home.php page. I will try to find the form you are talking about on the site, but I would still appreciate it if you could tell me if you see the error in the current form I'm using. I'm using instructions I found online.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>send results</title>
</head>
<body>
<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Results from Contact form';

// Your email address. This is where the form information will be sent.
$emailadd = 'jessa.wilcoxen@gmail.com';

// Where to redirect after form is processed.
$url = 'home.php';

// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';

// --------------------------Do not edit below this line--------------------------
$text = "Results from Contact Form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>
</body>
</html>