SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Feb 2011
    Location
    The land of nod
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP contact form not forwarding form details to email...

    For some strange unbeknown reason my contact form has just stopped working in that it no longer submits any of the form details to the email address I have set up in the script.

    The contact form does re-direct to the thanks.htm file once the approapriate field data has been completed and then submitted, its just it ends at that point..!

    I tested the PHP / contact form on several occasions whilst live and on every occasion I had the form details come through to my email account, so Im at a loss as to why it has just stopped ?

    My code for the PHP and HTML is as follows should anyone anyone be kind enough to look at it : (Domain is also www.bfdesigns.co.uk)

    PHP Code:
    <?php
    /* Set e-mail recipient */
    $myemail  "ben@bfdesigns.co.uk";

    $company  = ($_POST['company']);
    $firstname = ($_POST['firstname']);
    $email    =($_POST['email']);
    $enquiry =($_POST['enquiry']);
    $thanksurl "http://bfdesigns.co.uk/thanks.htm" ;
    $errorurl "http://bfdesigns.co.uk/error.html" ;

    /*Redirects the user to the error page if JS is disabled and the form is submitted*/
    if(empty($firstname))
    {
    header('Location: error.html');
    exit();
    }else
    {
    /* Redirects the visitor to the thanks page */
    header('Location: thanks.htm');
    exit();
    }

    /* Prepare the message for the e-mail */
    $message "You have a new Web design enquiry from:

    Company name: 
    $company
    Client name: 
    $firstname
    Clients e-mail: 
    $email
    Clients message: 
    $enquiry
    End of message
    "
    ;

    /* Sends the message using mail() function */
    mail($myemail$email$message);

    ?>
    HTML Code:
    <form action="contact.php" method="post" name="contactForm" onsubmit="return validateForm()">
    					<fieldset>
    					<p><span>*</span> Must be completed to submit the form</p>
    						<label>Company:</label>
    							<input type="text" name="company"/>
    								<label id="completeField"><span>*</span> Name:</label>
    									<input type="text" name="firstname" id="firstname"/>
    										<label>Email:</label>
    											<input type="text" name="email"/>
    												<label>Enquiry:</label>
    													<textarea name="enquiry" rows="4" cols="10"></textarea>
    														<input type="submit" value="Submit" id="submit" />
    					</fieldset>
    				</form>

  2. #2
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    669
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So what is the boolean output of your call to mail() ? (Remember you should always call it inside and if conditional - like this: if(mail()) {//do something} else {//do something else})
    I'll do anything to avoid working on my own code

    Are you using: if (isset($_POST['submit'])) ?
    IE has a bug and does not always send the value.

  3. #3
    SitePoint Wizard bronze trophy C. Ankerstjerne's Avatar
    Join Date
    Jan 2004
    Location
    The Kingdom of Denmark
    Posts
    2,692
    Mentioned
    7 Post(s)
    Tagged
    0 Thread(s)
    It's no great surprise, as you script will invariably terminate before getting to the mail code.

    Code php:
    if(empty($firstname))
    {
    header('Location: error.html');
    exit();
    }else
    {
    /* Redirects the visitor to the thanks page */
    header('Location: thanks.htm');
    exit();
    }

    Remove exit() from the else clause.
    Christian Ankerstjerne
    <p<strong<abbr/HTML/ 4 teh win</>
    <>In Soviet Russia, website codes you!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •