dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Please help with contact page on my site

  1. #1
    Join Date
    Apr 2011
    Posts
    30

    Please help with contact page on my site

    I am having this small problem with the contact page on my site. Everything is working except for when you do not enter information into the form and hit submit, it comes up with the error, BUT the spacing in between the links and the content spaces out more. Can someone please help me.

    http://wcuwomenshockey.dyndns.info

    Attached is my contact.php

    Thank you in advance
    Attached Files Attached Files

  2. #2
    Join Date
    Aug 2011
    Location
    Worthing, West Sussex
    Posts
    96
    Use this, works like a dream:

    HTML Code:
    <?php
    if(isset($_POST['button_x'])) { // use button_x ONLY if using an image - if not use just $_POST['button'];
    	if(empty($_POST['message'])) {
    		header("location:?e=1");
    		exit;
    	}
    	if(empty($_POST['email'])) {
    		header("location:?e=1");
    		exit;
    	}
    	if(empty($_POST['tel'])) {
    		header("location:?e=1");
    		exit;
    	}
    	if(empty($_POST['name'])) {
    		header("location:?e=1");
    		exit;
    	}
    	if(!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,3})$", $_POST['email'])) {
    		header("location:?e=2");
    		exit;
    	}
    	$subject = "Website Message - Winner Avant";
    	$name = $_POST['name'];
    	$telephone = $_POST['tel'];
    	$theiremail = $_POST['email'];
    	$message = $_POST['message'];
    	$ip = $_SERVER['REMOTE_ADDR'];
    	$msg = '
    	<html>
    	<body style="font-family:Verdana, Arial, Helvetica, sans-serif;">
    	<p>A message has been sent from the Winner Avant website.&nbsp; The message was from ' . $name . '.</p>
    	<p>Email: <strong>' . $theiremail . '</strong></p>
    	<p>Telephone: <strong>' . $telephone . '</strong></p>
    	<div style="width:700px; height:auto;">
    		<p>The message is:<br /><pre style="font-weight:bold; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word; font-family:Verdana, Arial, Helvetica, sans-serif;">' . stripslashes($message) . '</pre></p>
    	</div>
    	<p>The message was sent on ' . date('j F Y H:i:s') . '</p>
    	<p>Their IP address is ' . $ip . '</p>
    	</body>
    	</html>
    	';
    	$headers  = 'MIME-Version: 1.0' . "\r\n";
    	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    	$headers .= 'From: Winner Avant <donotreply@yourwebsite.co.uk>' . "\r\n";
    	$headers .= 'Reply-To: ' . $name . ' <' . $theiremail . '>' . "\r\n";
    	$email = 'sales@winnerhandling.co.uk';
    	if (@mail($email, $subject, $msg, $headers)) {
    		header("location:?e=3");
    		exit;
    	}
    	header("location:?e=0");
    	exit;
    } ?>
    And for the errors, use this:

    HTML Code:
    <?php
                if(isset($_GET['e'])):
    				switch($_GET['e']):
    					case 0:
    					echo "<p>An error occoured, please contact the server administrator.</p>";
    					break;
    					case 1:
    					echo "<p>Please fill in all the fields.</p>";
    					break;
    					case 2:
    					echo "<p>Please enter a valid email address.</p>";
    					break;
    					case 3:
    					echo "<p>Your message was sent. We will reply shortly.</p><p>To send another message, <a href=\"support.php\">click here</a>.";
    					break;
    				endswitch;
    			else:
    			?>
                <form action="" method="post">
                <p>Please fill in the following details below.&nbsp; We aim to get back to you within 24 hours.</p>
                <p><input type="text" name="name" id="name" /></p>
                <p><input type="text" name="tel" id="tel" /></p>
                <p><input type="text" name="email" id="email" /></p>
                <p><textarea name="message" id="message" cols="1" rows="1"></textarea></p>
                <?php // ADD CAPCHA ?>
                <p><input type="image" class="button" name="button" src="images/send.png" /></p>
                </form>
                <?php endif;?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles