gnize Posted September 19, 2008 Share Posted September 19, 2008 Hello, I have a file (upload.php) that is open to all users. When a user directs their browser to the file it shows an html page with an upload feature. It has browse for file etc. What I'm wanting to do is limit this file to admin only by whay of "user name is admin" or "id=12" or even ip address. How would I edit a file to include this? I'm using php 5 n mysql 5. Quote Link to comment Share on other sites More sharing options...
cornetofreak Posted September 23, 2008 Share Posted September 23, 2008 create a new file and call it admin_pass.php add this into the file <?php $admin_pass = "YOURPASSWORD"; if($is_admin) { if(!$_SESSION['admin']) { $pass = $_POST['pass']; if(!$pass) { die('<div align="center"><form action="" method="post">Password:<Br><input type="password" name="pass"><br><input type="submit" value="Login"></form></div>'); } else { if($pass == $admin_pass) { $_SESSION['admin'] = "somerandomstring"; header("Location: submit.php"); } else { die("Sorry Disabled : <a href \"index.php\">HOME..</a>"); } } } } ?> and in the files you wish to have a password protected page insert this at the top of them pages <?php $is_admin = true; ?> make sure you admin_pass.php is included Quote Link to comment Share on other sites More sharing options...
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.