Page 1 of 1

form works on one site not others

Posted: Mon Jul 04, 2016 9:12 am
by wizzer
Hi all, firstly I am pretty new to php but there is something I really don't understand.
I have a standard php form that works perfectly well on my website and returns all form data including the usual name, number and a drop down and sends email within seconds, the problem I am having is I basically copy and paste the same form on to 2 other site and it returns to a thank you url but does not send the email at all, on another it pings back the error message and does not return to the thank you url. All 4 forms are exactly the same I just change the <option> tag and obviously the css links that is all that changes, I use Microsofts Expression 4 to build these sites. :banghead:

Code: Select all

<?php
    $name = $_POST['name'];
    $number = $_POST['number'];
    $email = $_POST['email'];
    $type = $_POST['type'];
    $message = $_POST['message'];
    $from = 'From: Your Web Site'; 
    $to = 'chris@cjwadsworth.co.za'; 
    $subject = 'Website Enquiry';
    $human = $_POST['human'];
    
     $body = "From: $name\n Phone Number: $number\n E-Mail: $email\n type: $type\n Message:\n $message";
			
    
				
    if ($_POST['submit'] && $human == '4') {				 
        if (mail ($to, $subject, $body, $from)) { 
	  header('Location: thankyou.php');
exit;
	} else { 
	    echo '<p>Something went wrong, go back and try again!</p>'; 
	} 
    } else if ($_POST['submit'] && $human != '4') {
	echo '<p>You answered the anti-spam question incorrectly!</p>';
    }
?>
and the anti spam is;

Code: Select all

<label class="la">*What is 2+2? (Anti-spam)</label>

Re: form works on one site not others

Posted: Mon Jul 04, 2016 9:15 am
by Celauran
Probably best to do one server at a time if they're all behaving differently. First, what errors are being returned? Have you checked your mail server logs? Are you sure the mails aren't being sent, or are they simply not being received?

Re: form works on one site not others

Posted: Mon Jul 04, 2016 9:25 am
by wizzer
Hi and thanks, on 2 sites no errors returned it returns to a thank you url saying your details have been sent, but email received, on the latest it returns error; some thing went wrong go back and try again, no I have not checked mail server logs..?

Re: form works on one site not others

Posted: Sun Jul 10, 2016 4:25 pm
by TopCoder
Like @celauran says check your mail logs on your mail server at "default-mx.imaginet.co.za" and check your PHP Error logs. Using Mail just sends out SMTP - It's a good chance it might be in your spam folder, or your mail software is rejecting it.

Everything looks good from a code perspective. From an email configuration perspective you have a little work to do, but that's un-related to your question.

Re: form works on one site not others

Posted: Mon Jul 11, 2016 3:49 am
by wizzer
TopCoder wrote:Like @celauran says check your mail logs on your mail server at "default-mx.imaginet.co.za" and check your PHP Error logs. Using Mail just sends out SMTP - It's a good chance it might be in your spam folder, or your mail software is rejecting it.

Everything looks good from a code perspective. From an email configuration perspective you have a little work to do, but that's un-related to your question.
Thanks for that, what should I get when inserting "default-mx.imaginet.co.za" I have entered it and nothing happens, just a blank page.

Re: form works on one site not others

Posted: Mon Jul 11, 2016 12:36 pm
by Christopher
I think "default-mx.imaginet.co.za" is just and example. Lookup you DNS records to see what your is. It could be "mail.imaginet.co.za" or something like that.