1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Fix My Contact Form - 3$

Discussion in 'PHP' started by TheJugernaut, Jul 5, 2011.

  1. #1
    I have a contact form that I needed to be fixed.

    I dont know if I programed it well in PHP to verify so I just keep getting error sending email.

    Anyways here are the codes:

    FORM:
            <form action="contact.php" method="post">
              <ul>
                <li>
                  <label for="name">Name *</label>
                  <input name="name" type="text" name="name" id="name" class="txtFld" />
                  <span id="errorName" class="formError"></span> </li>
                <li>
                  <label for="email">Email *</label>
                  <input name="email" type="text" name="email" id="email" class="txtFld" />
                  <span id="errorEmail" class="formError"></span> </li>
                <li>
                  <label for="subject">Subject</label>
                  <input name="subject" type="text" name="subject" id="subject" class="txtFld" />
                </li>
                <li>
                  <label for="message">Message * </label>
                  <textarea name="message" name="message" id="message" cols="30" rows="5" class="txtAra"> </textarea>
                  <span id="errorMessage" class="formError"></span> </li>
                <li style=" margin-bottom: 0px;">
                  <input type="submit" value="" class="submit" id="submit" />
                  <span id="formProgress" class="formProgress"></span> </li>
              </ul>
             
            </form>
    Code (markup):
    Contact.php:
    <?php
    
    session_start();  
      
    if(isset($_POST['submit'])) {  
    $name = $_POST['name'];
    $email = $_POST['email'];
    $subject = $_POST['subject'];
    $message = $_POST['message'];
    $submit = $_POST['submit'];
    
    $mail_to = 'email I put here.';
    $subject = 'Message from a site visitor '.$name;
    
    $mail_status = mail($mail_to, $subject, $body_message, $headers);
    
    if ($mail_status) {} 
    }
    ?>
    Code (markup):

     
    TheJugernaut, Jul 5, 2011 IP
  2. Alex Roxon

    Alex Roxon Active Member

    Messages:
    424
    Likes Received:
    11
    Best Answers:
    7
    Trophy Points:
    80
    #2
    Change:
    <input type="submit" value="" class="submit" id="submit" />
    Code (markup):
    To:
    <input type="submit" value="Submit" name="submit" class="submit" id="submit" />
    Code (markup):
    After:
    $subject = 'Message from a site visitor '.$name;
    Code (markup):
    Add:
    $body_message = sprintf( "Name: %s\r\nEmail: %s\r\nMessage: %s\r\n", $name, $email, $message );
    Code (markup):
    Then provided you change the $mail_to variable to your email, it should send. Untested.
     
    Alex Roxon, Jul 5, 2011 IP
  3. TheJugernaut

    TheJugernaut Active Member

    Messages:
    92
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    61
    Digital Goods:
    1
    #3
    Thanks for helping me out but it did not work :/.
     
    TheJugernaut, Jul 6, 2011 IP
  4. ntomsheck

    ntomsheck Peon

    Messages:
    87
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The PHP mail function rarely works now days, with all the authentication-necessary SMTP servers. Could you tell us the errors you're getting? Also, read up on Pear::Mail or whatever it's called, for PHP. That works better.
     
    ntomsheck, Jul 6, 2011 IP
  5. sky4

    sky4 Member

    Messages:
    62
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    43
    #5
    contact.html
    
            <form action="contact.php" method="post">
              <ul>
                <li>
                  <label for="name">Name *</label>
                  <input type="text" name="name" class="txtFld" />
                  <span id="errorName" class="formError"></span> </li>
                <li>
                  <label for="email">Email *</label>
                  <input type="text" name="email" class="txtFld" />
                  <span id="errorEmail" class="formError"></span> </li>
                <li>
                  <label for="subject">Subject</label>
                  <input type="text" name="subject" class="txtFld" />
                </li>
                <li>
                  <label for="message">Message * </label>
                  <textarea name="message" cols="30" rows="5" class="txtAra"> </textarea>
                  <span id="errorMessage" class="formError"></span> </li>
                <li style=" margin-bottom: 0px;">
                  <input type="submit" value="sendmail" class="submit" />
                  <span id="formProgress" class="formProgress"></span> </li>
              </ul>
             
            </form>
    
    PHP:
    contact.php
    
    <?php
    $name = $_POST['name'];
    $email = $_POST['email'];
    $subject = $_POST['subject'];
    $message = $_POST['message'];
    $submit = $_POST['submit'];
    $mailrrto = 'sky@gamespoint.net';
    $subject54 = 'Site contact form';
    
    $mailheader = "From: ".$email."\r\n"; 
    $mailheader .= "Reply-To: ".$email."\r\n";
    $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
    
    $MESSAGE_BODY = "Name: ".$name."<br>"; 
    $MESSAGE_BODY .= "Email: ".$email."<br>"; 
    $MESSAGE_BODY .= "Comment: ".nl2br($message)."<br>";
    mail($mailrrto, $subject, $message, $mailheader) or die ("Fail"); 
    ?>
    
    
    PHP:
    Tasted :)
     
    sky4, Jul 6, 2011 IP