Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- register page to check if user exist in sql server 2012 using ODBC and php
- <?php
- include 'core/database/conn.php';
- include 'includes/overall/header.php';
- // Process the POST data.
- if (isset($_POST['log22'])){
- $username = $_POST['username'];
- $password = $_POST['password'];
- $confirm_password = $_POST['confirm'];
- $email = $_POST['email'];
- //echo $getemail;
- //echo "<script>alert('The Email is already registered');</script>";
- $id=md5(rand(1,123));
- $id='ADM'.strtoupper(substr($id,0,10));
- $username = strtoupper($username);
- $password = substr(md5($password),0,9);
- $email = strtoupper($email);
- //header ('Location: register.php');
- $sql = "INSERT INTO[ICPAK_FORMS].[dbo].[ICPAK$User Register](
- [ID],[Username],[Password],[Email])
- VALUES ('$id','$username','$password','$email')";
- global $DBCONN;
- odbc_exec($DBCONN,$sql);
- }
- ?>
- <h1>Register</h1>
- <!----><script type="text/javascript" src="js/regform.js"></script>
- <form id="formreg" name="formreg" method="post" action="register.php" onSubmit="return regformValidation()">
- <ul>
- <li>
- Username:<br/><input type="text" name="username" value="<?php //if(isset($_POST['username'])){ echo $_POST['username']; } ?>"/>
- </li>
- <li>
- Password:<br/> <input minlength="5" type="password" name="password" value="<?php //if(isset($_POST['password'])){ echo $_POST['password']; } ?>"/>
- </li>
- <li>
- Confirm Password:<br/><input type="password" name="confirm" value="<?php //if(isset($_POST['confirm'])){ echo $_POST['confirm']; } ?>" />
- </li>
- <li>
- E-mail<br/>
- <input type="text" name="email" id="email" value="<?php if(isset($_POST['email'])){ echo $_POST['email']; } ?>"/>
- </li>
- <li>
- <input type="submit" value="submit" /><input type="hidden" name="log22" id="log22" value="Login" /></td>
- </li>
- <li>
- <table>
- <tr><td colspan="2">If you are registered click <a href="login.php">here</a> to Login</td><tr>
- </table>
- </li>
- </ul>
- </form>
- <?php include 'includes/overall/footer.php';?>
- $sql_select = "select * from [ICPAK_FORMS].[dbo].[ICPAK$User Register] where [Username] = $username";
- $queryresult = odbc_exec($DBCONN,$sql_select);
- if ( odbc_num_rows($queryresult) > 0 ) {
- {
- // code for insert
- }
- else {
- // show error that username already exist.
- }
- $result = odbc_exec( $connection, "SELECT username FROM users_table WHERE username like '$username' ");
- if ( odbc_num_rows($queryresult) > 0) {
- echo 'User with this name already exist.. Please select a different username';
- ....
- ....
- // your logic what you want to do after that
- }
- else{
- //Save and Register User
- }
Add Comment
Please, Sign In to add comment