Yes, I am from Boston.
I have a form that is passing a bunch of data.
Here is a snippet of that form:
These are checkboxes:
<input name="employment_chkbox" type="checkbox" value="Y" id="qf_085b1c" /><label for="qf_085b1c">
Employment Services
</label> <br>
<input name="business_chkbox" type="checkbox" value="Y" id="qf_576ab8" /><label for="qf_576ab8">
Minority Business Services
</label> <br><input name="certification_chkbox" type="checkbox" value="Y" id="qf_87e3e6" /><label for="qf_87e3e6">
Technical Certification
</label> <br><input name="youth_chkbox" type="checkbox" value="Y" id="qf_b2b549" /><label for="qf_b2b549">
Youth Services
</label> <br><input name="parent_chkbox" type="checkbox" value="Y" id="qf_797412" /><label for="qf_797412">
Parent Services
</label> <br><input name="advocacy_chkbox" type="checkbox" value="Y" id="qf_e01cd9" /><label for="qf_e01cd9">
Public Policy / Advocacy
</label></td>
If none are checked, I want to send the user back to check one.
So I do this:
$checked = "no";
if (isset($_POST['employment_chkbox'])) {
$checked = "yes";
}
if (isset($_POST['business_chkbox'])) {
$checked = "yes";
}
if (isset($_POST['certification_chkbox'])) {
$checked = "yes";
}
if (isset($_POST['youth_chkbox'])) {
$checked = "yes";
}
if (isset($_POST['parent_chkbox'])) {
$checked = "yes";
}
if (isset($_POST['advocacy_chkbox'])) {
$checked = "yes";
}
if ($checked = "no")
{
echo "Please use your browser to go back and select at least one program.";
}
That doesnt work. Not even close. Ive tried a million variations of it.
I also have a bunch of other fields I need to be sure get filled out.
For them, I do this:
$error = "You need to go back and fill in these fields:<br>";
if ($firstname = '') {
$error = "$error. <br>first name"
}
if ($lastname = '') {
$error = "$error. <br>last name"
}
if ($month = '') {
$error = "$error. <br>month of birth"
}
if ($day = '') {
$error = "$error. <br>day of birth"
}
if ($year = '') {
$error = "$error. <br>year of birth"
}
if ($street = '') {
$error = "$error. <br>street"
}
if ($city = '') {
$error = "$error. <br>city"
}
if ($state = '') {
$error = "$error. <br>state"
}
if ($postalcode = '') {
$error = "$error. <br>zip code"
}
if ($homephone = '') {
$error = "$error. <br>home phone"
}
if ($referral = '') {
$error = "$error. <br>referral"
}
if ($contact = '') {
$error = "$error. <br>best time to contact"
}
if ($race = '') {
$error = "$error. <br>race"
}
if ($gender = '') {
$error = "$error. <br>gender"
}
if ($error <> "You need to go back and fill in these fields:<br>"){
echo $error;
}
And I am pretty sure you will laugh at that one.
But maybe someone can help me a little?
I really think you guys and gals who take the time to help noobs like me are incredible people... it means a lot to me. I have nobody to teach me and I dont read all that well.
So, thanks in advance.
Really.
J
And if its any consolation to my pride, I did get the script to do a fine insert on the database.
🙂