471,086 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,086 software developers and data experts.

Photo Gallery Website

rcollins
234 100+
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?
Jun 3 '08 #1
15 1890
eWish
971 Expert 512MB
This must be done with a server side language or by using your web server. If you would like I can move this post to the fourm of your choice. Sorry, but this is not an HTML/CSS issue.

--Kevin
Jun 3 '08 #2
rcollins
234 100+
I wasn't sure where to put this one, you can move me...I need help
Jun 3 '08 #3
eWish
971 Expert 512MB
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.

--Kevin
Jun 3 '08 #4
rcollins
234 100+
I know some php, that is what we learned in my 3rd website class in college,,and I have books, too
Jun 3 '08 #5
Markus
6,050 Expert 4TB
I know some php, that is what we learned in my 3rd website class in college,,and I have books, too
Read up on php then - check out some phptutorials().

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!
Jun 3 '08 #6
hsriat
1,654 Expert 1GB
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?
If this is your only need from PHP, then its not a big task.

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="pictures.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_password"]))
if ($_COOKIE["viewer_password"] == 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($_POST["id"], $ids))
if ($_POST["password"]==$passwords[array_search($_POST["id"], $ids)])
{

$hour = time() + 86400; //FOR 24 HOURS
setcookie("viewer_id", $_POST["id"], $hour);
setcookie("viewer_password", md5($_POST["password"]), $hour);

show_list_page();
exit();
}

header ("location:index.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("viewer_id", "", $past);
setcookie("viewer_password", "", $past);
header("location:index.php");
?>[/php]

ids.php[php]<?php
$ids = array(
"my_id",
"your_id",
"his_id",
"her_id"
);
$passwords = array(
"my_password",
"your_password",
"his_password",
"her_password"
);
?>[/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,
Harpreet
Jun 3 '08 #7
rcollins
234 100+
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? Thanks
Aug 10 '08 #8
miraan
24
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,

Miraan
Aug 10 '08 #9
Markus
6,050 Expert 4TB
To develop on your local PC / whatever OS, you need to have a server installed.

Google XAMPP
Aug 10 '08 #10
rcollins
234 100+
so if I upload this to the server where I host my website, it will work?
Aug 11 '08 #11
hsriat
1,654 Expert 1GB
so if I upload this to the server where I host my website, it will work?
Of course... just upload the files, and see if it works or not, and let us know in case it doesn't (along with the error).
Aug 11 '08 #12
rcollins
234 100+
OK So far so good, the .php pages are working. The problem is that if I log in with out a username or password, it still loads the page. did I miss something? I can give you my website address if you would like to see
Sep 3 '08 #13
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,
phpNerd01
Sep 7 '08 #14
hsriat
1,654 Expert 1GB
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,
phpNerd01
That is exactly what I expected from the code.
Sep 21 '08 #15
NeoPa
32,345 Expert Mod 16PB
A hijack post was posted in here and it has now been split into its own separate thread (Developing Photo Gallery).

Anyone interested in helping this (new) user is welcome to link across ;)
Sep 26 '08 #16

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

10 posts views Thread by matt | last post: by
5 posts views Thread by fraser | last post: by
3 posts views Thread by bob garbados | last post: by
7 posts views Thread by Eric Lindsay | last post: by
1 post views Thread by desjardins.daniel | last post: by
13 posts views Thread by Viken Karaguesian | last post: by
1 post views Thread by Xah Lee | last post: by
1 post views Thread by popotz | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.