Giter Site home page Giter Site logo

Comments (12)

therecluse26 avatar therecluse26 commented on July 25, 2024 1

Interesting, basically, you can just use the "createUser" method of the
"NewUser" class and pass the username, email and password into it. This is
what inserts the user into the database. You'll have to encrypt the
password first using this built in php function, but that should work
without any major problems.

   $pw = password_hash($_GET['pw'], PASSWORD_DEFAULT);

I've slightly refactored this in the next release I made and included the
password hashing within the createUser method itself, but in the current
version, this occurs outside of that method.

Keep an eye out for updates, I'm getting very close to a new release.

On Tue, Nov 22, 2016 at 8:14 AM, quavoce [email protected] wrote:

  • bradley david

from php-login.

fethica avatar fethica commented on July 25, 2024

Hi @quavoce !

Thanks for using PHP-Login in your project, this script is not intended to work as a bash command line, but you can create a simple php file (at your own risk) to add users manually and here is an example (adduser.php in the project root directory) :

<?php

echo 'Enter username: ';

$usr = readline();

echo 'Enter email: ';

$email = readline();

echo 'Enter password: ';

$pw1 = readline();

echo 'Confirm password: ';

$pw2 = readline();

// Do some checks you can add more to make it more secure
if (isset($usr) && isset($email) && isset($pw1) && isset($pw2) && ($pw1 == $pw2)) {

    include_once 'login/dbconf.php';

    $uid = uniqid(rand(), false);
    $pw = password_hash($pw1, PASSWORD_DEFAULT);

    try {

        $db = new PDO('mysql:host='.$host.';dbname='.$db_name.';charset=utf8', $username, $password);
        $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        
        // verified attribute is 0 (Default) in your case you don't need an email check activation so you put 1
        $stmt = $db->prepare("INSERT INTO ".$tbl_members." (id, username, password, email, verified)
        VALUES (:id, :username, :password, :email, 1)");

        $stmt->bindParam(':id', $uid);
        $stmt->bindParam(':username', $usr);
        $stmt->bindParam(':password', $pw);
        $stmt->bindParam(':email', $email);

        $stmt->execute();
        $err = '';

    } catch (PDOException $e) {

        $err = "Error: " . $e->getMessage();

    }

    if ($err == '') {

        $success = 'User has been created successfully and is ready to use.';

    } else {

        $success = $err;

    }

    echo $success."\n";
}

You call the script via bash:

PHP-Login$ php adduser.php 

I hope this will help,

from php-login.

quavoce avatar quavoce commented on July 25, 2024

Thank you very much both fethica and therecluse26! I'll have a go with this later today.

from php-login.

quavoce avatar quavoce commented on July 25, 2024

I've attempted to run the php script from fethica but I end up with the following error:

pi@pidev3:~/PHP-Login $ php adduser.php
Enter username: quavoce
Enter email: [email protected]
Enter password: password
Confirm password: password
Error: could not find driver

I'm running this from within the PHP-Login project directory. Unfortunately I'm not a PHP developer so not sure how to troubleshoot this...?

Thanks.

from php-login.

therecluse26 avatar therecluse26 commented on July 25, 2024

Are you running this from command line?

On Wed, Nov 23, 2016 at 11:30 AM, quavoce [email protected] wrote:

troubleshoot

  • bradley david

from php-login.

quavoce avatar quavoce commented on July 25, 2024

Yep - I have a suspicion it's something to do with PDO drivers. This is what my php -i shows.

PDO

PDO support => enabled
PDO drivers => sqlite

pdo_sqlite

PDO Driver for SQLite 3.x => enabled
SQLite Library => 3.8.7.1

I'll do some more digging.

from php-login.

therecluse26 avatar therecluse26 commented on July 25, 2024

We haven't designed this app to run in the command line, so I can't
guarantee that any of it will work, sorry. It would require a major
overhaul.

On Wed, Nov 23, 2016 at 11:39 AM, quavoce [email protected] wrote:

Yep - I have a suspicion it's something to do with PDO drivers. This is
what my php -i shows.

PDO

PDO support => enabled
PDO drivers => sqlite

pdo_sqlite

PDO Driver for SQLite 3.x => enabled
SQLite Library => 3.8.7.1

I'll do some more digging.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#43 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AH24AjiYVI7PfGVSepa7V5KvFKYYbKr-ks5rBGwlgaJpZM4K5Z1L
.

  • bradley david

from php-login.

quavoce avatar quavoce commented on July 25, 2024

No problems, I suspect I've not installed PHP/MySQL properly because it's not working via the web interface either at the moment. I'll look into it this evening.

I would like to explore your first suggestion made earlier if possible please (to avoid the command line), but I don't really know how to implement it. I'm essentially looking for a PHP web page that will let me register a new user without doing an email verification for testing purposes. I wouldn't keep this page due to a security risk so would only use it on a temporary basis to create a new user.

Thanks for your help!!

from php-login.

therecluse26 avatar therecluse26 commented on July 25, 2024

Yeah, check your php.ini file and make sure that you have the appropriate
pdo drivers for mysql installed and configured.

To implement the solution that we suggested before, all you'll need is a
web server running PHP such as Apache or Nginx, and then you'll just drop
the PHP-Login project folder into the application root directory (htdocs,
usually) and access it from a browser

On Wed, Nov 23, 2016 at 12:06 PM, quavoce [email protected] wrote:

I would like to explore your first suggestion made earlier if possible
please (to avoid the command line), but I don't really know how to
implement it. I'm essentially looking for a PHP web page that will let me
register a new user without doing an email verification for testing
purposes. I wouldn't keep this page due to a security risk so would only
use it on a temporary basis to create a new user.

  • bradley david

from php-login.

quavoce avatar quavoce commented on July 25, 2024

I'd missed out installing php5-mysql so all working now. :)

Looking forward to your new updates - I really like what you've already done. I also like the fact you're actively working on fixing issues and improving the code - it makes your project stand out from all the other PHP Login projects on here!

from php-login.

therecluse26 avatar therecluse26 commented on July 25, 2024

Thanks! This next update is going to be a big one with a lot more features,
so definitely keep an eye out! :)

On Wed, Nov 23, 2016 at 3:12 PM, quavoce [email protected] wrote:

I'd missed out installing php5-mysql so all working now. :)

Looking forward to your new updates - I really like what you've already
done. I also like the fact you're actively working on fixing issues and
improving the code - it makes your project stand out from all the other PHP
Login projects on here!


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#43 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AH24AteKLgb7npMegyOXL7iTNhigBRgRks5rBJ4dgaJpZM4K5Z1L
.

  • bradley david

from php-login.

fethica avatar fethica commented on July 25, 2024

Welcome! I'm glad it worked 👍

from php-login.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.