Page 1 of 1

PHP help - required fields

Posted: Thu Jun 28, 2007 9:19 pm
by dftho1
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi guys, I am completely new to PHP (novice is an understatement), so this question is pretty basic, sorry if it's been posted before, I had a look couldn't see anything.
Anyway basically all I want to do is make the $email_field required and need to be a valid e-mail address. I'm thinking this will only be an extra line or two so many thanks to anyone who can help out as PHP is quite foreign to me at the moment , cheers

Code: Select all

<?php
if(isset($_POST['submit'])) {

	$to = "whatever@hotmail.com"; 
	$subject = "Feedback Form";
	$name_field = $_POST['name']; 
	$email_field = $_POST['email']; 
	$message = $_POST['message']; 
  
	$body = "From: $name_field\n E-Mail: $email_field\n Message:\n $message";

	header( "Location: contact_thanks.html" );
	mail($to, $subject, $body);
	
} else {
	echo "_";
}
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Jun 28, 2007 9:23 pm
by feyd
Similar in principle to viewtopic.php?t=69814

Search my posts for "validateEmailFormat" for e-mail address validation (of the address itself, not if it exists.)