Page 1 of 1

Can you tell if I did something wrong with this send form?

Posted: Thu Jun 11, 2009 12:42 am
by KT83
Hi, I've created a survey but cannot get it to send the results to an email address. I know for sure it did work on the first try but for some reason when I tried to send it again without making any changes to it it wouldn't send. Could anyone tell me if this looks right?

FYI: The "id=contactform" that I use is a contact for I created for the feedback page. I wonder if I'd have to create a different one for the survey...

Code: Select all

 
//PHP FOR SENDING SURVEY RESULTS TO EMAIL//////////////////////////
 
if( isset($_POST["btnSubmit"]) ){
 
{
    ${$var} = $val;
}
 
$body_body .= "     Gender: | " . $gender . "\n";
$body_body .= "     Age Group: | " . $age . "\n";
 
 
$to = 'Admin <admin@pho411.ca>';
$subject = 'Pho411 Survey Results';
$body = $body_body;
mail($to, $subject, $body);
 
}
/////END OF PHP/////
 
 

Code: Select all

 
/////TPL FILE/////
 
<form method="post" id="contactForm">
 
  <b>What is your gender?</b>
<br /><br />
<table border="0">
    <tr>
      <td><input type="radio" name="gender" value="male"> &nbsp;&nbsp;Male </td>
    </tr>
    <tr>
      <td><input type="radio" name="gender" value="female"> &nbsp;&nbsp;Female</td>
    </tr>
   </table>
<br /><br />
 
   <b>What is your age group?</b>
   <br /><br />
   <table border="0">
    <tr>
      <td><input type="radio" name="age" value="under20" /> &nbsp;&nbsp;Under 20 </td>
    </tr>
  </table>
<br /><br />
<input type="submit" value="submit" name="submit" />
</form>
 
////END OF TPL////
 
Thanks in advance!

Re: Can you tell if I did something wrong with this send form?

Posted: Thu Jun 11, 2009 2:18 am
by globezone

Code: Select all

 
if( isset($_POST["btnSubmit"]) ){
 
{
${$var} = $val;
}
 ....
 
 
}
 
"btnSubmit" - i cant see this name in form must be "submit"

and this i am not shure ....

Code: Select all

 
{
${$var} = $val;
}
 
try this ...

Code: Select all

 
if(filter_has_var(INPUT_POST, 'submit')){
 
$body_body  = "";
$body_body .= " Gender: | " . $_POST['gender'] . "\n";
$body_body .= " Age Group: | " . $_POST['age'] . "\n";
 
 
$to = 'Admin <admin@pho411.ca>';
$subject = 'Pho411 Survey Results';
mail($to, $subject, $body_body);
 
}
 

Re: Can you tell if I did something wrong with this send form?

Posted: Fri Jun 12, 2009 12:43 am
by KT83
I tried that but the email wasn't sent. Not sure what else is involved that I might have overlooked.

Does anyone else have any ideas? Thanks.

Re: Can you tell if I did something wrong with this send form?

Posted: Fri Jun 12, 2009 2:40 am
by mischievous
This should work... however, not tested. Make sure when you use $variable .= "value"; that it initially has $variable = "value";

Code: Select all

 
if(isset($_POST["submit"]))
{
 
//Setup Email Format
$to = 'Admin <admin@pho411.ca>';
$subject = 'Pho411 Survey Results';
 
//Setup Email Content
$body = " Gender: | ".$_POST["gender"]."\n";
$body .= " Age Group: | ".$_POST["age"]."\n";
 
//Send Email
mail($to, $subject, $body);
 
}
//<---------END of PHP File
 
 
//TPL FILE---------->
 
<form method="post" id="contactForm">
 
<b>What is your gender?</b>
<br /><br />
<table border="0">
<tr>
<td><input type="radio" name="gender" value="male"> &nbsp;&nbsp;Male </td>
</tr>
<tr>
<td><input type="radio" name="gender" value="female"> &nbsp;&nbsp;Female</td>
</tr>
</table>
<br /><br />
 
<b>What is your age group?</b>
<br /><br />
<table border="0">
<tr>
<td><input type="radio" name="age" value="under20" /> &nbsp;&nbsp;Under 20 </td>
</tr>
</table>
<br /><br />
<input type="submit" value="submit" name="submit" />
</form>
 
//<-------END OF TPL