Pls see the message

How to create Register form database.(myphp admin)

1)username
2)first name
3)lastname
4)password
5)confirm password
6)date of birth -(date -month-year)
7)gender
8)alternate email
9)country -(selecting country)

pls let me know,i will be waiting for your reply.

regards
riyaz.

Which framework would you prefer to use? ZEND or PEAR?

There are many different ways to do that. Here’s one way.

register.php


<?php
require_once 'RegisterModel.php';
require_once 'RegisterDB.php';
require_once 'RegisterView.php';
$contentDB = new RegisterDB();
$contentView = new RegisterView();
$contentModel = new RegisterModel($contentDB, $contentView);
echo $contentModel->render();
?>

RegisterModel.php


<?php
class RegisterModel
{
    private $_db;
    private $_view;
    private $_userId;
    private $_error;
    public function __construct($db, $view)
    {
        $this->_db = $db;
        $this->_view = $view;
        $this->_userId = 0;
        $this->_error = array();
    }
    private function getAction()
    {
        $action = '';
        if (isset($_POST['createAccount'])) {
            $action = 'create';
        }
        if (isset($_POST['personalDetails'])) {
            $action = 'personal';
        }
        return $action;
    }
    function getAccountDetails()
    {
        return array(
            'username' => filter_input(INPUT_POST, 'username', FILTER_SANITIZE_SPECIAL_CHARS),
            'password' => filter_input(INPUT_POST, 'password', FILTER_SANITIZE_SPECIAL_CHARS),
            'confirmPassword' => filter_input(INPUT_POST, 'confirmPassword', FILTER_SANITIZE_SPECIAL_CHARS)
        );
    }
    function getPersonalDetails()
    {
        return array(
            'userid' => filter_input(INPUT_POST, 'userid', FILTER_SANITIZE_SPECIAL_CHARS),
            'first' => filter_input(INPUT_POST, 'firstname', FILTER_SANITIZE_SPECIAL_CHARS),
            'last' => filter_input(INPUT_POST, 'lastname', FILTER_SANITIZE_SPECIAL_CHARS),
            'dob' => filter_input(INPUT_POST, 'dob', FILTER_SANITIZE_SPECIAL_CHARS),
            'gender' => filter_input(INPUT_POST, 'gender', FILTER_SANITIZE_SPECIAL_CHARS),
            'email' => filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL),
            'country' => filter_input(INPUT_POST, 'country', FILTER_SANITIZE_SPECIAL_CHARS)
        );
    }
    private function processAction($action)
    {
        $db = $this->_db;
        
        $success = FALSE;
        switch ($action) {
        case 'create':
            $userDetails = $this->getPersonalDetails();
            list($username, $password, $confirmPassword) = $userDetails;
            if ($password === $confirmPassword) {
                $passcode = crypt($password);
                $userId = 
                $this->_userId = $db->addUser($username, $passcode);
                $success = ($this->_userId > 0);
            } else {
                array_push($this->_error, 'password');
            }
            break;
        case 'personal':
            $details = $this->getPersonalDetails();
            list($userId, $first, $last, $dob, $gender, $email, $country) = $userDetails;
            $this->_userId = $userId;
            $updated = $db->addPersonalDetails($userId, $first, $last, $dob, $gender, $email, $country);
            $success = ($updated > 0);
            if (!$success) {
                array_push($this->_error, 'personal');
            }
        }
        return $success;

    }
    private function countries()
    {
        $view = $this->_view;
        
        $list = '';
        $countries = array('New Zealand', 'Other');
        return $view->options($countries);
    }
    private function getView($action)
    {
        $view = $this->_view;
        $content = '';
        switch ($action) {
            case 'personal':
                $content .= $view->thankyou();
                break;
            case 'create':
                if (isset($_error['password'])) {
                    $content .= $view->passwordError();
                    $content .= $this->getView();
                } else {
                    $countries = $this->countries();
                    $content .= $view->userDetails($this->_userId, $countries);
                }
                break;
            default:
                $content .= $view->createAccount();
        }
        return $content;

    }
    public function render()
    {
        $action = $this->getAction();
        $success = $this->processAction($action);
        $content = $this->getView($action);
        return $content;
    }
}
?>

RegisterView.php


<?php
class RegisterView
{
    public function options($names)
    {
        $options = '';
        foreach ($names as $name => $value) {
            $options .= '<option name="' . $name . '">' . $value . '</option>';
        }
        return $options;
    }
    public function createAccount()
    {
        return <<< EOT
    <h1>Register</h1>
    <h2>Step 1 of 2</h2>
    <ol>
        <li><strong>Create account</strong></li>
        <li>User details</li>
    </ol>
    <form method="post">
        <p><label>Username: <input type="text" name="username"></label></p>
        <p><label>Password: <input type="password" name="password"></label></p>
        <p><label>Confirm Password: <input type="password" name="confirmPassword"></label></p>
        <p><input type="submit" name="createAccount" value="Create account"></p>
    </form>

EOT;
    }
    public function passwordError()
    {
        return '<p>There was a problem with your password.</p>';
    }
    public function userDetails($userId, $countries)
    {
        return <<< EOT
    <h1>Register</h1>
    <h2>Step 2 of 2</h2>
    <ol>
        <li>Create account</li>
        <li><strong>User details</strong></li>
    </ol>
    <form method="post">
        <p><label>First Name: <input type="text" name="firstname"></label></p>
        <p><label>Last Name: <input type="text" name="lastname"></label></p>
        <p><label>Date of Birth: <input type="text" name="dateofBirth"></label></p>
        <p><label>Gender:
            <input type="radio" name="gender" value="male"> Male
            <input type="radio" name="gender" value="female"> Female
        </label></p>
        <p><label>Alternate Email: <input type="text" name="email"></label></p>
        <p><label>Country:
            <select name="country">$countries</select>
        </label></p>
        <p>
            <input type="hidden" name="userid" value="$userId">
            <input type="submit" name="personalDetails" value="Update my details">
        </p>
    </form>

EOT;
    }
    public function thankyou()
    {
        return <<< EOT
    <h1>Register</h1>
    <h2>Thank You</h2>

EOT;
    }
    public function page($content)
    {
        return <<< EOT
<html>
<head>
</head>
</head>
<body>
$content
</body>
</HTML>

EOT;
    }
}
?>

and the database, I’ll leave for you to implement according to however you desire.

RegisterDB.php


<?php
class RegisterDB
{
    public function addUser($username, $password)
    {
        return 3; // last insert id
    }
    public function addPersonalDetails($userId, $first, $last, $dob, $gender, $email, $country)
    {
        return 1; // row updated
    }
}
?>

Thanks for sending codes,

But see this attachment ,say me how to set/create field for these in Myphpadmin.

1)username
2)first name
3)lastname
4)password
5)confirm password
6)date of birth -(date -month-year)
7)gender
8)alternate email
9)country -(selecting country)

First build a database at your server, Second, Build a sql file, something like below and name as ? autorized.sql
enter your mysql via server and insert into the database.
Note the date should be saved as a timestamp and when you need the info
you can simply format it there to what you like.

--
-- Table structure for table `authorized`
--

CREATE TABLE `authorize` (
  `username` varchar(10) default NULL,
  `firstname` varchar(20) default NULL,
  `lastname` varchar(20) default NULL,
  `password` varchar(50) default NULL,
  `email2` varchar(50) default NULL,
  `birth` varchar(20) default NULL,
  `gender` varchar(10) default NULL,
  `country` varchar(50) default NULL,
  `date` datetime default '0000-00-00 00:00:00',

) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Extract date and time from mysql database, along with your $connection, example-


    while ($sql = mysql_fetch_object($result)) 
    {


   $date    =    $sql -&gt; date;
    
   $TheDate = "Date: " . date ("n-j-y", strtotime ($date)); 
   $TheTime = "Time: " . date ("g:i A", strtotime ($date)); 

   echo "&lt;font size=\\"2\\" face=\\"Tahoma\\"&gt;&lt;b&gt;$TheDate                 &lt;/b&gt;&lt;/br&gt;&nbsp;&nbsp;&nbsp;  &lt;b&gt;$TheTime &nbsp;&nbsp;&nbsp;
   &lt;/b&gt;  &lt;/font&gt;  &lt;b&gt;&lt;br&gt;";
}