Form emails incomplete results & returns error?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rvasquez
Forum Newbie
Posts: 1
Joined: Sun Feb 06, 2011 9:00 am

Form emails incomplete results & returns error?

Post by rvasquez »

Hi,

I'm fairly new to PHP and although I can use html/css and some Javascript, I've only managed to implement PHP by digging into the code myself to better understand it. And so, I've been stuck on this project for like two days. I'd like to write a form that emails the results to an email address and I've taken the original source code from http://apptools.com/phptools/forms/forms1.php.

So far I've put three input types that the answers should email. However, not only does it give me the echo error for when the email's not sending, but it DOES send the email, and an email with only the rank, not the other two input question information. I'm unsure of what I'm missing. Would anyone mind explaining this and helping me out? Thank you so much.

Code: Select all

<?php
   if ($_SERVER['REQUEST_METHOD'] != 'POST'){
      $me = $_SERVER['PHP_SELF'];
?>
   <form name="form1" method="post"
         action="<?php echo $me;?>">
      <table border="0" cellspacing="0" cellpadding="2">
      <tr>
            <td valign="top">What is your character name?</td>
            <td><input type="text" name="charname"></td>
         </tr>
         
           <tr>
            <td valign="top">What are your normal playtimes?</td>
            <td><input type="text" name="playtime"></td>
         </tr>
        
              <tr>
            <td valign="top">What is your highest rank?</td>
            <td><input type="text" name="rank"></td>
         </tr>
          
         <tr>
            <td>&nbsp;</td>
            <td><input type="submit" name="Submit"
               value="Send"></td>
         </tr>
      </table>
   </form>
<?php
   } else {
      error_reporting(0);
      $recipient = 'fairy_tail_recruitment@yahoo.com';
	  $subject = 'Fairy Tail App';
      $rank = "Rank: ".stripslashes($_POST['rank']);
	  $playtime = "Playtime: ".stripslashes($_POST['playtime']);
	  $charname = "Character: ".stripslashes($_POST['charname']);
			 
      if (mail($recipient, $subject, $rank, $playtime, $charname))
         echo nl2br("<b>Message Sent:</b>
         To: $recipient");
      else
         echo "Sorry. Didn't go through...";
}
?>
Post Reply