Jump to content

checkbox ticked description?


neeep

Recommended Posts

Thanks, That helped :)

 

Now I need to say,

 

"If one of these two checkboxes were not ticked, give this alert."

 

 

The following code means "If forname or surname were not ticked, give this alert for each instance"

 

 

$emailMessage .= "\nforename: " . $_POST['foreName'];

$emailMessage .= "\nsurname: " . $_POST['surName'];

 

 

 

$error = '';

 

    if (!$surName)

    $error = $error."<b>Surname</b><br />";

    if (!$foreName)

    $error = $error."<b>Forename</b><br />";

   

    if ($error!="")

echo "<span id='red'><font size='2'>Please fill out the following required fields:</font><br />$error</span>";

 

 

The following are my checkboxes

 

$emailMessage .= "\n7day: " . (isset($_POST['7day']));

$emailMessage .= "\nexamonly: " . (isset($_POST['examonly']));

 

I need to make sure the user ticks at least one. If they tick none, I need an alert saying Please tick one of the boxes.

 

Can you help me with this?

 

for your checkboxes you need something like this..

 

<?php 
if (!isset($_POST['7day']) || !isset($_POST['examonly'])) {
// do your error stuff and tell them to choose one..
} else {
// now you need to figure out which one they clicked..
if (isset($_POST['7day'])) {
// 7 day was selected
} else {
//exam only was selected
}
}

 

now this isnt a perfect example but you get the idea..

Hi, Thanks, the error stuff is working, but once I then click one of the boxes the error message remains and i dont move on..

 

 

    if (!isset($_POST['7day']) || !isset($_POST['examonly']))

    echo "<span id='red'><font size='2'>Pick a course:</font><br />$error</span>";

    else

  {

//SUBMIT & REDIRECT

mail( "[email protected]", "Subject: $emailSubject", $emailMessage, "From: $Email" );

header("Location: thankyou.html");

}

 

 

Can you tell why it's not moving on?

 

It moves on to the email stage for the error messages which apply to one field not being filled in, so I know the submit and redirect is fine...

Any ideas on the checkbox thing?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.