shush1 Posted December 18, 2006 Share Posted December 18, 2006 Hi I have a simple form that when submitted I get sent a email with the results, however I want the 'Name' and 'Email' fields to be mandatory for the user to fill in, without which they cannot submit the form, if they try a message comes up saying they need to complete the mandatory fields.Can someone please help or show me how I can achieve this. Thanxthis is my PHP script<?php$result = "Garner International: Website Enquiry Form\r\n\r\n";$result .= "Name: " . $_POST['q1'] . "\r\n";$result .= "Professional Title: " . $_POST['q2'] . "\r\n";$result .= "Company Name: " . $_POST['q3'] . "\r\n"; $result .= "Email Address" . $_POST['q4'] . "\r\n";$result .= "Comments: " . $_POST['q5'] . "\r\n";if ($_POST['q4']) { $headers = "From: $_POST[q1] <$_POST[q4]>\r\n\r\n"; } else { $headers = "From: No Name given <[email protected]>\r\n\r\n"; } $sendit = mail("[email protected]", "Garner International: Website Enquiry Form", $result, $headers) or die("Something went wrong");echo "<meta http-equiv='refresh' content='0; url=thank.html'>";die;?> Link to comment https://forums.phpfreaks.com/topic/31106-php-form-help-mandatory-fields/ Share on other sites More sharing options...
tracy Posted December 18, 2006 Share Posted December 18, 2006 In the database, causing the fields to be not null should achieve this. Link to comment https://forums.phpfreaks.com/topic/31106-php-form-help-mandatory-fields/#findComment-143635 Share on other sites More sharing options...
shush1 Posted December 18, 2006 Author Share Posted December 18, 2006 Hi Im not using a database im getting the form to submit a email to my email address Link to comment https://forums.phpfreaks.com/topic/31106-php-form-help-mandatory-fields/#findComment-143667 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.