PDA

View Full Version : Contact Form not passing results


jessa
02-10-2009, 11:28 PM
Hi All,

I have never created a contact form before. My form is going to my email but none of the information is passing. It only says Results from Contact Form:
There is not a name, project description, email address, phone, how did you hear about creative spark etc. showing up. Here is the link http://jessaportfolio.com/home.php Click on contact for the contact form

I'm pasting my code from my send_results.php site:
<!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>







Here is the pasted info for the form:
<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>
<p><br />
Email me directly at <a href="mailto:jessa.wilcoxen@gmail.com">jessa.wilcoxen@gmail.com</a></p>
</div>
</div>
</div>
</div>
<div id="footer"><a href="portfolio.php"><img src="images/portfolio_button.gif" alt="portfolio" width="120" height="35" border="0" id="Image1" onmouseover="MM_swapImage('Image1','','images/portfolio_button_glow.gif',1)" onmouseout="MM_swapImgRestore()" /></a></div>
</div>


Please help. I always learn so much on this site.

urbanrays
02-11-2009, 12:28 AM
Hi,

Have you tried getting rid of all the codes at the top of the page so your php script looks like this
<?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.'">';
?>

I am no php expert but you are not asking the php code to send the criteria you ask for in your website.
By the looks of things you are only asking for a email add, name and subject.

Can I also give you some feedback on your site, I guess you are testing your site in FF not ie7, have you tried testing your site in different browsers, you have nearly 1/4 of a page missing on ie7 and have to scroll across to see the complete site.

I would first concentrate on getting your site to look good in all browsers before you tackle other issues within the site

Hope this helps

edbr
02-11-2009, 01:13 AM
cant see the doc type affecting it
add this before the form and if the results are being passed it will show
email=<?php echo $_POST['email'];?> <br/>
company_name=<?php echo $_POST['company_name'];?><br/>
hear_about =<?php echo $_POST['hear_about'];?><br/>

phone =<?php echo $_POST['phone'];?><br/>
email_phone =<?php echo $_POST['email_phone'];?>

jessa
02-11-2009, 05:11 AM
Thank you to both replies. I did remove the recommended code from the first reply and it has not made any changes. I am confused where exactly I should add this code recommended in the second reply:

email=<?php echo $_POST['email'];?> <br/>
company_name=<?php echo $_POST['company_name'];?><br/>
hear_about =<?php echo $_POST['hear_about'];?><br/>

phone =<?php echo $_POST['phone'];?><br/>
email_phone =<?php echo $_POST['email_phone'];?>

I have tried posting it in several places and I just receive errors. Should it be on the home.php document or the send_results.php document?

Also in regards to the question about IE 7. I have only checked my site on Safari, Firefox, and Opera. I do not have access to a PC either at home or at work but now you brought the problem to my attention I will try to borrow a friend's PC to view the problem mentioned.

Anymore advice on the contact form issue would be greatly appreciated.

edbr
02-11-2009, 05:32 AM
the code needs to go on the action file ie send_results.php, sorry i wrote form . you have a re direct you need to comment it out. If the values are being passed from your form you will see them. its just a debugging test
in fact just make a copy of send reults as back up and replace all its code with this. let me know i this gets the result . if it doesnt then the form is not sending the results
email=<?php echo $_POST['email'];?> <br/>
company_name=<?php echo $_POST['company_name'];?><br/>
hear_about =<?php echo $_POST['hear_about'];?><br/>

phone =<?php echo $_POST['phone'];?><br/>
email_phone =<?php echo $_POST['email_phone'];?>

jessa
02-11-2009, 04:29 PM
I tried the code as you mentioned before with no luck. I met with my web graduate professor today and he told me to try this form instead. Now we are receiving an error that says "Parse error: syntax error, unexpected T_VARIABLE in /home/wilcoxen/public_html/mailer.php on line 14" and he can't figure it out. I'm repasting my code from home.php file and the one from my new action file mailer.php.

Here is the home.php code:

<div class="AccordionPanel">
<div class="AccordionPanelTab">contact</div>
<div class="AccordionPanelContent">
<div id="accordian_textholder">
<form method="POST" action="mailer.php">
<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 value="email" selected="selected">email</option>
<option value="phone">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>
<p><br />
Email me directly at <a href="mailto:jessa.wilcoxen@gmail.com">jessa.wilcoxen@gmail.com</a></p>
</div>
</div>
</div>





Here is the mailer.php code:

<?php
//if(isset($_POST['submit'])) {
$to = "jessa.wilcoxen@gmail.com";
$subject = "Contact from website";

$name = $_POST['name'];
$company_name = $_POST['company_name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$project = $_POST['project'];
$hear_about = $_POST['hear_about'];
$email_phone = $_POST['email_phone'];
*
$body = "From:\n$name\n$company_name\n\nE-Mail:\n$email\n\nPhone:\n$phone\n \nProject:\n$project\n\nHear About:\n$hear_about\n\nEmail Phone:\n$email_phone";
*
//echo "Data has been submitted to $to!";
mail($to, $subject, $body);
//} else {
//echo "Sorry there was an error!";
//}
?>

Any ideas would be greatly appreciated.

edbr
02-12-2009, 12:42 AM
if the code i gave you didnt produce any values then the form is not submitting values. te code looks ok except i can not see a value for $project = $_POST['project']; on your form, but that would not stop it.step 1 make sure you are pasing the valus , then check the mail function.
1 point as you are sending the results to gmail , did you check to see if you had been getting mail but it had been put in the junk mail?

jessa
02-12-2009, 01:21 AM
I figured it out! I returned the first contact for send_results.php document and I added this code:

$body = "From:\n$name\n$company_name\n\nE-Mail:\n$email\n\nPhone:\n$phone\n\nProject:\n$proj ect\n\nHear About:\n$hear_about\n\nEmail Phone:\n$email_phone";
}

I hadn't but any code telling it to send the body information. It works fine now. Thanks for all of your help.