Jump to content

registration script issue


Eggzorcist

Recommended Posts

I made a script in which registrates a user very basicly. here are the functions used.

 

I click submit get no error but it doesnt do anything to the databse nor does it send me the the url as indicated in the header();

 

 

<?php
require_once('config.php');

function secure_var($var){

$var = mysql_real_escape_string(htmlentities($var));

}

function check_username($username){

$query = mysql_query("SELECT * FROM user_info WHERE username = {$username}");

if ($query >= 1){

return true;

}

else {

return false; }

}


function check_email($email){

$query = mysql_query("SELECT * FROM user_info WHERE email = {$email}");

if ($query >= 1){

return true;

}

else {

return false; }


}


// Register User
function register_user($username, $password1, $password2, $email, $captcha){

secure_var($username);
secure_var($password1);
secure_var($password2);
secure_var($email);

$Error = null;

// Validate Username Field
if(!preg_match("/\A[a-z0-9_]{4,15}$/i",$username)){
	$Error .= "Username Can Only Contain Letters, Numbers and Underscores (Between 4-15 Characters Long) <br />";
}

// Validates Username Availability
if(check_username($username) == true){

$Error .= "You're chosen username is taken. Plase choose another one.<br />";

}

// Validates Email Availability
if (check_email($email) == true){

$Error .= "You're email is already in use.<br />";

} 

// Validate Password Field
if (!preg_match("/\A[a-z0-9 _-]{4,15}$/i",$password1)){
	$Error .= "Password Can Only Contain Letters, Numbers, And Underscores (Between 4-15 Characters Long <br />";
}

// Validate Password Confirmation
if ($password1 != $password2){
	$Error .= "Password and Password Confirmation Do Not Match <br />";
}

// Validate Email Address Format
if (!preg_match("/\A[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/", $email)){
	$Error .= "Email Address Must Be In format: [username]@[domain].[extension] <br />";
}

// Validate Security Image
if ($captcha != $_SESSION['captcha']){
	$Error .= "Your Captcha Input Does Not Match The Image Shown";
}		

// Result Success or Error
if($Error == null){


	$reg_user = mysql_query("INSERT INTO user_info (username, password, email) VALUES ($username, $password, $email)");

	if($reg_user){
	header('login.php?reg=1');
	}

}else{
	// Echo the error(s)
	echo($Error);
}
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.