Earlier today I created simple database (user and login fields), login, and registration PHPs.

Now I need help going about the following enhancement:
In a nutshell: I am trying to create a registration form like facebook's with php code (and link it a mysql database)...

1.) My updated registration.php has 5 fields:

  1. "Full Name" (text)(40)
  2. "Your Email" (which is equal to username for my site's login, use text? not sure?)(40)
  3. "Create Password" (text)(40)
  4. "Birthday" (3 drop downs with following options: (Month: ) "Jan thru Dec", (Day: ) "1 thru 31", (Year: ) 1933 thru 2008
  5. "Gender" (single drop down with 2 options: "female", "male")

I have no clue for adding the birthday and gender dropdowns to mySQL because of their drop down options.

Here is what my code looks like (please share if you see any errors, some of my code was grabbed from web so I really am not sure if the "post"s are setup correctly now).

<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr><td><FONT FACE="Rockwell" color="#666666" SIZE="2">Full Name</FONT></td><td><input type="text" name="name" maxlength="40"></td></tr>
<tr><td><FONT FACE="Rockwell" color="#666666" SIZE="2">Your Email</FONT></td><td><input type="text" name="user" maxlength="30"></td></tr>
<tr><td><FONT FACE="Rockwell" color="#666666" SIZE="2">Create Password</td><td><input type="password" name="pass" maxlength="30"></td></tr>
<tr><td>
<tr><td><FONT FACE="Rockwell" color="#666666" SIZE="2">Birthday</FONT></td><td>
    <select name="update_mybirthmonth">
        <option value='1'>Jan</option>
        <option value='2'>Feb</option>
        <option value='3'>Mar</option>
        <option value='4'>Apr</option>
        <option value='5'>May</option>
        <option value='6'>Jun</option>
        <option value='7'>Jul</option>
        <option value='8'>Aug</option>
        <option value='9'>Sep</option>
        <option value='10'>Oct</option>
        <option value='11'>Nov</option>
        <option value='12'>Dec</option>
    </select>
    <select name="update_mybirthday">
        <? for($i = 1; $i <= 31; $i++) : ?>
            <option value="<?=$i;?>"><?=$i;?></option>
        <? endfor; ?>
    </select>
    <select name="update_mybirthyear">
        <? for($i = 1933; $i <= 2008; $i++) : ?>
            <option value="<?=$i;?>"><?=$i;?></option>
        <? endfor; ?>
    </select>
<tr><td><FONT FACE="Rockwell" color="#666666" SIZE="2">Gender</FONT></td><td>
    <select name="update_mybirthmonth">
        <option value='1'>female</option>
        <option value='2'>male</option>
</form></td></tr>

<tr><td>
<tr><td colspan="2" align="right"><input type="submit" name="subjoin" value="Sign Up"></td></tr>
</table>
</form>

<?php 
if(isset($_POST['Submit']))
{
    $update_mybirthmonth = $_POST['update_mybirthmonth'];
    $update_mybirthday = $_POST['update_mybirthday'];
    $update_mybirthyear = $_POST['update_mybirthyear'];

    if (($update_mybirthmonth >= 1) AND ($update_mybirthmonth >= 1) AND ($update_mybirthday >= 1) AND ($update_mybirthday <= 31) AND ($update_mybirthyear >= 0) AND ($update_mybirthyear <= $this_year))
    {
        include 'functions/DbConnector.php';
        $birthday = "$update_mybirthmonth-$update_mybirthday-$update_mybirthyear";
        mysql_query("UPDATE login SET birthday = '$birthday' WHERE username = 'Valerij'") or die ("Database error: ".mysql_error());
    }
}
?>
</head>

Does anyone know the code for creating a mySQL database that can grab from this information?

What code should I use to make this information available to users' unique member page?

Thanks in advance (a million!).

Dani AI

Generated

described a classic registration-to-database gap; is right that PHP does the processing, but the missing pieces are a clear data model, server‑side validation, and secure insertion. Recommended approach: store birthday as a single DATE column, make email unique, never store plaintext passwords (use passwordhash), and use PDO or mysqli prepared statements instead of the old mysql* API.

A simple schema that fits the form:

CREATE TABLE users (
  id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(100) NOT NULL,
  email VARCHAR(255) NOT NULL UNIQUE,
  password VARCHAR(255) NOT NULL,
  birthday DATE DEFAULT NULL,
  gender ENUM('female','male','other','unspecified') NOT NULL DEFAULT 'unspecified',
  created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

Server-side workflow (validate, build a YYYY-MM-DD birthday, hash, insert). Example pattern using PDO and modern APIs:

// collect and validate input
$email = trim($_POST['email'] ?? '');
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { /* handle invalid email */ }

$month = (int)($_POST['birth_month'] ?? 0);
$day   = (int)($_POST['birth_day'] ?? 0);
$year  = (int)($_POST['birth_year'] ?? 0);
$birthday = checkdate($month, $day, $year) ? sprintf('%04d-%02d-%02d', $year, $month, $day) : null;

$hash = password_hash($_POST['password'] ?? '', PASSWORD_DEFAULT);

// insert with prepared statement (PDO)
$pdo = new PDO(/* dsn */);
$stmt = $pdo->prepare('INSERT INTO users (name,email,password,birthday,gender) VALUES (:n,:e,:p,:b,:g)');
$stmt->execute([':n'=>$name,':e'=>$email,':p'=>$hash,':b'=>$birthday,':g'=>$gender]);

Troubleshooting and best practices: ensure form field names match the server checks (a common bug is mismatched submit button names or reusing a select name for gender), enforce UNIQUE on email to prevent duplicates, escape output with htmlspecialchars when rendering profiles, use HTTPS and CSRF tokens, and prefer DATE storage so age calculations and queries (e.g., "users older than 18") are straightforward.

A MySQL code that grabs form variables? …A database code that connects to view ? .. That is where programming is in middle even with Visual Basic or dot Net even with Java or Ruby ……. You are in a PHP thread just use PHP … ( 2 minutes searching on internet will give you the answer )

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.