Need help with Registration page for my website(PDO)

Can any one help me i want to add confirm password option where there should be a clause that checks that both password n confirm password is same, email option and also there should be check for duplicate name check for this registration page.

<?php
       if ( isset ( $_POST [ 'register' ] ) ) {
              $account = ! empty ( $_POST [ 'account' ] ) ? $_POST [ 'account' ] : null ;
              $password = ! empty ( $_POST [ 'password' ] ) ? $_POST [ 'password' ] : null ;
              if ( ! is_null ( $account ) && ! is_null ( $password ) ) {
                     $db = GetDatabaseConnection ( 'db_account' ) ;
                     $sql = $db->prepare ( 'INSERT INTO `t_account` ( `name` , `pwd` , `pw2` , `gd` ) VALUES ( :account , :passwd , :pw2 , :tps )' ) ;
                     $pw2 = ( constant ( 'StoreTextPWD' ) ? $password : 'NULL' ) ;
                     $sql->bindParam ( ':account' , $account , PDO::PARAM_STR ) ;
                     $sql->bindParam ( ':passwd' , md5 ( $password ) , PDO::PARAM_STR ) ;
                     $sql->bindParam ( ':tps' , constant ( 'StartTPoints' ) , PDO::PARAM_INT ) ;
                     $sql->bindParam ( ':pw2' , $pw2 , PDO::PARAM_STR | PDO::PARAM_NULL ) ;
                     if ( $sql->execute ( ) ) {
                            echo 'Ok ...' ;
                     } else echo 'Error ...' ;
              } else {
                     echo 'Account and Password must be filled' ;
              }
       }
?>

First step is to add the extra fields into the HTML form, give them unique and clear names, and then add lines into the PHP above to retrieve them into PHP variables. Once you’ve done that and successfully got the data into the PHP code, then you can worry about checking that the confirm password matches the standard one, and check that the account does not already exist.

There are several ways to achieve the latter - set the appropriate column to ‘unique’ in your database table and check for an error when you try to insert the new row, or do a short query first to see if it is already there.

To clarify, what’s your level of experience with PHP and HTML?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.