I have a daughter and son in law in iraq. I am taking care of the grandbaby till they get back. There are so many family members and them over seas that I fealt a web site where they all can access them would be a very good idea. I have a domain name already, made my front page. On the main page there is a link to nothing, because this is where I want to control access with passwords. I right most of my code in straight html using css. I have no clue how to do the secure part. Can someone point me in the right direction?
Photo Gallery Website
Collapse
X
-
How do you wish to achieve this? Do you know any server side languages, ie: PHP, Perl, ASP, Ruby? Please advise me of where you would like this post moved to and I will be glad to do that for you. There many pre-made script available online for free. Search for Free Login Scripts.
--KevinComment
-
Read up on php then - check out some phptutorials().Originally posted by rcollinsI know some php, that is what we learned in my 3rd website class in college,,and I have books, too
It's definitely - in my oppinion ;) - the best way to go.
Shouldn't take you long to brush up on the basics.
And by the sounds of it, all you'll need is the basics.
Once you've learnt the basics, you won't want to stop!
Deadly cycle, trust me!Comment
-
If this is your only need from PHP, then its not a big task.Originally posted by rcollinsI have a daughter and son in law in iraq. I am taking care of the grandbaby till they get back. There are so many family members and them over seas that I fealt a web site where they all can access them would be a very good idea. I have a domain name already, made my front page. On the main page there is a link to nothing, because this is where I want to control access with passwords. I right most of my code in straight html using css. I have no clue how to do the secure part. Can someone point me in the right direction?
I see your need is just to show your pictures to few of your family members. I'll just give a short script and you can use that.
index.php (add this somewhere in your main page and name your page as index.php)[html]<form action="picture s.php" method="post">
Id:<input name="id" type="text" /><br />
Password:<input name="password" type="password" /><br />
<input name="login" type="submit" value="Submit" />
</form>[/html]
pictures.php[php]<?php
require ("ids.php");
if (isset($_COOKIE["viewer_id"]) && isset($_COOKIE["viewer_passwor d"]))
if ($_COOKIE["viewer_passwor d"] == md5($passwords[array_search($_ COOKIE["viewer_id"], $ids)]))
{
show_list_page( );
exit();
}
if (isset($_POST["login"]) && isset($_POST["id"]) && isset($_POST["password"]))
if (in_array($_POS T["id"], $ids))
if ($_POST["password"]==$passwords[array_search($_ POST["id"], $ids)])
{
$hour = time() + 86400; //FOR 24 HOURS
setcookie("view er_id", $_POST["id"], $hour);
setcookie("view er_password", md5($_POST["password"]), $hour);
show_list_page( );
exit();
}
header ("location:inde x.php");
function show_list_page( )
{
?>
<!-- copy here the HTML that contains the list and links to all the pictures -->
<?php
}[/php]
logout.php (Link this somewhere in pictures.php)[php]<?php
$past = time() - 100;
setcookie("view er_id", "", $past);
setcookie("view er_password", "", $past);
header("locatio n:index.php");
?>[/php]
ids.php[php]<?php
$ids = array(
"my_id",
"your_id",
"his_id",
"her_id"
);
$passwords = array(
"my_passwor d",
"your_password" ,
"his_passwo rd",
"her_passwo rd"
);
?>[/php]This ids.php contains the list of all the ids and passwords which you can give your relatives. You can add ids and passwords in it, but you would need to be careful that the serial order remains respective.
The only limitations are, user can't himself change the password and you may not have TOO many ids and passwords.
I have not tested it, so if any problem is there, do let me know.
Regards,
HarpreetComment
-
so, instead of trying to put this in my code, I figured I can add my code to this. The problem I am having, and this is just copying and pasting the info into the three new files, is that when I try to open .php files it prompts me to open or save. This is a continuous circle. Can you test it and see what is wrong? ThanksComment
-
This is because you are trying to access the files from your local computer. First you need to upload these three files to your domain which you said you had, make sure that the webserver that your domain is on supports php though otherwise it will not work. Most webservers have php installed so that is not really an issue. To upload some files just find your FTP details given to you by your webhosting company in a welcome email or in your control panel and use them with an FTP client such as SmartFTP or BitKinex or Ipswitch WS_FTP. Then just copy and paste those three files into the directory on your domain where the public can view those files. This folder on your domain is usually called public_html or www. When you have uploaded them, go to your website and you should be on index.php and the log in form displaying.
Remember, PHP is server-side code, it is interpreted by a server that has php installed. HTML and CSS are interpreted by the web browser.
Hope this helps,
MiraanComment
-
I tried the sample code and it works fine!
If you try to load pictures.php and are not logged in yet, it redirects you to the login page (index.php) in this case.
When you successfully log in, you are redirected to pictures.php which will show your page. Adding a logout link to logout.php will clear the cookie settings when the users links to it. The next time the user tries to load pictures.php, he/she will be redirected to the index.php to enter the user/password.
regards,
phpNerd01Comment
-
That is exactly what I expected from the code.Originally posted by phpNerd01I tried the sample code and it works fine!
If you try to load pictures.php and are not logged in yet, it redirects you to the login page (index.php) in this case.
When you successfully log in, you are redirected to pictures.php which will show your page. Adding a logout link to logout.php will clear the cookie settings when the users links to it. The next time the user tries to load pictures.php, he/she will be redirected to the index.php to enter the user/password.
regards,
phpNerd01Comment
Comment