Contact Form Not Working? Please Help!

Discussion in 'PHP' started by gobbly2100, Nov 20, 2007.

  1. #1
    Hello,

    I am using a PHP script that was given to me by someone on here a while back but it does not seem to be working now.

    Could someone take a look at it please and see if you can see why?

    HTML Code
    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <?php if ($errors) echo '<p>The following errors occurred: <br />' . join('<br />', $errors) . '</p>'; ?>
    <p>Name:<br>
    <input name="name" type="text" />
     </p>
    <p>Email:<br>
    <input name="email" type="text" />
     </p>
    <p>Subject:<br>
    <input name="subject" type="text" />
     </p>
    <p>Message:<br>
    <textarea name="message" rows="10" cols="80"></textarea>
     <br />
    <input type="submit" value="Send" /><input type="hidden" name="do" value="send" /><input type="reset" value="Reset" />
     </p></form>
    Code (markup):
    PHP Code
    
    <?php
    $errors = array();
    if($_POST['do']=="send") {
    	$recipient="email@email.com"; // Set your email here //
    	if (!$subject=$_POST['subject']) $errors[] = 'Subject required';
    	if (!$name=$_POST['name']) $errors[] = 'Name required';
    	if (!$email=$_POST['email']) $errors[] = 'Email required';
    	if (!$message=$_POST['message']) $errors[] = 'Message required';
    	if (!$errors) {
    		$message = "Name: {$name}\n\nMessage:\n{$message}";
    		    $formsend=mail("$recipient", "$subject", "$message", "From: $name ($email)\r\nReply-to:$email");    
    			echo("<p>Your message was successfully sent!</p>");  }}
    ?>
    Code (markup):
    Thanks in advance to anyone who can help me on this one.
     
    gobbly2100, Nov 20, 2007 IP
  2. greatlogix

    greatlogix Active Member

    Messages:
    664
    Likes Received:
    13
    Best Answers:
    1
    Trophy Points:
    85
    #2
    Script is working on my machine. What error you get?
     
    greatlogix, Nov 20, 2007 IP
  3. gobbly2100

    gobbly2100 Banned

    Messages:
    906
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Well I am not getting any errors but when I change the email to various email addresses I don't seem to receive them so am not sure why, I get some emails when I use it but they are usually delayed and most I simply don't get.

    Any ideas on that? Is it something to do with my host maybe?
     
    gobbly2100, Nov 20, 2007 IP
  4. Marko

    Marko Peon

    Messages:
    248
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Probably something is wrong with your host!
    Use phpinfo to check is SMTP enabled…
     
    Marko, Nov 20, 2007 IP
  5. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #5
    Barti1987, Nov 20, 2007 IP
  6. bobb1589

    bobb1589 Peon

    Messages:
    289
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #6
    also, make sure you are checking your junk email folders, alot of times these types of emails will go to the spam folder
     
    bobb1589, Nov 20, 2007 IP
  7. phpl33t

    phpl33t Banned

    Messages:
    456
    Likes Received:
    33
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Most likely, your server's sendmail or postfix is misconfigured. I had one server that would always get caught by spam filters not for open relays, but because of the address sendmail was sending with. Wierd stuff.

    Also, make sure your server is not blacklisted.
     
    phpl33t, Nov 20, 2007 IP