|
|
#1 |
|
New Member
![]() Join Date: Dec 2011
Posts: 1
|
Im doing a Contact form for a client and my php is limited. I need to make everything in this required. Here is the code:
<?php ob_start(); if(empty($_POST)) { $status = ''; $display_form = true; } else { $fname = $_POST['fname']; $lname = $_POST['lname']; $pname = $_POST['pname']; $email = $_POST['email']; $phone = $_POST['phone']; $prescrip = $_POST['prescrip']; $payment = $_POST['payment']; $card = $_POST['card']; $shipping = $_POST['shipping']; $error_list = array(); if(empty($fname)) { $error_list[] = 'You did not supply your first name'; } if(empty($lname)) { $error_list[] = 'You did not supply your last name'; } if(empty($pname)) { $error_list[] = 'You did not supply your patient name'; } if(empty($email)) { $error_list[] = 'You did not supply your email address'; } if(empty($phone)) { $error_list[] = 'You did not supply a phone number'; } if(empty($prescrip)) { $error_list[] = 'You did not supply a prescription number'; } if(empty($payment)) { $error_list[] = 'You did not supply a payment method'; } if(empty($shipping)) { $error_list[] = 'You did not select a shipping method'; } if(empty($error_list)) { $email_contents = "The following message was sent to you from your website:\n"; $email_contents .= "First Name: $fname\n"; $email_contents .= "Last Name: $lname\n"; $email_contents .= "Patient Name: $pname\n"; $email_contents .= "Email: $email\n"; $email_contents .= "Phone Number: $phone\n"; $email_contents .= "Prescription Number: $prescrip\n"; $email_contents .= "Payment Type: $payment\n"; $email_contents .= "Payment Card On File: $card\n"; $email_contents .= "Shipping Method: $shipping\n"; $extra_headers = "From: $fname <$email>\n"; $extra_headers .= "Reply-To: $email"; mail('scripts@sbhmed.com','Refill Form Submission', $email_contents, $extra_headers ); header('Location: http://www.sbhmed.com/refill_request_confirm.php'); $status = "Thank you $fname. We will be sure to get back to you as soon as possible!"; $display_form = false; } else { $status = '<ul>'; foreach($error_list as $error_message) { $status .= "<li>$error_message</li>"; } $status .= '</ul>'; $display_form = true; } } ob_flush(); ?> Thanks for your help |
|
|
|
|
|
#2 |
|
New Member
![]() Join Date: Dec 2011
Posts: 3
|
|
|
|
|
![]() |
| Tags |
| contact form, php, required field |
| Thread Tools | |
| Display Modes | |
|
|