Jump to content

Form Problem


Andrew2010

Recommended Posts

When I press submit on the form, I do receive the email, but the text in the fields don't show up. How do I fix this? Thanks.

 

FORM CODE:

<form method="post" id="contacts-form" action="process.php">
                              <fieldset>
                              <div class="rowElem">
                                 <input type="text" value="Name:" onFocus="if(this.value=='Name:'){this.value=''}" onBlur="if(this.value==''){this.value='Name:'}">
                              </div>
                              <div class="rowElem">
                                 <input type="email" value="E-mail:" onFocus="if(this.value=='E-mail:'){this.value=''}" onBlur="if(this.value==''){this.value='E-mail:'}">
                              </div>
                              <textarea onFocus="if(this.value=='Message:'){this.value=''}" onBlur="if(this.value==''){this.value='Message:'}">Message:</textarea>
                              <div class="alignright"><input value="Submit" type="submit" name="submit"></div>
                              </fieldset>
                           </form>

 

PHP CODE:

<?php
if(isset($_POST['submit'])) {
   $to = '[email protected]' ;     //put your email address on which you want to receive the information
   $subject = 'Contact Form';   //set the subject of email.
   $headers  = 'MIME-Version: 1.0' . "\r\n";
   $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
   $message = "<table><tr><td>Name</td><td>".$_POST['Name:']."</td></tr>
               <tr><td>E-Mail</td><td>".$_POST['E-mail:']."</td></tr>
               <tr><td>Message</td><td>".$_POST['Message:']."</td>
               </tr></table>" ;
   mail($to, $subject, $message, $headers);
   header('Location: contact.php');
}
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/231521-form-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.