Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
* * * * * 3 votes

Creating A Simple Yet Secured Login/registration With Php5

encryption registration login

  • Please log in to reply
113 replies to this topic

#85 Sundance

Sundance

    CC Devotee

  • Validating
  • PipPipPipPipPipPip
  • 572 posts
  • Programming Language:C, Java, PHP, Python, JavaScript, Perl, PL/SQL, Transact-SQL, Bash, Others

Posted 04 September 2014 - 11:20 AM

This is what i get when i try to create the database.

 

Error

SQL query:

 

CREATE DATABASE `codecalltut` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;

 

MySQL said: dot.gif

#1044 - Access denied for user 'pryehost'@'localhost' to database 'codecalltut' 

 

Your username is invalid, check the MySQL settings.


  • 0

Please read the

FaQ & Guidelines


#86 flamelier

flamelier

    CC Lurker

  • New Member
  • Pip
  • 3 posts

Posted 05 September 2014 - 09:21 AM

Your username is invalid, check the MySQL settings.

Ok I think I created a new user called root and made a passcode where do I put the passcode? also i was useing myphpadmin to make the thing i use mysql to create the user.

Do I need to create it in phpmyadmin? If so how?

Version of PHPMyAdmin is 4.1.8

 

When I use cPanel to get to MyPHPAdmin it says \/ On the right.

  • User: pryehost@localhost

Edited by flamelier, 05 September 2014 - 09:33 AM.

  • 0

#87 Alexander

Alexander

    YOL9

  • Moderator
  • 3963 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 05 September 2014 - 02:37 PM

Beginners may not understand that PHPMyAdmin is simply a PHP frontend to modifying an SQL database. Anything done in PHPMyAdmin can be done in a PHP script (because in fact it is simply a script itself,) and can be done in mysql itself. In fact, PHPMyAdmin has a box where you can enter raw queries, and view the output afterwards.

 

 

i use mysql to create the user.

 

- Then you have simply chosen not to create the user through PHPMyAdmin. It will still be visible to anything accessing the database (i.e. by root, through PHPM.A. or mysql -u root , or by logging in with said user within a PHP script, or with mysql -u user.)

 

 

and made a passcode where do I put the passcode?

 

Every connection line in PHP to a database server should provide a means to supply a username, passcode, and possibly database. PHPMyAdmin will have global access to all databases, your script will not, and so you will have to log in to your user with its own user/pass and in to its own database to keep things tidy and isolated.

 

Alexander.


Edited by Alexander, 05 September 2014 - 02:52 PM.

  • 1

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.


#88 flamelier

flamelier

    CC Lurker

  • New Member
  • Pip
  • 3 posts

Posted 08 September 2014 - 03:57 AM

Beginners may not understand that PHPMyAdmin is simply a PHP frontend to modifying an SQL database. Anything done in PHPMyAdmin can be done in a PHP script (because in fact it is simply a script itself,) and can be done in mysql itself. In fact, PHPMyAdmin has a box where you can enter raw queries, and view the output afterwards.

 

 

- Then you have simply chosen not to create the user through PHPMyAdmin. It will still be visible to anything accessing the database (i.e. by root, through PHPM.A. or mysql -u root , or by logging in with said user within a PHP script, or with mysql -u user.)

 

 

Every connection line in PHP to a database server should provide a means to supply a username, passcode, and possibly database. PHPMyAdmin will have global access to all databases, your script will not, and so you will have to log in to your user with its own user/pass and in to its own database to keep things tidy and isolated.

 

Alexander.

 

I'm sorry what?


  • 0

#89 DesigningThings

DesigningThings

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 01 October 2014 - 01:21 AM

I've tried 100's of login scripts over the years, this is the most simple of scripts out there and is well presented! Thanks you've ended a lot of misery.


  • 0

#90 TartanSpartan

TartanSpartan

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts
  • Location:Somewhere, probably coding
  • Programming Language:PHP, JavaScript, Others
  • Learning:PHP, JavaScript

Posted 13 October 2014 - 03:38 AM

This is a great little tutorial for a PHP beginner like myself and managed to get it working quite easily.

 

I wanted to add a unique key for the username field and did this in the SQL, but I want to edit the following registration code to include an echo for "Username already exists"

 

<?php 
 
//if register button was clicked.
} else {
$usr = new Users; //create new instance of the class Users
$usr->storeFormValues( $_POST ); //store form values
 
//if the entered password is match with the confirm password then register him
if( $_POST['password'] == $_POST['conpassword'] ) {
echo $usr->register($_POST); 
} else {
//if not then say that he must enter the same password to the confirm box.
echo "Password and Confirm password not match"; 
}
}
?>
 
As I'm still getting to grips with PHP, I have made a few failed attempts. Can anyone help?

  • 0

#91 Alexander

Alexander

    YOL9

  • Moderator
  • 3963 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 16 October 2014 - 12:06 AM

 

This is a great little tutorial for a PHP beginner like myself and managed to get it working quite easily.

 

I wanted to add a unique key for the username field and did this in the SQL, but I want to edit the following registration code to include an echo for "Username already exists"

 

 

Sorry for the late reply.

 

Could you not search the database (WHERE `username` = ...) and see if it returns an existing user?

 

Alexander.


  • 1

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.


#92 TartanSpartan

TartanSpartan

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts
  • Location:Somewhere, probably coding
  • Programming Language:PHP, JavaScript, Others
  • Learning:PHP, JavaScript

Posted 16 October 2014 - 01:08 AM

Sorry for the late reply.

 

Could you not search the database (WHERE `username` = ...) and see if it returns an existing user?

 

Alexander.

 

No worries, I'll give that a go. Thanks!


  • 0

#93 sschucktown

sschucktown

    CC Lurker

  • New Member
  • Pip
  • 4 posts
  • Programming Language:Java, Python
  • Learning:PHP, JavaScript, PL/SQL

Posted 20 October 2014 - 11:25 AM

Really enjoyed this tutorial as I am currently learning php.  I know there have been somewhat similar questions about adding sessions to the existing code, but how would I go about adding a profile page using sessions and the register information in the database?  Thank you guys so much for your time one this!


  • 0

#94 papabear

papabear

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 472 posts
  • Location:DarkSide

Posted 20 October 2014 - 05:21 PM

I'm so glad that there are so many people who liked this simple tutorial.Please enjoy yourself and have a great day coding.

 

@sschuctown, just create a profile page and store a session and check if the session is valid using IF statement, then redirect the user into his profile page.


  • 1
Life has no CTRL+Z
Never Forget To HIT "LIKE" If I Helped

#95 sschucktown

sschucktown

    CC Lurker

  • New Member
  • Pip
  • 4 posts
  • Programming Language:Java, Python
  • Learning:PHP, JavaScript, PL/SQL

Posted 21 October 2014 - 11:36 AM

Thanks for the reply, I have sessions initiated, but what would a secure syntax look like for this with the existing code?  Upon login, would I redirect using header() function with the incremented userID and sessions?  If you could show me an example of how you would do it to start me off, that would be extremely helpful.  Thank you again for your time.


  • 0

#96 Graphene

Graphene

    CC Regular

  • Member
  • PipPipPip
  • 34 posts
  • Learning:C, C++, Python, JavaScript

Posted 24 October 2014 - 07:32 PM

i know using a salt is good practise, but what if a password were stolen? would sha256 be good enough with the salt?


  • 0

Some things are just intuitive :P Some are...very not.






Also tagged with one or more of these keywords: encryption, registration, login

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download