Making My Form Fields Required
Posted: Wed Aug 15, 2007 4:09 pm
feyd | Please use
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 everyone, I'm new here.
I am trying to make the form fields "First name, last name, state, phone, and email" required.
the page is here
http://www.mankatowebdesign.com/SMS/cen ... egion.html
The PHP Code I have currently my friend helped me so I know the (if) statements need to be fixed. If anyone could explain what I need to change the if's to to fix this it would help.Code: Select all
<?php
$txtCompanyName = $_POST["txtCompanyName"];
$txtFirstName = $_POST["txtFirstName"];
$txtLastName = $_POST["txtLastName"];
$txtTitle = $_POST["txtTitle"];
$txtStreetAddress = $_POST["txtStreetAddress"];
$txtCity = $_POST["txtCity"];
$txtState = $_POST["txtState"];
$txtZip = $_POST["txtZip"];
$txtCountry = $_POST["txtCountry"];
$txtPhone = $_POST["txtPhone"];
$txtEmailAddress = $_POST["txtEmailAddress"];
$txtNumberOfEmployees = $_POST["txtNumberOfEmployees"];
$chkContactMeChoicesA = $_POST["ChkContactMeChoicesA"];
$chkContactMeChoicesB = $_POST["ChkContactMeChoicesB"];
$chkContactMeChoicesC = $_POST["ChkContactMeChoicesC"];
$chkContactMeChoicesD = $_POST["ChkContactMeChoicesD"];
$txtContactMeChoicesD1 = $_POST["txtContactMeChoicesD1"];
$txtHearAboutUs = $_POST["HearAboutUs"];
$txtHearAboutUsOther = $_POST["txtHearAboutUsOther"];
$txtComments = $_POST["txtComments"];
if($txtHearAboutUs == "No Selection" || $txtRegionalManager == "No Selection")
{
echo "<h2>One or more required fields are missing. Please hit 'back' on your browser and fill in all required fields.</h2>\n";
}
$ContactMeChoiceFormatted = "";
if(!empty($chkContactMeChoicesA))
{
$ContactMeChoiceFormatted = $chkContactMeChoicesA;
}
if(!empty($chkContactMeChoicesB))
{
$ContactMeChoiceFormatted = $ContactMeChoiceFormatted .", ". $chkContactMeChoicesB;
}
if(!empty($chkContactMeChoicesC))
{
$ContactMeChoiceFormatted = $ContactMeChoiceFormatted .", ". $chkContactMeChoicesC;
}
if(!empty($chkContactMeChoicesD))
{
$ContactMeChoiceFormatted = $ContactMeChoiceFormatted .", ". $chkContactMeChoicesD . $txtContactMeChoicesD1;
}
$todayis = date("l, F j, Y, g:i a") ;
$message = " $todayis [EST] \n
Company: $txtCompanyName
-----------------------------------
From: $txtLastName, $txtFirstName ($txtEmailAddress)
-----------------------------------
Phone: $txtPhone
-----------------------------------
Title: $txtTitle
-----------------------------------
Address:
$txtStreetAddress
$txtCity, $txtState, $txtZip,
$txtCountry
-----------------------------------
Number Of Employees: $txtNumberOfEmployees
-----------------------------------
Please Contact Me Regarding: $ContactMeChoiceFormatted
-----------------------------------
How Did I Hear About SMS: $txtHearAboutUs
-----------------------------------
If Other: $txtHearAboutUsOther
-----------------------------------
Comments: $txtComments
-----------------------------------
";
mail("ddooley@scholarshipamerica.org", "SMS Web Request", $message, $txtEmailAddress);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="keywords" content="tuition assistance,loan programs,scholarship management,sms,scholarship america">
<meta name="description" content="Scholarship Management Services provides scholarship management, tuition assistance, loan programs, and case studies about our clients.">
<link type="text/css" href="http://www.mankatowebdesign.com/SMS/style.css" rel="stylesheet" media="screen" />
<title>Thank You For Your Message</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="favicon.ico" >
</head>
<body>
<div id="container">
<div class="navigation">
<a href="contact.html">Contact</a> | <a href="faq.html">FAQ</a> | <a href="newsletter.html">Newsletter</a> | <a href="refer_this_site.html">Refer This Site</a></div>
<div id="header" >
<img border="0" src="services.gif"></div>
<div id="left"><div class="top_tier"> <a href="index.html">Home</a></div>
<div class="top_tier"> <a href="services.html">Services</a></div>
<div class="bottom_tier1"> <a href="scholarships.html">Scholarships</a></div>
<div class="bottom_tier"> <a href="tuition_assistance.html">Tuition Assistance</a></div>
<div class="bottom_tier"> <a href="loan_programs.html">Loan Programs</a></div>
<div class="top_tier"> <a href="sms_advantage.html">SMS Advantage</a></div>
<div class="top_tier"> <a href="about.html">About Us</a></div>
<div class="bottom_tier"> <a href="leadership.html">Leadership</a></div>
<div class="bottom_tier"> <a href="job_opportunities.html">Job Opportunities</a></div>
<div class="top_tier"> <a href="case_studies.html">Case Studies</a></div>
<div class="top_tier"> <a href="news.html">News & Events</a></div>
<div class="bottom_tier"> <a href="newsletter.html">Newsletter</a></div>
<div class="top_tier"> <a target="_blank" href="http://scholarshipamerica.org/students/index.html">Student Resources</a></div>
<div class="top_tier"> <a href="refer_this_site.html">Refer This Site</a></div>
<div class="top_tier"> <a href="faq.html">FAQs</a></div>
<div class="top_tier"> <a href="contact.html">Contact Us</a></div>
<p>
<br />
<br />
</p>
<div align="center"><a target="_blank" href="http://www.scholarshipamerica.org">
<img src="scholarshiplogo.jpg" border="0" alt="Scholarship America" /></a></div>
</div>
<div id="right" style="width: 181px; height: 459px">
<h2> </h2>
</div>
<div id="content_index">
<div class="hierarchy">
Viewing: <a href="index.html">Home</a>
> <a href="contact.html">Contact Us</a> > Thank You
</div>
<p><font size="4" color="#A5262F"><b>Thank You For Your Message!<br>
<br>
</b></font><font size="2">Your message has been received. </font></p>
<p> </p>
<p> </p>
</div>
<div id="footer"><font size="1">Registered
</font><span style="font-family: Arial"><font style="font-size: 9pt"></font></span><font size="1"> 2007 Scholarship Management Services |
<a href="index.html">Home</a> | <a href="contact.html">Contact Us</a> |
<a href="sitemap.html">Sitemap</a> | <a href="privacy_policy.html">Privacy Policy</a><br />
</font>
</div>
</div>
</body>
</html>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]