Jump to content

[SOLVED] Basic Email Form Problem


aeafisme23

Recommended Posts

I have attached my code below, when i upload it nothing loads on the page, am i missing something really simple? I do not see any errors...hmph... If it is a quick fix let me know, if it's not and you know a better form for me and are willing to expel the information thats cool too! See below .... and thanks

 

<?php
// declare values
$contact_email = $_POST['EmailAddress'];
$contact_subject = $_POST['Subject'];
$contact_name = $_POST['FullName'];
$contact_message = $_POST['Message'];
$mydate = date ( 'l, F d Y g:i A',time()+240 );

// where to send e-mail to
$to = 'txdxdxrax3@gmail.com';

// e-mail subject
$subject = "Message submitted using Contact Us form";

// e-mail message
$message = "You have received a contact message:\r\n"

."----------------------------------------------------------------\r\n"
."Contact Name: $contact_name\r\n"
."Subject: $contact_subject\r\n"
."Submitted: $mydate\r\n"
."Message: $contact_message\r\n"
."Form Address: {$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}";

$headers = "From: $contact_name <$contact_email>\n"
."Reply-To: $contact_email\n"
."X-Mailer: PHP/".phpversion();

// check for validation, then send the e-mail
if(empty($contact_name) || empty($contact_email) || empty($contact_subject) || empty($contact_message)) {
echo '<p>Send us a message, enter your information below and click \'Submit\'!</p>
<form method="post" action="">
<table id="Form-Details">
<tbody>
<tr><td>Name:</td><td><input type="text" name="FullName" size="20" /></td>
<td>Subject:</td><td><input type="text" name="Subject" size="20" /></td></tr>
<tr><td>Email:</td><td colspan="3"><input type="text" name="EmailAddress" size="20" /></td></tr>
<tr><td colspan="4">Message:</td></tr>
<tr><td colspan="4"><textarea rows="6" name="Message" cols="47" class="input"></textarea></td></tr>
<tr><td colspan="4" class="right1"><input type="submit" value="Submit" /><input type="reset" value="Reset" /></td></tr>
</tbody>
</table>
</form>';
} elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $contact_email)) {
echo "<p>ERROR: Please enter a valid e-mail address.</p>";
} else {
mail( $to, $subject, $message, $headers );
echo "<h3>Message Sent!</h3><p>Dear $contact_name,<br /><br />We will get back to you as soon as possible using $contact_email."; 
}
?>

Link to comment
Share on other sites

Your code works for me.

Nothing loads on your page at all?

 

Perhaps your host doesn't support "something", but I can't see what it might be..

 

You might be able to coax some errors from the server by changing php settings first.

At the start of your page, put

ini_set('display_errors',TRUE);
error_reporting(7);

 

If still blank, try increasing the error reporting level. The list of values is here, but 7 is fairly common.

http://www.php.net/manual/en/function.error-reporting.php

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.