Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //REGISTER.PHP
- <form name="login" method="post" action="registernext.php">
- <p>Username: <input type ="text" name="useregister" size = "15" maxlength = "25" value = ""/></p>
- <p>Password: <input type = "password" name="passwordregister" size = "15" maxlength = "25" value =""/></p>
- <p>Confirm Password:
- <input type = "password" name="pass2" size = "15" maxlength = "25" value =""/></p>
- <p>
- <input type ="submit" name ="submit" value="Register"/>
- </p>
- </form>
- //REGISTERNEXT.PHP
- <?php
- include('config.php');
- include('register.php');
- //test to see if username is alphannumberic
- $user=$_REQUEST['useregister'];
- $pass=$_REQUEST['passwordregister'];
- $conf=$_REQUEST['pass2'];
- if ($pass != $conf) {
- //pass and confirm don't equal each other
- }
- if(!preg_match('/[^A-Za-z0-9]/ i' , $test)){
- //test for duplicate names
- $query="SELECT * FROM usernames WHERE username ='$user'";
- $result=mysql_query($query);
- $num=mysql_num_rows($result);
- if ($num == 0){
- //insert users into table
- $sql="INSERT INTO users SET useregister = '$user', passwordregister = '$pass'";
- $result=mysql_query($sql);
- //Shows "Thanks for registering" page
- header("Location:thanksreg.html");
- }else{
- header("Location:nameinuse.html");
- }
- }else{
- header("Location:invalidname.html");
- }
- ?>
- //CONFIG.PHP
- <?php
- $host="localhost";//hostname
- $usernamesql="HIDDEN";//username
- $passwordsql="HIDDEN";//database password
- $db_name="fronkcra_users";//database name
- //connect to database
- mysql_connect("$host","$usernamesql","$passwordsql")or die("cannot connect to server");
- mysql_select_db("$db_name")or die("cannot select DB");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement