Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Verifying radio button
Index -> Programming, PHP -> PHP Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Lanks




PostPosted: 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]
Sponsor
Sponsor
Sponsor
sponsor
octopi




PostPosted: 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
}
Lanks




PostPosted: Sun Nov 16, 2008 6:05 pm   Post subject: RE:Verifying radio button

it works, yay

thank you octopi
Display posts from previous:   
   Index -> Programming, PHP -> PHP Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: