Computer Science Canada

Verifying radio button

Author:  Lanks [ Sun Nov 16, 2008 4:27 pm ]
Post subject:  Verifying radio button

i have created a signin form with name, age, email etc and i'm verifying that these credentials exist using this code
code:

// Check for a first name:
   if (preg_match ('/^[A-Z \'.-]{2,20}$/i', $trimmed['first_name'])) {
      $fn = mysqli_real_escape_string ($dbc, $trimmed['first_name']);
   } else {
      echo '<p class="error">Please enter your first name!</p>';
   }
....

....

if ($fn && $ln && $e && $p && $ag && $em && $sx) { // If everything's OK...

(add to table).....

but now i need to make sure they check one of these radio buttons
code:

<p><b>Account Type:</b><br />
       <input type="radio" name="account_type" value="c">Client<br />
        <input type="radio" name="account_type" value="u">User<br />

i then need to tell the php script that is creating the entry which table to put the data in depending on which value is selected for account type... is it possible?[/code]

Author:  octopi [ Sun Nov 16, 2008 5:53 pm ]
Post subject:  Re: Verifying radio button

code:

$accountType = $_REQUEST['account_type'];
if($accountType == 'c') {
  //add to the client table
}
else if($accountType == 'u') {
  //add to user table
}
else {
  //add to default table, or throw an error
}

Author:  Lanks [ Sun Nov 16, 2008 6:05 pm ]
Post subject:  RE:Verifying radio button

it works, yay

thank you octopi


: