kurt.santo Posted November 15, 2007 Share Posted November 15, 2007 I would love to have a page on my new website, where my friends only (or anyone I will give password to) can log in to see pages no one else will be able to see. Would it be also possible to direct them to different files depending on what username/password they supplied? Not such a fan of putting pictures etc publicly accessible on the web (do not everyone want to see my spotty face;-)). Can this be done in simple way without use of databases etc?Kurt Link to comment Share on other sites More sharing options...
Ingolme Posted November 15, 2007 Share Posted November 15, 2007 Well, you can try .htaccess and .htpasswd files to pretect folders.with PHP you can't protect images, but you can protect the page itself something like this: <?phpif($_POST['user'] == "username" && $_POST['password'] == "password") {?><!-- Show some HTML of the site --><?php} else {?><form action="?a=1" method="post"><div>Log in to view this page:<br />Username: <input type="text" name="user" /><br />Password: <input type="password" name="password" /><br /><input type="Submit" /></div></form><?php}?> Link to comment Share on other sites More sharing options...
SpOrTsDuDe.Reese Posted November 15, 2007 Share Posted November 15, 2007 This is a lazy thing you could try, I'm bored and you probably won't do this but you could have an invisible link that doesn't show the URL in the bottom left part of the browser and if clicked it will load JavaScript on the page for whatever. Definately not safe-proof or whatever but thats an idea. Don't use that idea. Not safe and wont accomplish what you want. I don't even know why I posted here... Link to comment Share on other sites More sharing options...
Synook Posted November 16, 2007 Share Posted November 16, 2007 with PHP you can't protect imagesWell, you could make the image a PHP file that sets its MIME type to image/whatever then echoes the image data onto the screen, but first checks for a session variable or something (don't know what encoding the image has to be in though)...<?phpsession_start();header("Content-Type: image/gif");if (isset($_SESSION['logged_in'])) {echo /*Whatever the image's code is*/;} else {echo /*An image saying "can't access" or whatever*/;}?> Link to comment Share on other sites More sharing options...
kurt.santo Posted November 16, 2007 Author Share Posted November 16, 2007 Will have a go and try the given suggestions. Cheers,Kurt Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.