PHP FORMS- Do they even send?

Discussion in 'PHP' started by Fenchel, Jun 2, 2011.

  1. #1
    Hey I'm having troubles getting my PHP Form to work...

    Will send $5 to whoever can correct it. The problem is I'm not getting anything in my email


    CONTACT.HTML
    <form id="contact" method="POST" action="thanks.php"> 
    							<fieldset> 
    							  	<label for="name" id="name_label">Name<span class="red">*</span></label> 
    							  	<input type="text" name="name" id="name" size="50" value="" class="text-input" /> 
                                    
    							  	<label for="email" id="email_label">E-mail<span class="red">*</span></label> 
    							  	<input type="text" name="email" id="email" size="50" value="" class="text-input" /> 
                                    
    								<label for="website" id="website_label">Website</label> 
    								<input type="text" name="website" id="website"  value="http://www." class="text-input" /> 
                                    
    							  <label for="msg" id="msg_label">Message<span class="red">*</span></label> 
    							 	<textarea cols="60" rows="10" name="msg" id="msg" class="text-input"></textarea> 
    							  	<br /> 
    							  	<input type="submit" name="submit" class="button" id="submit_btn" value="Send Message"/><br /> 
    							<span class="error" id="name_error">Please enter name !</span> 
    							<span class="error" id="email_error">Please enter email address !</span> 
    							<span class="error" id="email_error2">Please enter valid email address !</span> 
    							<span class="error" id="msg_error">Please enter message !</span> 
    							</fieldset> 
    						  </form> 
    Code (markup):
    THANKS.PHP

    <?php
    if(isset($_POST['submit'])) {
    $to = "myemail@email.com";
    $subject = "Quote";
    $name_field = $_POST['name'];
    $email_field = $_POST['email'];
    $message = $_POST['website'];
    $message1 = $_POST['msg'];
    
    
     
    $body = "Full Name: $name_field\n E-Mail: $email_field\n Website: $message\n Message: $message1\n ";
    
     
    
    mail($to, $subject, $body);
    } else {
    echo "blarg!";
    }
    ?>
    Code (markup):

    Someone please help... REP + $5
     
    Fenchel, Jun 2, 2011 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2
    I've tested your script and it works fine, perhaps its a problem with your hosting provider ?
     
    MyVodaFone, Jun 3, 2011 IP
  3. Bitrain

    Bitrain Active Member

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #3
    Try this:
    
    
    <?php
    if(isset($_POST['submit'])) {
    $to = '"Company Name" <myemail@email.com>';
    $subject = 'Quote';
    $name_field = $_POST['name'];
    $email_field = $_POST['email'];
    $message = $_POST['website'];
    $message1 = $_POST['msg'];
    
    $body = "Full Name: $name_field\n E-Mail: $email_field\n Website: $message\n Message: $message1\n ";
    $headers = 'From: "Your WebSite" <site@domain.com>' . PHP_EOL .
               'X-Mailer: PHP-' . phpversion() . PHP_EOL;
     
    
    if (mail($to, $subject, $body, $headers)) {
      echo 'mail() Success!' . "<br />\n";
    }
    else {
      echo 'mail() Failure!' . "<br />\n";
    } 
    }
    ?>
    
    
    PHP:
     
    Bitrain, Jun 3, 2011 IP
  4. crivion

    crivion Notable Member

    Messages:
    1,669
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    210
    Digital Goods:
    3
    #4
    check your junk folder
     
    crivion, Jun 3, 2011 IP
  5. Minimal Hank

    Minimal Hank Peon

    Messages:
    136
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    For raw debugging purposes you might want to add or die statement at the end of your mail function.
     
    Minimal Hank, Jun 3, 2011 IP
  6. Fenchel

    Fenchel Member

    Messages:
    199
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #6

    This didn't fix the problem either.

    My hosting said It's a problem on my end.

    I checked my junk folder, still nothing.

    It seems when I press "submit" it just stays on the same page. It doesn't go to the process page.
     
    Fenchel, Jun 3, 2011 IP
  7. Cucumba123

    Cucumba123 Well-Known Member

    Messages:
    1,403
    Likes Received:
    34
    Best Answers:
    3
    Trophy Points:
    150
    #7
    Are both files in the same folder?
    Also I think the files names are case sensitive.
     
    Cucumba123, Jun 3, 2011 IP
  8. Minimal Hank

    Minimal Hank Peon

    Messages:
    136
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    I guess all you can do is to change your hosting provider - there is nothing wrong with the code you have posted here.
     
    Minimal Hank, Jun 3, 2011 IP
  9. ntomsheck

    ntomsheck Peon

    Messages:
    87
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #9
    If your e-mail hosting requires authentication, that code wont work. Why would a server farm allow non-authenticated e-mails to be sent out from it? Look for the PHP mail PEAR module.
     
    ntomsheck, Jun 3, 2011 IP
  10. Fenchel

    Fenchel Member

    Messages:
    199
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #10
    I found the problem.

    The problem was in the CSS properties of the submit button. Thanks anyway!
     
    Fenchel, Jun 3, 2011 IP