[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

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


Closed Thread
 
LinkBack Thread Tools
Old 06-30-2005, 08:20 PM   #1 (permalink)
Senior Member
 
Sohil's Avatar
 
Join Date: May 2003
Location: Ohio
Posts: 2,332
1,884.80 NP$ (Donate)

Sohil is a glorious beacon of lightSohil is a glorious beacon of lightSohil is a glorious beacon of lightSohil is a glorious beacon of lightSohil is a glorious beacon of light


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, 08:55 PM   #2 (permalink)
NPQ's PA, Slave, and On Call Coder

Technical Services


 
Eric's Avatar
 
Join Date: Mar 2005
Posts: 4,545
0.71 NP$ (Donate)

Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute

Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse
Which are you more fond of? PHP or JavaScript ?
__________________
Eric is offline  
Old 06-30-2005, 08:57 PM   #3 (permalink)
Senior Member
 
Sohil's Avatar
 
Join Date: May 2003
Location: Ohio
Posts: 2,332
1,884.80 NP$ (Donate)

Sohil is a glorious beacon of lightSohil is a glorious beacon of lightSohil is a glorious beacon of lightSohil is a glorious beacon of lightSohil is a glorious beacon of light


Quote:
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, 09:07 PM   #4 (permalink)
NPQ's PA, Slave, and On Call Coder

Technical Services


 
Eric's Avatar
 
Join Date: Mar 2005
Posts: 4,545
0.71 NP$ (Donate)

Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute

Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse
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, 09:11 PM   #5 (permalink)
Senior Member
 
Sohil's Avatar
 
Join Date: May 2003
Location: Ohio
Posts: 2,332
1,884.80 NP$ (Donate)

Sohil is a glorious beacon of lightSohil is a glorious beacon of lightSohil is a glorious beacon of lightSohil is a glorious beacon of lightSohil is a glorious beacon of light


Quote:
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, 09:13 PM   #6 (permalink)
NPQ's PA, Slave, and On Call Coder

Technical Services


 
Eric's Avatar
 
Join Date: Mar 2005
Posts: 4,545
0.71 NP$ (Donate)

Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute

Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse
No prob.
__________________
Eric is offline  
Old 06-30-2005, 09:45 PM   #7 (permalink)
Senior Member
 
Sohil's Avatar
 
Join Date: May 2003
Location: Ohio
Posts: 2,332
1,884.80 NP$ (Donate)

Sohil is a glorious beacon of lightSohil is a glorious beacon of lightSohil is a glorious beacon of lightSohil is a glorious beacon of lightSohil is a glorious beacon of light


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
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, 10:49 PM   #8 (permalink)
NamePros Regular
 
gamex's Avatar
 
Join Date: Feb 2004
Location: Student @ UConn
Posts: 408
73.95 NP$ (Donate)

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
CarrotCash.com
gamex is offline  
Old 06-30-2005, 10:56 PM   #9 (permalink)
Senior Member
 
Sohil's Avatar
 
Join Date: May 2003
Location: Ohio
Posts: 2,332
1,884.80 NP$ (Donate)

Sohil is a glorious beacon of lightSohil is a glorious beacon of lightSohil is a glorious beacon of lightSohil is a glorious beacon of lightSohil is a glorious beacon of light


Quote:
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.

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 06-30-2005, 11:09 PM   #10 (permalink)
NamePros Regular
 
gamex's Avatar
 
Join Date: Feb 2004
Location: Student @ UConn
Posts: 408
73.95 NP$ (Donate)

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_SERVER, DB_USER, DB_PASS) or die(mysql_error());
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
CarrotCash.com
gamex is offline  
Old 07-01-2005, 04:29 AM   #11 (permalink)
Senior Member
 
Cobalt's Avatar
 
Join Date: Jun 2005
Location: North Dakota
Posts: 1,368
15.00 NP$ (Donate)

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 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, 08:35 PM   #12 (permalink)
NamePros Member
 
Umer's Avatar
 
Join Date: Jun 2005
Location: Toronto, ON
Posts: 175
150.18 NP$ (Donate)

Umer is on a distinguished road


Notice

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>
    
<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>

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 08:47 PM.
Umer is offline  
Old 07-06-2005, 12:46 AM   #13 (permalink)
NamePros Regular
 
Join Date: May 2005
Location: Oklahoma City Oklahoma
Posts: 467
41.70 NP$ (Donate)

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

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 04:16 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85