[php]<?php
include_once(“php_include/check_login_status.php”);
?><?php
// Ajax calls this NAME CHECK code to execute
if(isset($_POST[“usernamecheck”])){
include_once(“php_include/db_connect.php”);
$username = preg_replace(’#[^a-z0-9]#i’, ‘’, $_POST[‘usernamecheck’]);
$sql = “SELECT id FROM users WHERE username=’$username’ LIMIT 1”;
$query = mysqli_query($db_conx, $sql);
$uname_check = mysqli_num_rows($query);
if (strlen($username) < 3 || strlen($username) > 16) {
echo ‘3 - 16 characters please’;
exit();
}
if (is_numeric($username[0])) {
echo ‘Usernames must begin with a letter’;
exit();
}
if ($uname_check < 1) {
echo ‘’ . $username . ’ is OK’;
exit();
} else {
echo ‘’ . $username . ’ is taken’;
exit();
}}
?><?php
// Ajax calls this REGISTRATION code to execute
if(isset($_POST[‘u’])){
// CONNECT TO THE DATABASE
include_once(“php_include/db_connect.php”);
// GATHER THE POSTED DATA INTO LOCAL VARIABLES
$u = preg_replace(’#[^a-z0-9]#i’, ‘’, $_POST[‘u’]);
$e = mysqli_real_escape_string($db_conx, $_POST[‘e’]);
$p = $_POST[‘p’];
$g = preg_replace(’#[^a-z]#’, ‘’, $_POST[‘g’]);
$c = preg_replace(’#[^a-z ]#i’, ‘’, $_POST[‘c’]);
// GET USER IP ADDRESS
$ip = preg_replace(’#[^0-9.]#’, ‘’, getenv(‘REMOTE_ADDR’));
// DUPLICATE DATA CHECKS FOR USERNAME AND EMAIL
$sql = “SELECT id FROM users WHERE username=’$u’ LIMIT 1”;
$query = mysqli_query($db_conx, $sql);
$u_check = mysqli_num_rows($query);
// -------------------------------------------
$sql = “SELECT id FROM users WHERE email=’$e’ LIMIT 1”;
$query = mysqli_query($db_conx, $sql);
$e_check = mysqli_num_rows($query);
// FORM DATA ERROR HANDLING
if($u == “” || $e == “” || $p == “” || $g == “” || $c == “”){
echo “The form submission is missing values.”;
exit();
} else if ($u_check > 0){
echo “The username you entered is alreay taken”;
exit();
} else if ($e_check > 0){
echo “That email address is already in use in the system”;
exit();
} else if (strlen($u) < 3 || strlen($u) > 16) {
echo “Username must be between 3 and 16 characters”;
exit();
} else if (is_numeric($u[0])) {
echo ‘Username cannot begin with a number’;
exit();
} else {
// END FORM DATA ERROR HANDLING
// Begin Insertion of data into the database
// Hash the password and apply your own mysterious unique salt
$p_hash=md5($p);
// Add user info into the database table for the main site table
$sql = “INSERT INTO users (username, email, password, gender, country, ip, signup, lastlogin, notescheck,avatar)
VALUES(’$u’,’$e’,’$p_hash’,’$g’,’$c’,’$ip’,now(),now(),now(),‘avatardefault.jpg’)”;
$query = mysqli_query($db_conx, $sql);
$uid = mysqli_insert_id($db_conx);
// Establish their row in the useroptions table
$sql = “INSERT INTO useroptions (id, username, background) VALUES (’$uid’,’$u’,‘original’)”;
$query = mysqli_query($db_conx, $sql);
// Create directory(folder) to hold each user’s files(pics, MP3s, etc.)
if (!file_exists(“user/$u”)) {
mkdir(“user/$u”, 0755);
}
$avatar=“images/avatardefault.jpg”;
$avatar2=“user/$u/avatardefault.jpg”;
if(!copy($avatar,$avatar2)){
echo"failed to create avatar";
}
// Email the user their activation link
$to = “$e”;
$from = “admin@localhost”;
$subject = ‘Hello.com account avtivation’;
$message = ‘Hello.com Message
Click the link below to activate your account when ready:
Click here to activate your account now
Login after successful activation using your:
* E-mail Address: ‘.$e.’
$headers = “From: $from\n”;
$headers .= “MIME-Version: 1.0\n”;
$headers .= “Content-type: text/html; charset=iso-8859-1\n”;
mail($to, $subject, $message, $headers);
echo “signup_success”;
exit();
}
exit();
}
?> Hello.com #signupform { margin-top: 0px; margin-left: 632px; font-family: Tahoma, Geneva, sans-serif; } #signupform > div { margin-top: 12px; } #signupform > input,select { width: 200px; padding: 3px; background: #F3F9DD; } #signupbtn { font-size:18px; padding: 12px; } #terms { border:#CCC 1px solid; background: #F5F5F5; padding: 12px; } #sname { margin-left: 750px; } <?php include_once("header.php"); ?>
Sign Up Here
Web Intersect Terms Of Use
1. Play nice here.
2. Take a bath before you visit.
3. Brush your teeth before bed.
Create Account
After filling all credentials when i click on create account button the message appear pls fill all the data fields!!! this is happening on index page but on signup page which i created separately it is working perfectly fine. i will be realy thank ful if you guys can help me.