Hybridd Posted March 27, 2014 Posted March 27, 2014 is there anyway i could protect my php files with a code that only i can use to view the page, or anything else that is similar thanks in advance. Quote
Zettieee Posted March 28, 2014 Posted March 28, 2014 if($user['id'] == $_SESSION['id']) { //all the code here } else { echo 'Go away'; exit; } Quote
KyleMassacre Posted March 28, 2014 Posted March 28, 2014 There are numerous ways like what Zettieee said by restricting it to a particular userid, you can password protect it by creating just a real simple form or etc. those are just some of the easiest ways that don't require much effort Quote
Zettieee Posted March 28, 2014 Posted March 28, 2014 $pass = "myMasterPass"; if(!isset($_POST['submit'])){ echo '<form action="myfilename.php" method="POST"></br> <input type="password" name="pass" value=""></br> <input type="submit" name="submit">'; } if(isset($_POST['submit'])){ if($_POST['pass'] == $pass){ //code here } else { die('not correct'); } Quote
KyleMassacre Posted March 28, 2014 Posted March 28, 2014 $pass = "myMasterPass"; if(!isset($_POST['submit'])){ echo '<form action="myfilename.php" method="POST"></br> <input type="password" name="pass" value=""></br> <input type="submit" name="submit">'; } if(isset($_POST['submit'])){ if($_POST['pass'] == $pass){ //code here } else { die('not correct'); } Derrty but gets the job done :p I'm not the biggest fan of die() but ehh oh well lol Quote
Zettieee Posted March 28, 2014 Posted March 28, 2014 :P I hope this is what he means by protect his file. If not I have no idea what he actually wants. Maybe some sort of encryption? Quote
Guest Posted March 28, 2014 Posted March 28, 2014 Could use htaccess http://www.htaccesstools.com/htaccess-authentication/ Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.