Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

login authentication

by window (Initiate)
on Dec 12, 2017 at 04:59 UTC ( [id://1205331]=perlquestion: print w/replies, xml ) Need Help??

window has asked for the wisdom of the Perl Monks concerning the following question:

Hello Perl monks,

I was wondering, as a beginner, on how to make a Perl script that checks if the account and password match the stored values in the MySQL table so it will proceed? else, it won't proceed ?

#table l---------l----------l l_account_l_password_l l---------l----------l l__name___l___123____l l---------l----------l #form <form method="get" action="" onsubmit="return formValidation(this)"> Account: <input type="text" name="account"><br> Password: <input type="password" name="password"><br> <input type="submit" value="login" name="check"> #perl $account = param("account"); $password = param("password"); if($check) { $querycheck = $dbh->prepare("select * from data"); $querycheck->execute; if($account != "account" and $password != "password") { print "Login failed. Account and password do not match."; } return true; }

Replies are listed 'Best First'.
Re: login authentication
by NetWallah (Canon) on Dec 12, 2017 at 06:21 UTC
    Welcome to Perlmonks!

    Hopefully this is for a "learning" project, and nowhere near a production system.

    There are many technologies involved : CGI, DBI, Sessions/persistence - too much to go into with your general question.

    Instead, I'll direct you toward Chapter 20: Password Protection, where the script
    register2.cgi directly answers your question.

    I'm sure you will run into trouble with this, so feel free to come back here with a more specific question, and show us what you have tried.

                    All power corrupts, but we need electricity.

Re: login authentication
by hdb (Monsignor) on Dec 12, 2017 at 07:30 UTC

    Of course you should never store plain text passwords. Have a look at this interesting discussion.

Re: login authentication
by marto (Cardinal) on Dec 12, 2017 at 10:35 UTC

    You should not start to learn CGI, from the docs:

    "CGI.pm is no longer considered good practice for developing web applications, including quick prototyping and small web scripts. There are far better, cleaner, quicker, easier, safer, more scalable, more extensible, more modern alternatives available at this point in time. These will be documented with CGI::Alternatives.

    I suggest you look at Mojolicious/Mojolicious::Lite.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1205331]
Approved by hdb
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-25 07:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found