Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include ("Design/header.php");
- require ("connect.php");
- //register code
- if ($_POST['submit'])
- {
- //grab submitted data
- $firstname= $_POST ['firstname'];
- $lastname= $_POST ['lastname'];
- $username= $_POST ['username'];
- $password= $_POST ['password'];
- $password_repeat= $_POST ['password_repeat'];
- $dob_year= $_POST ['dob_year'];
- $dob_month= $_POST ['dob_month'];
- $dob_day= $_POST ['dob_day'];
- $gender= $_POST ['gender'];
- if (
- $firstname&&
- $lastname&&
- $username&&
- $password&&
- $password_repeat&&
- $dob_year&&
- $dob_month&&
- $dob_day&&
- $gender
- )
- {
- //validate
- if (strlen($firstname)>25 || strlen($lastname)>25 || strlen($username)>25)
- echo "Firstname, Lastname and Username must be no more that 25 characters.";
- else
- {
- //check password
- if (strlen($password)>25 || strlen($password)<6)
- echo "Password must be between 6 and 25 characters.";
- else
- {
- //check dob
- if (is_numeric($dob_year)&&is_numeric($dob_month)&&is_numeric($dob_day))
- {
- if(strlen($dob_year)>4 || strlen($dob_month)>2 || strlen($dob_day)>2 )
- echo "Date of Birth must be in the following format, 1919/01/31.";
- else
- {
- if ($gender=="Male"||$gender=="Female")
- {
- //compare passwords
- if ($password==$password_repeat)
- {
- //check Date of Birth limits for month and day
- if ($dob_month>12||$dob_month>31)
- echo "Date of Birth month and/or day is bigger then expected.";
- else
- {
- //success register the user
- $dob_db = "$dob_year-$dob_month-$dob_day";
- $password_db = md5(password);
- switch ($gender)
- {
- case "Male";
- $gender_db = "M";
- break;
- case "Female";
- $gender_db = "F";
- break;
- }
- $register = mysql_query ("INSERT INTO users VALUES ('','$firstname','$lastname;,$username','$password_db','$dob_db','$gender_db')");
- echo "Success!";
- }
- }
- else
- echo "The two passwords you have entered do not match, please try again.";
- }
- else
- echo "Gender must be Male of Female.";
- }
- }
- else
- echo "Date of Birth must be in number form, For example 1919/01/01.";
- }
- }
- }
- else
- echo "Missing field! Please fill in all fields.";
- }
- else
- echo "Please enter your details and Register.";
- ?>
- <form action='register.php' method='POST'>
- <p>
- <table width='60%'>
- <tr>
- <td width='40%' align='right'>
- <font size='2' font face='arial'>First name -
- </td>
- <td>
- <input type='text' value='<?php echo $firstname; ?>' name='firstname' maxlength='25'>
- </td>
- </tr>
- <tr>
- <td width='40%' align='right'>
- <font size='2' font face='arial'>Last name -
- </td>
- <td>
- <input type='text' value='<?php echo $lastname; ?>' name='lastname' maxlength='25'>
- </td>
- </tr>
- <tr>
- <td width='40%' align='right'>
- <font size='2' font face='arial'>Username -
- </td>
- <td>
- <input type='text' value='<?php echo $username; ?>' name='username' maxlength='25'>
- </td>
- </tr>
- <tr>
- <td width='40%' align='right'>
- <font size='2' font face='arial'>Password -
- </td>
- <td>
- <input type='password' name='password' maxlength='25'>
- </td>
- </tr>
- <tr>
- <td width='40%' align='right'>
- <font size='2' font face='arial'>Repeat password -
- </td>
- <td>
- <input type='password' name='password_repeat' maxlength='25'>
- </td>
- </tr>
- <tr>
- <td width='40%' align='right'>
- <font size='2' font face='arial'>Date of Birth -
- </td>
- <td>
- <input type='text' name='dob_year' maxlength='4' size='3' value='<?php if ($dob_year) echo $dob_year; else echo "YYYY";?>'> / <input type='text' name='dob_month' maxlength='2' size='1' value='<?php if ($dob_month) echo $dob_month; else echo "MM";?>'> / <input type='text' name='dob_day' maxlength='2' size='1' value='<?php if ($dob_day) echo $dob_day; else echo "DD";?>'>
- <tr>
- <td width='40%' align='right'>
- <font size='2' font face='arial'>Gender -
- </td>
- <td>
- <select name='gender'>
- <option>Male</option>
- <option>Female</option>
- </select>
- </td>
- </tr>
- </td>
- </tr>
- <tr>
- <td width='40%' align='right'>
- <input type='submit' name='submit' value='Register'>
- </td>
- <td>
- </td>
- </tr>
- </table>
- </form>
- <?php
- include ("Design/footer.php");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement