Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php # search.inc.php
- // Redirect if this page was accessed directly:
- if (!defined('BASE_URL')) {
- // Need the BASE_URL, defined in the config file:
- require_once ('../includes/config.inc.php');
- // Redirect to the index page:
- $url = BASE_URL . 'index.php?p=reg';
- header ("Location: $url");
- exit;
- } // End of defined() IF.
- echo '<h2>Welcome to the register page!</h2>';
- if($_POST) {
- $password = $_POST['password'];
- $confirm = $_POST['confirm'];
- if($password != $confirm) { ?>
- <span style='color:red'>Error: Passwords do not match!</span>
- <?php } else {
- mysql_select_db($dbname);
- $query = sprintf("SELECT COUNT(id) FROM users WHERE UPPER(username) = UPPER('%s')",
- mysql_real_escape_string($_POST['username']));
- $result = mysql_query($query);
- list($count) = mysql_fetch_row($result);
- if($count >= 1) {
- ?>
- <span style='color:red'>Error: that username is taken.</span>
- <?php } else {
- $query = sprintf("INSERT INTO users(username,password) VALUES ('%s','%s');",
- mysql_real_escape_string($_POST['username']),
- mysql_real_escape_string(md5($password)));
- mysql_query($query);
- ?>
- <span style='color:green'>Congratulations, you registered successfully!</span>
- <?php
- }
- }
- }
- ?>
- <br /><br /><br /><form method='post' action='modules/reg.inc.php'>Username: <input type='text' name='username' /><br />
- Password: <input type='password' name='password' /><br />
- Confirm Password: <input type='password' name='confirm' /><br />
- <input type='submit' value='Register!' />
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement