swamp Posted February 12, 2008 Share Posted February 12, 2008 Hey, Basically, I've written a basic php script that allows me to upload files, and then get redirected to a page that has a script to view all the files in the directory the files have been uploaded to. I was wondering if anyone could help me add a bit of code that mean the upload page would require a password. Ideally this would just be a simple text field just above the submit button. Cheers. Kieran Quote Link to comment Share on other sites More sharing options...
nethnet Posted February 12, 2008 Share Posted February 12, 2008 This depends on whether or not the password is universal (same for every person that uploads), or if different users can have different passwords. If it's the first case, just put a password field above your submit button then, and on the page that handles your uploading, run something similar to this near the top (before any of the uploading script): <?php $pass = $_POST['password']; if ($pass !== "your password here"){ echo "<p>Password is incorrect! Upload failed!</p>"; include "upload_form.php"; exit(); } // run the rest of your script... ?> If it's the other way, you'll have to hold the password against a list of possible values in a database or something along those lines. Either way, the code will be about the same thing. Quote Link to comment Share on other sites More sharing options...
swamp Posted February 12, 2008 Author Share Posted February 12, 2008 Works a treat. Thanks a lot. swamp 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.