PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 16th, 2004, 02:23 PM
Janet Janet is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 Janet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
PHP Passwords

Hey. I've been trying to create a password protection on my Mom's website for the past two days, but have failed.

I have tried two different methods and nothing. It keeps asking whether or not I really want to download the php file,
but I am trying to get it to use the file to send it to an html webpage so only certain people can enter the website.
That is not how it is working out at all. Below is the original...please tell me what I am doing wrong!

<?php>
$passwords = array("bill" =>"apple",
"charles"=>"potato",
"david" =>"igneous",
"janet" =>"tomask");
if ($password == $passwords[$username])
{
setcookie("username", $username, time()+1200);
echo "<H2>Access granted.</H2>";
}
else
{
setcookie("username", "", time()-3600);
echo "<H2>Invalid user name or password: access denied.</H2>";
}
?>

Reply With Quote
  #2  
Old May 16th, 2004, 03:13 PM
Pheifel Pheifel is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Denmark
Posts: 174 Pheifel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 46 sec
Reputation Power: 5
Send a message via MSN to Pheifel
i would suggest using $_session['']; like this:

PHP Code:
<?

session_start
();

$username $_POST['username']; $password $_POST['password'];

$pass = array("bill"=>"apple","charles"=>"potato");

if (
$username == $pass['$username']) {
    
header("location:http://www.yoursite.com")
} else print 
"Acces denied";


?>

<form name="form1" method="post" action="">
  <p>Username: 
    <input name="username" type="text" id="username">
  </p>
  <p>Password: 
    <input name="password" type="text" id="password">
  </p>
</form>

Reply With Quote
  #3  
Old May 16th, 2004, 05:56 PM
Janet Janet is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 Janet User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you so much. I would just like to say on the record...that moms are a pain in the butt.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > PHP Passwords


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway