Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6589807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:13:18+00:00 2026-05-25T17:13:18+00:00

Hey I need to get the gender selected from a select tag and then

  • 0

Hey I need to get the gender selected from a select tag
and then store that value as a variable in php, here’s some relevant snippets of both
the register.php form and the register_process.php file

register.php

    <form action="register_process.php" method="post">
    <table>
        <tr>
            <td>Username (to be used for login and display name)</td>
            <td><input type="text" name="username" id="username" onclick="check()"/></td>
            <td id="username_check"></td>
        </tr>
        <tr>
            <td>Password</td>
            <td><input type="password" name="password" id="password" onclick="check()"/></td>
            <td id="password_check"></td>
        </tr>
        <tr>
            <td>Password (Re-Enter)</td>
            <td><input type="password" name="repassword" id="repassword" onclick="check()"/></td>
            <td id="repassword_check"></td>
        </tr>
        <tr>
            <td>Email Address</td>
            <td><input type="text" name="email" id="email" onclick="check()"/></td>
            <td id="email_check"></td>
        </tr>
        <tr>
            <td>Email Address (Re-Enter)</td>
            <td><input type="text" name="reemail" id="reemail" onclick="check()"/></td>
            <td id="reemail_check"></td>
        </tr>
        <tr>
            <td>Gender</td>
            <td>
                <select name="gender">
                    <option value="1">Male</option>
                    <option value="2">Female</option>
                </select>
            </td>
            <td></td>
        </tr>
        <tr>
            <td>I agree to the terms and conditions</td>
            <td><input type="checkbox" name="tos" id="tos" /></td>
            <td id="tos_check"></td>
        </tr>
        <tr>
            <td id="valid" colspan="3"></td>
        </tr>
        <tr>
            <td colspan="3"><input type="submit" value="Register" /></td>
        </tr>
        <tr>
            <td colspan="3"><a href="login.php">Cancel</a></td>
        </tr>
    </table>
</form>

there is a ton of javascript I have omitted from this that does very basic validation

register_process.php

    <?php
ini_set('display_errors', 'On');
error_reporting(E_ALL | E_STRICT);
    ?>
    <?php
    $connection = mysql_connect(HOST, USERNAME, PASSWORD);
    if(!$connection)
    {
die("Database connection failed: " . mysql_error());
    }
    $db_select = mysql_select_db(DATABASE, $connection);
    if(!$db_select)
    {
die("Database selection failed: " . mysql_error());
    }

    $username = mysql_real_escape_string($_POST['username']);
    $password = mysql_real_escape_string($_POST['password']);
    $repassword = mysql_real_escape_string($_POST['repassword']);
    $email = mysql_real_escape_string($_POST['email']);
    $reemail = mysql_real_escape_string($_POST['reemail']);
    $gender = $_POST['gender'];
    $tos = mysql_real_escape_string($_POST['tos']); // not being checked yet

    $errors = 0;
    $success = 0;

    // USERNAME CHECK
    if (preg_match('/^[a-z\d_]{5,20}$/i', $username)) 
    {
    $user_query = "SELECT * FROM users WHERE user_name = '$username' OR login_name   =  '$username' LIMIT 1";
$result=mysql_query($user_query);
$count=mysql_num_rows($result);
if($count==0)
{
    echo "username is available <br/>";
    $success++;
    echo "<br/>1 Passed<br/>";
}
else 
{
    echo "sorry, that username already exist";
    $errors++;
    echo "<br/>1 Passed<br/>";
}

   }
    else 
    {
     echo "You either need to enter a username, or you have entered a username in an incorrect format.";
 $errors++;
 echo "<br/>1 Passed<br/>";

}

   // PASSWORD CHECK
   if(preg_match('/^[a-z\d_]{5,20}$/i', $password))
   {
// password is between 5-10 characters, alpha-numeric (a-z, A-Z, 0-9) and underscores
if($password === $repassword)
{
    // password is identical
    $success++;
    echo "<br/>2 Passed<br/>";
}
else 
{
    // passwords do not match
    $errors++;
    echo "<br/>2 Passed<br/>";
}
 }
     else 
     {
  echo "Password failed validation";
  $errors++;    
 }

   // EMAIL CHECK
   if (eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})$',$email))
   {
// user@email.com passes
// 1@1.com passes
// -@_.com passes
//
echo "<br/> email is ok";
if($email === $reemail)
{
    // email addresses match
    $success++;
    echo "<br/>3 Passed<br/>";
}
else 
{
    // email address does not match
    echo "<br/>3 Passed<br/>";
    $errors++;
}
   }
    else
    {
echo "email validation failed <br/>";
$errors++;
echo $email;    
   }
    // Here is the problem, I can't seem to evaluate the correct value,
    // When I echo out $gender I get nothing, So theres either an issue
    // in the html form OR in the way I use $gender = $_POST['gender'];

    if($gender == 1 || $gender == "1" || $gender == '1')
    {
    echo "male selected";
    }
    else 
    {
    echo "female selected";
    }

    ?>

what am I missing here guys?,

I have been hunting around
google to find an answer with no success.

heres the error php is giving me:

“Notice: Undefined index: gender in register_process.php on line 22”

Everything else in the form IS working fine, there are no other issues

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:13:19+00:00Added an answer on May 25, 2026 at 5:13 pm

    Your mistake is this:

     />
    

    Don’t close your form tag way up there – you need to close it after the select.

    BTW xhtml is dead, don’t use it (it has been superseded by html5). Use plain HTML and don’t close tags that don’t need it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, I'm using php 5 and need to communicate with another server that runs
I have a result of select from my table: id tag 1 hey 1
Hey, I need to delete all images from a string and I just can't
Hey, I need help isolating part of a url in PHP. say I have
Hey, I'm really stuck with my project here... I need to know when any
Hey Guys...need help. Working on a project and get this error on the Output
hey guys, I need help considering win32com in Python: I have a routine that
hey i have a counter text here and i need to know how to
Hey guys I managed to get a text input and select box to updated
Hey I need to get the width of the screen in my application. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.