PDA

View Full Version : Problem with email containing form results


canadian_turtle
07-07-2010, 04:31 PM
Hi there, I'm a complete Noob when it comes to PHP but I'm trying to get the results from a form on my website send to my e-mail and it just isn't working.

I'm using this tutorial/code but the e-mail I receive is anbsolutely blank

http://www.dreamweaverclub.com/dreamweaver-php-form.php

Does anyone know what could possibly be wrong or isn't as easy as copy/paste (with altering the first few lines of course) for it to be able to work.

Sorry for such a beginners question but I've been Googling all afternoon (and haven't been able to get it to work for weeks now!) and I'm just getting so frustrated with the fact I can't get it to work properly as everywhere I read it's such an easy thing to do.

Thanks anyway, for any help you can give me.

davidj
07-07-2010, 04:33 PM
Are you testing it on a live server. A commercial server which is configured for mail?

canadian_turtle
07-07-2010, 09:58 PM
Are you testing it on a live server. A commercial server which is configured for mail?

Yes I am. Sorry, I should've included the link:

http://www.klusservicederuiter.nl/offerte.html

edbr
07-08-2010, 02:08 AM
an often encountered problem is with the character number restriction on that form. post the code for it

canadian_turtle
07-08-2010, 08:19 AM
I've used the exact code linked to above and have also changed the character restriction to a very high nnumber, which didn't seem to make a difference so I changed it back seeing the tutorial said not to actually change anything in that part of the code. I don't necessarily have to use this particular code, if anyone knows an easy tutorial that does work, I'm very happy to try it out :)



<?php
//--------------------------Set these paramaters--------------------------
// Subject of email sent to you.
$subject = 'Aanvraag offerte via Klusservice website';
// Your email address. This is where the form information will be sent.
$emailadd = 'turtlegoescanada@hotmail.com';
// Where to redirect after form is processed.
$url = 'http://www.klusservicederuiter.nl';
// 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 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.'">';
?>

edbr
07-08-2010, 08:53 AM
think its your form, copy this into a new page, upload it fill the form and send it to test . actually ill look ot a different form if i get time , i dont like the lack of validation in this form
<!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>Untitled Document</title>
</head>

<body>

<form method="post" action="sendresults.php" enctype="text/plain">


<input name="naam" type="text" />

<input name="email" type="text" />
<input name="send" type="submit" value="Submit" />
</form>

</body>
</html>

canadian_turtle
07-08-2010, 11:53 PM
Thank you very much for your reply!

When you say I have to save this form and upload it, I don't quite follow the connection with the PHP form I used before as this one isn't PHP. What format should I save it in (and does it need a particular name?) and how does it get linked to both my form page css code and the above mentioned PHP code? Thank you very much! :)

edbr
07-09-2010, 01:51 AM
not important just upload it as say, mailtest.html then open it in a browser (your_site.com/mailtest.html ) fill it in and submit and see if you get a filled mail sent to you . i think its because you are using fieldsets this is just to check

misswebweaver
08-01-2010, 08:31 PM
I too am trying to use the form and php from the tutorial
http://www.dreamweaverclub.com/dreamweaver-php-form.php

The form submits and it forwards to the confirmation page. But, I never receive an email.

I tried your mailtest.html form, got the same results. Used my domain name email address, gmail address, yahoo address.... The email never comes through. I've tried it with and without the file attachment.

Form:

Confirmation:
at the beginning of my form, I have:
<form action="sendresults.php" method="post" enctype="multipart/form-data" name="Ugly" id="Ugly">

php from sendresults.php - I changed the limit to 90:
{echo "Name of form element $key cannot be longer than 90 characters";die;}

<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Ugliest Office Entry';

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

// Where to redirect after form is processed.
$url = 'http://www.cccccc.com/confirmation.html';

// 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 = '1';

// --------------------------Do not edit below this line--------------------------
$text = "Results from 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 90 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.'">';
?>

edbr
08-02-2010, 05:20 AM
ok try this . it will not redirect but let me know if the message is displayed.
<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Ugliest Office Entry';

// Your email address. This is where the form information will be sent.
//$emailadd = 'teresa@cccccc.com';
$emailadd = 'teresa@ccccc.com';

// Where to redirect after form is processed.
$url = 'http://www.ccccccccc.com/confirmation.html';

// 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 = '1';

// --------------------------Do not edit below this line--------------------------
$text = "Results from 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 90 characters";}
// $j = 20 - $j;
// for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}

echo $text;

mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
// echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

misswebweaver
08-02-2010, 05:58 AM
replaced the code with what you had on the post. It goes to a blank page
http://yfactorstudio.com/sendresults.php
and no email in my inbox :(

Do you another php form that could be used?

edbr
08-02-2010, 06:09 AM
the problem is that the info is not being passed then ($text) so you may have the same problem. can you post the form code as well

edbr
08-02-2010, 06:11 AM
oh wait i messed that up, hold tight

misswebweaver
08-02-2010, 06:15 AM
<!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>Ugliest Office Contest presented by Y Factor Studio</title>
<link href="/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
<style type="text/css">
<!--
body,td,th {
color: #FFF;
}
body {
background-color: #000;
}
-->
</style></head>

<body>
<!-- DO NOT MOVE! The following AllWebMenus linking code section must always be placed right AFTER the BODY tag-->
<!-- ******** BEGIN ALLWEBMENUS CODE FOR menu ******** -->
<script type="text/javascript">var MenuLinkedBy="AllWebMenus [4]",awmMenuName="menu",awmBN="816";awmAltUrl="";</script><script charset="UTF-8" src="menu.js" type="text/javascript"></script><script type="text/javascript">awmBuildMenu();</script>
<!-- ******** END ALLWEBMENUS CODE FOR menu ******** -->

<script type='text/javascript'>var MenuLinkedBy='AllWebMenus [4]',awmMenuName='menu',awmBN='DW';awmAltUrl='';</script>
<script charset='UTF-8' src='menu.js' type='text/javascript'></script>
<script type='text/javascript'>awmBuildMenu();</script>

<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="51" rowspan="7" valign="top">&nbsp;</td>
<td width="892" align="center" valign="top"><blockquote>
<blockquote>
<blockquote>
<blockquote>
<p onmouseover="MM_preloadImages('/images/ugly/uglyad.jpg','/images/ugly/sponsors.jpg')"><img src="/images/ugly/uglyad.jpg" alt="Ugly Office Contest" width="576" height="625" align="top" onload="MM_preloadImages('/images/ugly/uglyad.jpg');MM_preloadImages('/images/ugly/sponsors.jpg')" /></p>
</blockquote>
</blockquote>
</blockquote>
</blockquote></td>
<td width="50">&nbsp;</td>
</tr>
<tr>
<td height="32" align="right" valign="top" bgcolor="#062695"><span id='awmAnchor-menu'>&nbsp;</span></td>
<td class="ugly">&nbsp;</td>
</tr>
<tr>
<td width="891" height="340" align="center" valign="top"><table width="100%" border="0" align="center" cellpadding="6" cellspacing="0">
<tr>
<th width="100%" align="left" valign="top" scope="col"><table width="93%" border="0" align="center" cellpadding="0" cellspacing="6">
<tr>
<th scope="col"><p><span class="ugly">Is your office the &quot;Ugliest Office&quot; in the Tri-State? </span></p>
<p><span class="ugly">If it is, you could win an office makeover from Y FACTOR STUDIO. </span></p>
<p><span class="ugly">It's easy to enter. Simply fill out and submit the form below. In addition to submitting the form below, please email 1 picture to Jennifer@yfactorstudio.com. </span></p>
<p><span class="ugly">Please review the <a href="/terms.html">Terms and Conditions</a> of the contest. When entering your answers below, please keep the total answers to 500 words or less. Good Luck! </span></p></th>
</tr>
</table></th>
</tr>
</table>
<form id="ugly" name="ugly" method="post" action="sendresults.php"><table width="93%" border="0" cellspacing="6" cellpadding="0">
<tr>
<td width="28%" class="ugly">Business Name</td>
<td colspan="5"><label>
<input type="text" name="business" id="business" />
</label></td>
</tr>
<tr>
<td class="ugly">Applicant Name</td>
<td colspan="5"><input type="text" name="business2" id="business2" /></td>
</tr>
<tr>
<td class="ugly">Business Street Address</td>
<td colspan="5"><input type="text" name="business3" id="business3" /></td>
</tr>
<tr>
<td class="ugly">City</td>
<td width="12%"><input type="text" name="business4" id="business4" /></td>
<td width="4%" class="ugly">State</td>
<td width="4%"><label>
<input type="text" name="State" id="State" />
</label></td>
<td width="5%" class="ugly">Zip</td>
<td width="47%"><label>
<input type="text" name="zip" id="zip" />
</label></td>
</tr>
<tr>
<td class="ugly">Phone</td>
<td><input type="text" name="business5" id="business5" /></td>
<td colspan="3">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td class="ugly">Email Address</td>
<td colspan="5"><input type="text" name="business6" id="business6" /></td>
</tr>
<tr>
<td><span class="ugly">What are your current challenges?</span></td>
<td colspan="5"><label>
<textarea name="challenges" id="challenges" cols="45" rows="5"></textarea>
</label></td>
</tr>
<tr>
<td><span class="ugly">How would an office make-over effect you and your business?</span></td>
<td colspan="5"><label>
<textarea name="makeover" id="makeover" cols="45" rows="5"></textarea>
</label></td>
</tr>
<tr>
<td><span class="ugly">Describe your ultimate vision of the space.</span></td>
<td colspan="5"><label>
<textarea name="vision" id="vision" cols="45" rows="5"></textarea>
</label></td>
</tr>
<tr>
<td>Upload one image of office</td>
<td colspan="5"><label>
<input type="file" name="upload" id="upload" />
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td colspan="5"><label>
<input type="submit" name="submit" id="submit" value="Submit" />
</label></td>
</tr>
</table>
</form>
<td width="50" rowspan="5" valign="top">&nbsp;</td>
</tr>
<tr>
<td height="9" bgcolor="#9090d0">&nbsp;</td>
</tr>
<tr>
<td bgcolor="#FFFFFF"><img src="/images/ugly/sponsors.jpg" width="800" height="251" alt="Ugly Contest Sponsors" /></td>
</tr>
<tr>
<td bgcolor="#252525"><img src="/images/index_12.jpg" width="892" height="16" /></td>
</tr>
<tr>
<td height="41" valign="top" bgcolor="#353535"><img src="/images/index_13.jpg" width="891" height="41" border="0" usemap="#Map" /></td>
</tr>
</table>

<map name="Map" id="Map">
<area shape="rect" coords="666,8,876,37" href="mailto:jennifer@yfactorstudio.com" alt="Contact Y Factor Studio" />
</map>
</body>
</html>

edbr
08-02-2010, 06:20 AM
ill look at your form but here is a variation i edited a couple of weeks ago which has been tested and works
<!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>test mail</title>
</head>

<body>
<?php
// Subject of email sent to you.
$subject = 'Results from Contact form';

// Your email address. This is where the form information will be sent.

$emailadd = 't';

// edit if cc wanted
$mailcc ='';

// edit if bcc wanted
$mailbcc ='';

// Where to redirect after form is processed.
$url = 'http://www.your domain.com';

// 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 form:\r\n".'<br>';

foreach($_POST as $key => $value){
if(!(!isset($value))){$set=1;}
if(is_array($value)){
$message = $message . "$key: ".implode( ', ', $value)."\n\n";
} else {
$message = $message . "$key: $value\n\n";
}
}
$to= $emailadd;

function UTF8_mail($to, $subject, $message)
{


$headers .=
"Content-Type: text/html;"
. "charset=UTF-8\r\n""
. "MIME-Version: 1.0\n"
. "Content-Transfer-Encoding: 8bit\n"
. "X-Mailer: PHP\n";
if (!empty($mailcc)) {
$headers.= "Cc: " . $mailcc ."\n";
}

if (!empty($mailbcc)) {
$headers.= "Bcc: " . $mailbcc ."\n";
}
return mail($to, $subject, $message, $headers);
}

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

echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

</body>
</html>

edbr
08-02-2010, 06:24 AM
this form wont help you . you are looking for a mail with an upload script as you are trying to add an image attachment.

misswebweaver
08-02-2010, 06:31 AM
I can take the upload back out. It didn't work before I added that either.
Let me try that.

misswebweaver
08-02-2010, 06:36 AM
here's what I just tried.
I removed the file upload and replaced all the contents in the sendresults.php file with what you just posted here.
It doesn't forward to the confirmation page but goes to http://yfactorstudio.com/sendresults.php
No email in my inbox either.
I have to get something up on the site and form working before the work day starts tomorrow. Any suggestions? - desperate :-)

edbr
08-02-2010, 06:48 AM
your server is an iss server and the problem lies there info says it is php enabled but you will have to contact godaddy and assk if they have a mail script. this problem has arisen before im afraid. this will work on an appache server for sure

connection:close date:Mon, 02 Aug 2010 05:45:50 GMT server:Microsoft-IIS/6.0 x-powered-by:ASP.NET,PHP/4.4.9

misswebweaver
08-02-2010, 06:53 AM
Thank you. I am not hosting her website and I feared it was her server since i had got php scripts to work many times on my server.
She uses http://www.ixwebhosting.com.
thank you very much for your help! Any suggestions on another type of form to use to send the email?

edbr
08-02-2010, 07:01 AM
as i said info on the page shows the hoster as godaddy the webhosting is probaly a re seller i have no experience with them but i seem to remember they have their own script that they use check out godaddy web site