security - Restrict page access with member login -


i need make normal restricted area of website accessible registered, logged-in members. restricted pages pulling data mysql database using php.

i have been searching way this, finding many useless results. of i've found either insecure, outdated or deals 1 specific area of process. incredibly frustrating spending hours studying method of doing this, find out they've used insecure method , it's useless. i'm hoping opinions of experienced stackoverflow community point me in right direction.

so question this: knowing hundreds of thousands of websites have same "register, log in, grant access pages a, b , c, log out" combination of events, there universally accepted way of setting (and if not, why not)? this: http://www.wikihow.com/create-a-secure-login-script-in-php-and-mysql "good" way of achieving (assuming figure out how work)?

the pages/database not hold credit card numbers or other sensitive information, don't think i'll have thousands of hackers attacking site, want maintain reasonable level of security. i've been careful avoid potential of sql injection attacks on database side of things.

many thanks, paul

try this. login.php

<form action="check.php" method="post"> <table border="0" cellpadding="0" cellspacing="0" style="margin-left:auto; margin-right:auto;"> <tr><td>nickname:</td><td><input type="text" id="usernaame" name="usernaame"></td></tr> <tr><td>password:</td><td><input type="password" id="passworrd" name="passworrd"></td></tr> <tr><td colspan="2"><input type="submit" value="login" class="button"></td></tr></table> </form> <br><a href="register.php"><button>register</button></a></div> 

check.php

<?php session_start(); $user = htmlspecialchars(addslashes($_post['usernaame'])); //you can edit password encryption $password = htmlspecialchars(addslashes(md5(sha1($_post['passworrd'])))); //put here query $query = mysqli_query(); if(mysqli_num_rows($query)=="1"){ $_session['logged'] = $user; } else{echo 'data incorrect';} ?> 

index.php (where protected content is)

<?php session_start(); if(!isset($_session['logged'])){echo 'please login';} else{ //your private content here } ?> 

Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -