All pastes #899030 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-02-10 20:29 UTC
rendered paste body
<?php
					        if ((!empty($_POST['email']) and eregi("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,6}$", $_POST['email'])) and !empty($_POST['subject']) and !empty($_POST['body'])) {
					                $headers = 'From: '.$_POST['email']."\r\n".
					                            'X-Mailer: PHP/'.phpversion();
					                mail("aaronbm1@gmail.com", stripslashes($_POST['subject']), stripslashes($_POST['body']), $headers);
					                echo '<p class="success">Your message has been sent.</p>';
					        }
					        if (!empty($_POST)) {
					                if (empty($_POST['email']) or !eregi("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,6}$", $_POST['email'])) {
					                        echo '<p class="error">Invalid or empty email address.</p>';
					                }
					                if (empty($_POST['subject'])) {
					                        echo '<p class="error">Please add a subject to your message.</p>';
					                }
					                if (empty($_POST['body'])) {
					                        echo '<p class="error">Your message is empty!</p>';
					                }
					        }
					        $email = (empty($_POST['email'])) ? "" : $_POST['email'] ;
					        $subject = (empty($_POST['subject'])) ? "" : $_POST['subject'] ;
					        $body = (empty($_POST['body'])) ? "" : $_POST['body'] ;
					?>
				<form action="" method="post" class="contact" accept-charset="utf-8">
					<fieldset>
						<label for="email">Your E-Mail</label><br />
						<input type="text" name="email" value="<?php echo $email; ?>" id="email" class="title margin" size="30" /><br />
						<label for="subject">Subject</label><br />
						<input type="text" name="subject" value="<?php echo $subject; ?>" id="subject" class="title margin" size="30" />
						<br />
						<label for="body">Body</label><br />
						<textarea name="body" rows="15" class="wide" cols="40" id="body"><?php echo $body; ?></textarea><br />
						<input type="submit" value="Send &rarr;" class="send_button" />
					</fieldset>
				</form>