473,394 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How can i prevent users from registering twice?

Hey guys so i recently made a registration form for my website, but i have a big problem users are able to register more than once so please if you can help me here's my register sumbit form.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     global $users, $core, $engine;
  3.  
  4.     $errors = array();
  5.     $messages = array();
  6.  
  7.     if(empty($_POST["registrationBean_username"]))
  8.         $errors["registration_username"] = "<br/>Please enter a username!";
  9.     elseif(strlen($_POST["registrationBean_username"]) > 25 || !ctype_alnum($_POST["registrationBean_username"]))
  10.         $errors["registration_username"] = "<br/>Please enter a valid username!";
  11.     elseif($engine->num_rows("SELECT null FROM users WHERE username = '" . $engine->secure($_POST["registrationBean_username"]) . "' LIMIT 1") != 0)
  12.         $errors["registration_username"] = "That username is already taken!";
  13.  
  14.     if(empty($_POST["registrationBean_email"]))
  15.         $errors["registration_email"] = "<br/>Please enter an email address!";
  16.     elseif(!preg_match("/^[a-z0-9_\.-]+@([a-z0-9]+([\-]+[a-z0-9]+)*\.)+[a-z]{2,7}$/i", $_POST["registrationBean_email"]))
  17.         $errors["registration_email"] = "<br/>Please enter a valid email address!";
  18.     elseif($engine->num_rows("SELECT null FROM users WHERE mail = '" . $engine->secure($_POST["registrationBean_email"]) . "' LIMIT 1") != 0)
  19.         $errors["registration_email"] = "<br/>That email address is taken!";
  20.  
  21.     if(empty($_POST['registrationBean_password']))
  22.         $errors["registration_password"] = "<br/>Please enter a password!";
  23.     elseif(strlen($_POST['registrationBean_password']) < 6)
  24.         $errors["registration_password"] = "<br/>Please enter a password with more than 6 characters!";
  25.  
  26.     if(empty($_POST['registrationBean_password_confirm']))
  27.         $errors["registration_password_confirm"] = "<br/>Please enter your password again!";
  28.     elseif(!($_POST['registrationBean_password'] === $_POST['registrationBean_password_confirm']))
  29.         $errors["registration_password_confirm"] = "<br/>Please enter a password with more than 6 characters!";
  30.  
  31.     if($_POST['registrationBean_termsOfServiceSelection'] != "true")
  32.         $errors["registration_termsofservice"] = "Please accept the terms of service.";
  33.  
  34.     $return = array(
  35.         "registrationErrors" => $errors,
  36.         "registrationMessages" => $messages);
  37.  
  38.     if(count($errors) == 0) {
  39.         $users->addUser($engine->secure($_POST["registrationBean_username"]),$core->hashed($_POST['registrationBean_password']),$_POST["registrationBean_email"],$_CONFIG['hotel']['motto'],$_CONFIG['hotel']['credits'],$_CONFIG['hotel']['pixels'],1, $_CONFIG['hotel']['figure'], "M","seckey");
  40.         $users->turnOn($engine->secure($_POST["registrationBean_username"]));
  41.         $return['registrationCompletionRedirectUrl'] = "{$_CONFIG['hotel']['url']}/me";
  42.     }
  43.  
  44.     header('Content-type: application/json'); 
  45.     echo json_encode($return);
  46.     exit;
  47. ?>
Apr 10 '15 #1
2 2257
Luuk
1,047 Expert 1GB
You cannot prevent that, a user always has the possibility to register with another email address, a fake name, etc
Apr 11 '15 #2
This is a spinet from phpocean.com (http://phpocean.com/tutorials/back-e...-a-web-site/15):

Expand|Select|Wrap|Line Numbers
  1. if (!$Model->emailAlreadyUsed($email)) 
  2.                 {
  3.                     if ($Model->addUser($email, $password)) 
  4.                     {
  5.                         session::set('confirmation', 'You have successfully signed up!');
  6.                         // If you want to can send a confirmation email here
  7.  
  8.                     }else{
  9.                         session::set('error_general', 'Something went wrong.');
  10.                     }
  11.                 }else{
  12.                     session::set('error_email', 'This email is already used.');
  13.                 }
  14.  
The only way is to force a user to use only one email for an account.
Apr 17 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: G4Gun | last post by:
Hi, I have a form in which I have this link :- < href="javascript:submitform(parameters );"> . In the JavaScript function submitform, there is the code for submitting the form.Thi works fine with...
7
by: JimO | last post by:
I teach HS computers and one of my kids has a web site with a textbox of info that the user can scroll down and read. The problem is that users can also enter text into it. Is there a way, or a...
4
by: JP SIngh | last post by:
Hi All We have an ASP application which links to various word and excel documents stored in a folder called attachments. The documents are extermely confidential in nature and we would like...
8
by: Dirk | last post by:
Hello, Can anyone tell me what the best way is to prevent an application from starting up twice. Thanks, Dirk
2
by: swbaz | last post by:
What is an effect way to prevent users from viewing a webpage directly by typing in its URL? For example: If a default page is set up as a login screen with user name and password. The user...
2
by: COHENMARVIN | last post by:
I'm writing a database application in asp.net, and I'm worried that the users will sometimes click the BACK button in their browser, thus making some pages re-execute, and possibly messing up the...
6
by: Mark C | last post by:
how do you prevent users from copying ctrl-c content from your textboxes. I know how to do this with IE which is <body onSelectStart="return false;"> but does not work in Mozilla Thanks Mark...
1
by: blumonde | last post by:
Hello, I read an article on "how to prevent users from submitting a form twice." at the url http://www.4guysfromrolla.com/webtech/100406-1.shtml I was able to freeze the web page but was not...
4
by: anewuser | last post by:
Hi, At the risk of repeating myself in other questions. I have a multi-user login screen which works using the following code: Option Compare Database Private Sub Login_Click()...
3
by: moonrb | last post by:
Hi Every one how can i prevent users deleting the record but edit on table when they are viewing datasheet view through "SELECT QUERY" I am using user & password table with VB CODE for securing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.