NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Username & Password Protected

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 06-30-2005, 09:20 PM THREAD STARTER               #1 (permalink)
Senior Member
 
Sohil's Avatar
Join Date: May 2003
Location: Ohio
Posts: 2,337
Sohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to all
 



Username & Password Protected


Hello all,
I was wondering is there a script/way to make a certain page which can be only accessed by a username and password. I would like to make more than one username and password so please let me know if this is possible.
Thank you.
__________________
•• PolurNET Communications LLC
=Avoid the Freeze...Enjoy the Breeze!=
Sohil is offline  
Old 06-30-2005, 09:55 PM   #2 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
Which are you more fond of? PHP or JavaScript ?
Eric is offline  
Old 06-30-2005, 09:57 PM THREAD STARTER               #3 (permalink)
Senior Member
 
Sohil's Avatar
Join Date: May 2003
Location: Ohio
Posts: 2,337
Sohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to all
 



Originally Posted by SecondVersion
Which are you more fond of? PHP or JavaScript ?
PHP but anything will work right now..
__________________
•• PolurNET Communications LLC
=Avoid the Freeze...Enjoy the Breeze!=
Sohil is offline  
Old 06-30-2005, 10:07 PM   #4 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
http://www.evolt.org/article/rating/17/60384/index.html <This could possibly give you a little Insight
Eric is offline  
Old 06-30-2005, 10:11 PM THREAD STARTER               #5 (permalink)
Senior Member
 
Sohil's Avatar
Join Date: May 2003
Location: Ohio
Posts: 2,337
Sohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to all
 



Originally Posted by SecondVersion
http://www.evolt.org/article/rating/17/60384/index.html <This could possibly give you a little Insight
Downloading, going to take a look at it. Thank you very much.
__________________
•• PolurNET Communications LLC
=Avoid the Freeze...Enjoy the Breeze!=
Sohil is offline  
Old 06-30-2005, 10:13 PM   #6 (permalink)
Senior Member
 
Eric's Avatar
Join Date: Mar 2005
Posts: 4,948
Eric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatnessEric Has achieved greatness
 

Member of the Month
MOTM September 2005
Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Animal Rescue Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Baby Health Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse Diabetes Protect Our Planet Multiple Sclerosis Autism Adoption Special Olympics
No prob.
Eric is offline  
Old 06-30-2005, 10:45 PM THREAD STARTER               #7 (permalink)
Senior Member
 
Sohil's Avatar
Join Date: May 2003
Location: Ohio
Posts: 2,337
Sohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to all
 



A question,
When I am trying to access admin area it is giving me following error,
Quote:
Warning: mysql_connect(): Access denied for user: 'your_name@localhost' (Using password: YES) in /home/bwsongs/public_html/include/database.php on line 24
????: NamePros.com http://www.namepros.com/programming/103202-username-and-password-protected.html
Access denied for user: 'your_name@localhost' (Using password: YES)
even though I can access the user page. I looked at all the files but I am not getting anywhere. Would you happen to know why?
__________________
•• PolurNET Communications LLC
=Avoid the Freeze...Enjoy the Breeze!=
Sohil is offline  
Old 06-30-2005, 11:49 PM   #8 (permalink)
NamePros Regular
Join Date: Feb 2004
Location: Student @ UConn
Posts: 411
gamex has a spectacular aura aboutgamex has a spectacular aura about
 



In that page, in constants.php, you need to make some changes to that file, especially the following:

define("DB_USER", "your_name");
define("DB_PASS", "your_pass");
define("DB_NAME", "your_dbname");


Replace your_name with your database username, your_pass with your database password, and your_dbname with the name of your database.

Check the rest of that file, there might be some other things you need to change as well.

Joe
__________________
Joe
gamex is offline  
Old 06-30-2005, 11:56 PM THREAD STARTER               #9 (permalink)
Senior Member
 
Sohil's Avatar
Join Date: May 2003
Location: Ohio
Posts: 2,337
Sohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to allSohil is a name known to all
 



Originally Posted by gamex
In that page, in constants.php, you need to make some changes to that file, especially the following:

define("DB_USER", "your_name");
define("DB_PASS", "your_pass");
define("DB_NAME", "your_dbname");


Replace your_name with your database username, your_pass with your database password, and your_dbname with the name of your database.
????: NamePros.com http://www.namepros.com/showthread.php?t=103202

Check the rest of that file, there might be some other things you need to change as well.

Joe

I have already done that and like I have said I can login and everything just can't access the admin area.
__________________
•• PolurNET Communications LLC
=Avoid the Freeze...Enjoy the Breeze!=
Sohil is offline  
Old 07-01-2005, 12:09 AM   #10 (permalink)
NamePros Regular
Join Date: Feb 2004
Location: Student @ UConn
Posts: 411
gamex has a spectacular aura aboutgamex has a spectacular aura about
 



Well the problem is with line 24 in database.php, which is the following:

PHP Code:
$this->connection mysql_connect(DB_SERVERDB_USERDB_PASS) or die(mysql_error()); 
????: NamePros.com http://www.namepros.com/showthread.php?t=103202
It is having some sort of problem connecting to the database, dont know why you can access the users page though...

Contact me on AIM/Yahoo and ill see what I can do, Ill be on for another 20 minutes, otherwise I will be on tomorrow morning

Joe
__________________
Joe
gamex is offline  
Old 07-01-2005, 05:29 AM   #11 (permalink)
Senior Member
 
Cobalt's Avatar
Join Date: Jun 2005
Location: North Dakota
Posts: 1,378
Cobalt is a splendid one to beholdCobalt is a splendid one to beholdCobalt is a splendid one to beholdCobalt is a splendid one to beholdCobalt is a splendid one to beholdCobalt is a splendid one to beholdCobalt is a splendid one to beholdCobalt is a splendid one to behold
 



Also, just incase you can't figure this out, I have provided another wonderful script...Its very easy to use. Step by step guide..

Tutorial Here
Cobalt is offline  
Old 07-01-2005, 09:35 PM   #12 (permalink)
NamePros Member
 
Umer's Avatar
Join Date: Jun 2005
Location: Toronto, ON
Posts: 175
Umer is on a distinguished road
 




Hey bud, try this code. its 100% free to use, as long as you cite it.

I named this file private.php, you can change the name of this file, to watever you want, but then YOU MIGHT have to modify this script..

Put this part of the script in the code before <HTML>, means very begining of the page..
PHP Code:
<?
/* ---------- user settings ---------- */


$un "YOUR USER NAME";
$pw "YOUR PASSWORD";

/* ----------  actions ----------  */

if ($action == "logout") {
   
session_unset();
echo 
"<b>You were successfully logged out from the system!</b>";
}

if (
$action == "login") {
   if (
$put_un == $un)    {
       if (
$passw0rd == $pw) {
           
$_SESSION['auth'] = true;
       } else {
           
$error "<font color=\"red\">Error:</font> incorrect password/username. <br /> The username/Password are CAsE SEnSItiVE";
       }
   } else {
       
$error "<font color=\"red\">Error:</font> incorrect username/password. The username/password are The User/Password are CAsE SEnSItiVE";
   }
}

/* ---------- authenticate ----------  */
if ($_SESSION['auth'] == true) {
   
/* secure code */
} else {
   
/* non-secure code */

   
$view "login";

}

?>


The code below goes anywhere on the page, for instance <BODY>;
PHP Code:
<? if ($view == "login") { ?>

<form action="private.php" method="post">
Don't have an account? Click <a href="/contact_me.php">here</a><br /> <br>
    <table border="0" cellpadding="3" cellspacing="1" width="100%">

        <td width="45%" align="center">Username:</td>
        <td> 
        <input type="text" name="put_un" size="20" maxlength="20">
        </td>
    
????: NamePros.com http://www.namepros.com/showthread.php?t=103202
<tr> 
        <td align="center">Password:</td>
        <td>
    
        <input type="password" name="passw0rd" size="25" maxlength="25" />
        </td>
      </tr>
</table>
   <input name="action" type="hidden" id="action" value="login"><br>
  <center> <input type="submit" name="Submit" value="login"><br /><? echo  "$error<br>"?></center>
</form>

<? } if ($_SESSION['auth'] == true) { ?>

<! -- SECURE CONTENT -->

<a href="private.php?action=logout"><b><?php echo "$un"?></b> logout? </a>
????: NamePros.com http://www.namepros.com/showthread.php?t=103202

PUT YOUR SECURE STUFF HERE

<? ?>
thats it!

PS- this is NOT the best way to secure your page..

use .htaccess on your Apache server If u have one, that's what I use..
Last edited by Umer; 07-01-2005 at 09:47 PM.
Umer is offline  
Old 07-06-2005, 01:46 AM   #13 (permalink)
NamePros Regular
Join Date: May 2005
Location: Oklahoma City Oklahoma
Posts: 467
shanee86 is on a distinguished road
 



Yes I would suggest apache password protect folders. I am not that ggod at php so I use it.
shanee86 is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
change your yahoo mail password through gmail. suthra The Break Room 4 07-02-2005 10:49 AM
Password Problem Wildchild22 Programming 3 06-28-2005 03:08 AM
password protection hargi22 Programming 4 06-10-2005 01:39 PM
Windows XP Password Problem Martin Crepaz The Break Room 3 03-12-2005 08:25 PM
help, help, help with phpBB installation seraph Programming 2 10-05-2003 10:05 PM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 06:24 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger