15,917,174 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by US RSA (Top 6 by date)
US RSA
23-Apr-22 14:13pm
View
register($username, $firstName, $lastName, $email, $email2, $password, $password2);
if($wasSuccessful == true) {
$_SESSION['userLoggedIn'] = $username;
header("Location: index.php");
}
}
?>
US RSA
23-Apr-22 14:11pm
View
Deleted
register($username, $firstName, $lastName, $email, $email2, $password, $password2);
if($wasSuccessful == true) {
$_SESSION['userLoggedIn'] = $username;
header("Location: index.php");
}
}
?>
US RSA
23-Apr-22 14:10pm
View
con = $con;
$this->errorArray = array();
}
public function login($un, $pw) {
$pw = md5($pw);
$query = mysqli_query($this->con, "SELECT * FROM users WHERE username='$un' AND password='$pw'");
if(mysqli_num_rows($query) == 1) {
return true;
}
else {
array_push($this->errorArray, Constants::$loginFailed);
return false;
}
}
public function register($un, $fn, $ln, $em, $em2, $pw, $pw2) {
$this->validateUsername($un);
$this->validateFirstName($fn);
$this->validateLastName($ln);
$this->validateEmails($em, $em2);
$this->validatePasswords($pw, $pw2);
if(empty($this->errorArray) == true) {
//Insert into db
return $this->insertUserDetails($un, $fn, $ln, $em, $pw);
}
else {
return false;
}
}
public function getError($error) {
if(!in_array($error, $this->errorArray)) {
$error = "";
}
return "
$error
";
}
private function insertUserDetails($un, $fn, $ln, $em, $pw) {
$encryptedPw = md5($pw);
$profilePic = "assets/images/profile-pics/head_emerald.png";
$date = date("Y-m-d");
$result = mysqli_query($this->con, "INSERT INTO users VALUES ('', '$un', '$fn', '$ln', '$em', '$encryptedPw', '$date', '$profilePic')");
return $result;
}
private function validateUsername($un) {
if(strlen($un) > 25 || strlen($un) < 5) {
array_push($this->errorArray, Constants::$usernameCharacters);
return;
}
$checkUsernameQuery = mysqli_query($this->con, "SELECT username FROM users WHERE username='$un'");
if(mysqli_num_rows($checkUsernameQuery) != 0) {
array_push($this->errorArray, Constants::$usernameTaken);
return;
}
}
private function validateFirstName($fn) {
if(strlen($fn) > 25 || strlen($fn) < 2) {
array_push($this->errorArray, Constants::$firstNameCharacters);
return;
}
}
private function validateLastName($ln) {
if(strlen($ln) > 25 || strlen($ln) < 2) {
array_push($this->errorArray, Constants::$lastNameCharacters);
return;
}
}
private function validateEmails($em, $em2) {
if($em != $em2) {
array_push($this->errorArray, Constants::$emailsDoNotMatch);
return;
}
if(!filter_var($em, FILTER_VALIDATE_EMAIL)) {
array_push($this->errorArray, Constants::$emailInvalid);
return;
}
$checkEmailQuery = mysqli_query($this->con, "SELECT email FROM users WHERE email='$em'");
if(mysqli_num_rows($checkEmailQuery) != 0) {
array_push($this->errorArray, Constants::$emailTaken);
return;
}
}
private function validatePasswords($pw, $pw2) {
if($pw != $pw2) {
array_push($this->errorArray, Constants::$passwordsDoNoMatch);
return;
}
if(preg_match('/[^A-Za-z0-9]/', $pw)) {
array_push($this->errorArray, Constants::$passwordNotAlphanumeric);
return;
}
if(strlen($pw) > 30 || strlen($pw) < 5) {
array_push($this->errorArray, Constants::$passwordCharacters);
return;
}
}
}
?>
US RSA
23-Apr-22 14:10pm
View
<title>TEST
$(document).ready(function() {
$("#loginForm").hide();
$("#registerForm").show();
});
';
}
else {
echo '
$(document).ready(function() {
$("#loginForm").show();
$("#registerForm").hide();
});
';
}
?>
Login to your account
getError(Constants::$loginFailed); ?>
Username
Password
LOG IN
Don't have an account yet? Signup here.
Create your free account
getError(Constants::$usernameCharacters); ?>
getError(Constants::$usernameTaken); ?>
Username
getError(Constants::$firstNameCharacters); ?>
First name
getError(Constants::$lastNameCharacters); ?>
Last name
getError(Constants::$emailsDoNotMatch); ?>
getError(Constants::$emailInvalid); ?>
getError(Constants::$emailTaken); ?>
Email
Confirm email
getError(Constants::$passwordsDoNoMatch); ?>
getError(Constants::$passwordNotAlphanumeric); ?>
getError(Constants::$passwordCharacters); ?>
Password
Confirm password
SIGN UP
Already have an account? Log in here.
Local, for sure.
Listen to loads of songs for free
Discover music you'll fall in love with Create your own playlists Follow artists to keep up to date
US RSA
23-Apr-22 14:08pm
View
lol, thank you replying ... i cannot get myphpadmin database to update after registering
US RSA
23-Apr-22 14:08pm
View
lol, thank you replying ... i cannot get myphpadmin database to update after registering
Show More