Jump to content

[SOLVED] PHP Mail Script


jbingman

Recommended Posts

<?php

$link = "<a href='/contact.php'>Click here to go back</a>";
if(!$name || !$email || !$comments) {
echo "<font color='red'>Please fill in all fields</font><br />";
echo  "<form action='action.php' method='post' name='contactform'>
	<table height='194' bgcolor='#333333'>
	<tr>
	<td width='240' height='521'><font color='red'>*</font>Full Name:<br />
	<input type='text' name='name' /><br /></td>
	<td width='328'><font size='1'><font color='red'>*</font> Indicates Required Fields</font></td>
	</tr>
	<tr>
	<td height='52' colspan='2'><font color='red'>*</font>E-mail Address:<br />
	<input type='text' name='email' /><br /></td>
	</tr>
	<tr>
	<td colspan='2'>Phone Number:<br />
	<input type='text' maxlength='3' size='4' name='areacode'/>-<input type='text' maxlength='3' size='4' name='3digits' />-<input type='text' maxlength='4' size='6' name='4digits' /><br /></td>
	</tr>
	<tr>
	<td colspan='2'><font color='red'>*</font>Subject:<br />
	<input type='text' name='subject'/><br /></td>
	</tr>
	<tr>
	<td colspan='2'><font color='red'>*</font>Questions/Comments:<br />
	<textarea cols='50' rows='10' name='comments'>Comment here</textarea></td>
	</tr>
	<tr>
	<td colspan='2'><br />
	<input type='reset' value='Reset Form' />     <input type='submit' value='Submit Form' name='submit' /></td>
	</tr>
	</table>
	</form>";
	exit;
}
if(!eregi('^[a-z0-9_]+@[a-z0-9\-]+\.[a-z0-9\-\.]+$', $email)) {
echo "<font color='red'>E-mail is not a valid address</font><br />";
echo "<form action='action.php' method='post' name='contactform'>
	<table height='194' bgcolor='#333333'>
	<tr>
	<td width='240' height='52'><font color='red'>*</font>Full Name:<br />
	<input type='text' name='name' /><br /></td>
	<td width='328'><font size='1'><font color='red'>*</font> Indicates Required Fields</font></td>
	</tr>
	<tr>
	<td height='52' colspan='2'><font color='red'>*</font>E-mail Address:<br />
	<input type='text' name='email' /><br /></td>
	</tr>
	<tr>
	<td colspan='2'>Phone Number:<br />
	<input type='text' maxlength='3' size='4' name='areacode'/>-<input type='text' maxlength='3' size='4' name='3digits' />-<input type='text' maxlength='4' size='6' name='4digits' /><br /></td>
	</tr>
	<tr>
	<td colspan='2'><font color='red'>*</font>Subject:<br />
	<input type='text' name='subject'/><br /></td>
	</tr>
	<tr>
	<td colspan='2'><font color='red'>*</font>Questions/Comments:<br />
	<textarea cols='50' rows='10' name='comments'>Comment here</textarea></td>
	</tr>
	<tr>
	<td colspan='2'><br />
	<input type='reset' value='Reset Form' />     <input type='submit' value='Submit Form' name='submit' /></td>
	</tr>
	</table>
	</form>";
exit;
}else{
$name = trim(stripslashes($_REQUEST['name']));
$email = trim($_REQUEST['email']);
$phone = $_REQUEST['areacode' . '3digit' . '4digit'];
$subject = $_REQUEST['subject'];
$comments = stripslashes($_REQUEST['comments']);
mail('[email protected]', $subject, $comments, $phone, 'From:$name <$email>');

echo "<br />";
echo "<p>Thank you for your comments.<br />";
echo "<a href='contact.php'>click here to continue.</a></p>";
}
?>

 

Here's my script i have for a comment/contact section on my page that isnt working. it wont pass the first if even if i fill in all the fields.

its probably something stupid but i dont know PHP inside and out.

Link to comment
https://forums.phpfreaks.com/topic/112920-solved-php-mail-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.