473,386 Members | 1,846 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,386 software developers and data experts.

Secure Passwords

Here:

Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. session_start(); 
  3. include_once "incfiles/connectdb.php"; 
  4.  
  5. $rand1 = rand(0,100);
  6. $rand2 = rand(0,100);
  7. $answer = $rand1 + $rand2;
  8.  
  9. if ($_POST['SubmitReg']){
  10. $additional08989 = $_POST['additional']; 
  11. $answers = $_POST['answers']; 
  12. $register_user = $_POST['register_user']; 
  13. $register_pass = $_POST['register_pass']; 
  14. $register_pass2 = $_POST['register_pass2']; 
  15. $register_gender = $_POST['register_gender']; 
  16. $register_email = $_POST['register_email'];
  17. $register_email2 = $_POST['register_email2']; 
  18. $register_location=strip_tags($_POST['register_location']); 
  19. $register_user=trim($register_user);
  20. $register_pass=trim($register_pass); 
  21.  
  22. $today = gmdate('Y-m-d H:i:s');
  23.  
  24. $register_user = stripslashes($register_user); 
  25. $register_email = stripslashes($register_email); 
  26. $quote = stripslashes($quote); 
  27. $register_user = strip_tags($register_user); 
  28. $register_email = strip_tags($register_email); 
  29. $number = $_POST['equals'];
  30.  
  31. if ($additional08989 != "GANCY78"){ echo "Use your head bro."; }
  32. elseif ($additional08989 == "GANCY78"){
  33.  
  34. if((!$register_user) || (!$register_email) || (!$register_location) || (!$register_pass)){ 
  35. echo "Please fill in all of the fields."; }else{
  36.  
  37. if ($number != "$answers"){ echo "Are you stupid bro? The answer is not $number."; }
  38. elseif ($number == "$answers"){
  39.  
  40.  
  41. if ($register_pass != $register_pass2){
  42. echo "The passwords you entered do not match.";
  43. }elseif ($register_pass == $register_pass2){
  44.  
  45.  
  46. if ($register_email != $register_email2){
  47. echo "The emails you entered do not match.";
  48. }elseif ($register_email == $register_email2){
  49.  
  50. if ($register_user == "0"){ echo "Haha good joke, now try using an actual name?"; }
  51. elseif ($register_user != "0"){ 
  52.  
  53. if (ereg('[^A-Za-z0-9 _]', $register_user)) {  
  54. echo "You can't use symbols in your name.";
  55. }elseif (!ereg('[^A-Za-z0-9 _]', $register_user)) { 
  56.  
  57. if (strlen($register_user) <= 2 || strlen($register_user) >= 20){
  58. echo  "The username you entered is too big or too small.";
  59. }elseif (strlen($register_user) > 2 || strlen($register_user) < 20){
  60.  
  61. $email_check = mysql_query("SELECT email FROM accounts WHERE email='$register_email' AND status='Alive'"); 
  62. $username_check = mysql_query("SELECT username FROM accounts WHERE username='$register_user'"); 
  63.  
  64. $register_email_check = mysql_num_rows($email_check); 
  65. $username_check = mysql_num_rows($username_check); 
  66.  
  67. if(($register_email_check > 0) || ($username_check > 0)){  
  68.  
  69. if($register_email_check > 0){ 
  70. echo  "Some other gangster is already running that email address."; unset($register_email); } 
  71. if($username_check > 0){ 
  72. echo "some other gangster is already running that name."; unset($register_user); } 
  73.  
  74. }else{ 
  75.  
  76. $ip = $_SERVER['REMOTE_ADDR'];
Feb 10 '14 #1
5 1207
Dormilich
8,658 Expert Mod 8TB
I'm with one.com so it doesn't show me what line my errors on but I still can't seem to figure out how to secure this.
ini_set() and php_flags disabled?

If there's anything you can suggest/help me with it'd be appreciated.
use Prepared Statements, they’re immune to SQL Injection.

ah, yes, passwords should always be hashed before storing in a DB, that should render SQL Injection useless as well (if applied in PHP).

as a last resort you could use a RegExp to find invalid characters.
Feb 11 '14 #2
Could you show me a quick example in code as to what I'd be doing if it's okay?
Feb 11 '14 #3
Dormilich
8,658 Expert Mod 8TB
there is too few information for anything code related.
Feb 11 '14 #4
can you see from line 41 all it decides is whether the password for the first box and the verify password box are the same.. I want it to be limited so you can only have passwords using, letters(lowercase&uppercase), numbers, underscores and dashes
Feb 13 '14 #5
Wait, sorry make that:

A-Z
a-z
0-9
underscores > (_)
dashes > (-)
fullstops > .
slash > /
Feb 13 '14 #6

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

Similar topics

11
by: Florian Lindner | last post by:
Hello, I've a scripts that allows limited manipulation of a database to users. This script of course needs to save a password for the database connection. The users, on the other hand need read...
2
by: Peter Rilling | last post by:
How does Windows store passwords that it uses? For instance, when you install a service, you can provide it the username and password. This information is stored somehow so that at a later date...
3
by: John Buchmann | last post by:
In my web.config, I have a section that has a name and password: <credentials passwordFormat="Clear"> <user name="aaa" password="bbb" /> </credentials> Is this secure? What is to stop...
6
by: VB Programmer | last post by:
I am creating a new ASPX web app. I would like to use MS Access, but am concerned about security. There will be alot of secure info in this db (credit cards, passwords, client info, etc...) Is...
6
by: Notgiven | last post by:
I am considering a large project and they currently use LDAP on MS platform. It would be moved to a LAMP platform. OpenLDAP is an option though I have not used it before. I do feel fairly...
4
by: Alvaro G. Vicario | last post by:
I’m writing a web application that needs to keep passwords in a database. These passwords are for third-party services and are different from the regular login passwords. I don’t like...
14
by: Usman | last post by:
Hi I'm working on an application that contains classes for licensing, authentication etc, including all the algorithms of encryption/decryption etc. I wanted to secure this code, but after...
0
by: scoomey | last post by:
Hi folks- I've got an interesting problem. For our homebrewed PHP intranet application, I will soon be required to give users access to their email/calendar information from Microsoft Exchange....
19
by: Cord-Heinrich Pahlmann | last post by:
Hi, I have written a tool wich de/encrypts a few of my forum and bloggin-Passwords. My question is how secure it is. The following describes how I have encrypted my passwords. When I log in,...
1
by: | last post by:
I've written code for encrpting files, but I can't seem to find examples where the password is secure from user input to wiping it from memory after decryption. Is this atually possible in c#?...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.