Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Password Protect Website

Password Protect Website
Thread Tools
surferboy
Mac Enthusiast
Join Date: Jul 2003
Status: Offline
Reply With Quote
Oct 21, 2004, 08:47 AM
 
I am trying to password protect my website. I am planning in using PHP, MySQL and Apache server. I have the free tools- I just don't know how to use them yet. I downloaded and installed the MAMP as a package. Does anyone know of a good resource on the web or a step-by-step instruction on how to password protect my website?

It has been recommended that I make a database with MySQL with name and password. Then I write a PHP script to access the database and grant or deny permission to the page. Makes sense- I just need a little hand-holding on how to do it.
     
philzilla
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Oct 21, 2004, 09:03 AM
 
"Have sharp knives. Be creative. Cook to music" ~ maxelson
     
skalie
Mac Elite
Join Date: Mar 2002
Location: Clogland
Status: Offline
Reply With Quote
Oct 21, 2004, 09:38 AM
 
try googling ".htaccess" as well
     
TikTokk
Junior Member
Join Date: Sep 2000
Location: Michigan, USA
Status: Offline
Reply With Quote
Oct 21, 2004, 02:20 PM
 
Also, check with your ISP. Some have Admin settings for password protecting specific directories.
     
surferboy  (op)
Mac Enthusiast
Join Date: Jul 2003
Status: Offline
Reply With Quote
Nov 7, 2004, 05:22 PM
 
Phil,
Your book must be popular- sold out of all but one of the local Borders. Just ordered it online.

In the meantime, I have kind of come full circle. The link you posted in regards to the php login system with admin features looks great. I have been hard at work trying to get it to work for me. In short- I have downloaded the appropriate files and have everything working and interacting with my database. But, I cannot quite make that leap to apply this stuff to my own web pages. I took one of my webpages and saved it as "protectedpage.php" and added all the code I felt necessary to make this a truly protected page. I simply cannot make it work. I think there are several potential issues:
(1)does it matter where the php files are located as long as I have the correct file path for the include/session file?
(2)does that fact that I am using php5 matter? (if so, how do I delete it and install php4 without screwing up the mysql - php relationships I've already established?)

If you or anyone has used this system, can you please post a sample of an actual protected page demonstrating where the php commands go and how the html is integrated?

I am stuck. I have tried many things, and simply cannot get my pea-brain to understand what I am doing wrong.

Mundy, Philzilla- can you help walk me through this?

Much appreciated.
     
surferboy  (op)
Mac Enthusiast
Join Date: Jul 2003
Status: Offline
Reply With Quote
Nov 8, 2004, 09:23 AM
 
Anyone willing to look at this and tackle it with me? By the way, how do you insert a link? It does not seem to work for me?

http://www.evolt.org/article/PHP_Log...384/index.html
     
genevish
Mac Enthusiast
Join Date: Jan 1999
Location: Marietta, GA, USA
Status: Offline
Reply With Quote
Nov 8, 2004, 03:20 PM
 
You need to make sure all the links to include files are correct and accessable. Note that your main page will link to the session.php file, which will link to the database.php, mailer.php and form.php files, etc...

When you try to add the login form to your site, what are you seeing?
Scott Genevish
scott AT genevish DOT org
     
surferboy  (op)
Mac Enthusiast
Join Date: Jul 2003
Status: Offline
Reply With Quote
Nov 8, 2004, 04:39 PM
 
Originally posted by genevish:
You need to make sure all the links to include files are correct and accessable. Note that your main page will link to the session.php file, which will link to the database.php, mailer.php and form.php files, etc...

When you try to add the login form to your site, what are you seeing?
I see the login page with some of the code visible within the page.

Thanks for the insight. Any idea if this would not work with PHP5?
     
surferboy  (op)
Mac Enthusiast
Join Date: Jul 2003
Status: Offline
Reply With Quote
Nov 8, 2004, 04:59 PM
 
Actually, now I see nothing: when I call the page up- I get nothing. I made sure all the file paths were correct in each of the files.

Does the location of the files relative to the "protected page" matter? If so, what is the relationship?

Also, do you think this could be a PHP5 issue? How do I uninstall PHP5 and use PHP4 instead? Which version of PHP4 is recommended.

I am sorry: I know this is a bit of a no-no, but I am going to paste the code here so you can see what I am doing. Also, do I need to do a start_session(); at the top?

Thanks in advance:

<?php

/**
* Main.php
*
* This is an example of the main page of a website. Here
* users will be able to login. However, like on most sites
* the login form doesn't just have to be on the main page,
* but re-appear on subsequent pages, depending on whether
* the user has logged in or not.
*
* Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
* Last Updated: August 26, 2004
*/
include("/Library/WebServer/Documents/include/session.php");
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<link rel="stylesheet" href="css%20files/index.css" type="text/css" />
<title>HomeGraphic</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- ImageReady Preload Script (HomeGraphic.psd) -->
<script type="text/javascript">
<!--

userAgent = window.navigator.userAgent;
browserVers = parseInt(userAgent.charAt(userAgent.indexOf("/")+1),10);
function newImage(arg) {
if (document.images) {
rslt = new Image();
rslt.src = arg;
return rslt;
}
}

function findElement(n,ly) {
if (browserVers < 4) return document[n];
var curDoc = ly ? ly.document : document;
var elem = curDoc[n];
if (!elem) {
for (var i=0;i<curDoc.layers.length;i++) {
elem = findElement(n,curDoc.layers[i]);
if (elem) return elem;
}
}
return elem;
}

function changeImages() {
if (document.images && (preloadFlag == true)) {
var img;
for (var i=0; i<changeImages.arguments.length; i+=2) {
img = null;
if (document.layers) {
img = findElement(changeImages.arguments[i],0);
}
else {
img = document.images[changeImages.arguments[i]];
}
if (img) {
img.src = changeImages.arguments[i+1];
}
}
}
}

var preloadFlag = false;
function preloadImages() {
if (document.images) {
HomeGraphic_03_over = newImage("images/HomeGraphic_03-over.gif");
HomeGraphic_06_over = newImage("images/HomeGraphic_06-over.gif");
HomeGraphic_11_over = newImage("images/HomeGraphic_11-over.png");
HomeGraphic_15_over = newImage("images/HomeGraphic_15-over.gif");
HomeGraphic_18_over = newImage("images/HomeGraphic_18-over.gif");
preloadFlag = true;
}
}

// -->
</script>
<!-- End Preload Script -->
<!-- ImageReady Styles (HomeGraphic.psd) -->
<style type="text/css">
<!--


-->
</style>
<!-- End ImageReady Styles -->

</head>


<body onload="preloadImages();" style="background-color:#FFFFFF;">
<!-- ImageReady Slices (HomeGraphic.psd) -->
<table>
<tr><td>


<?
/**
* User has already logged in, so display relavent links, including
* a link to the admin center if the user is an administrator.
*/
if($session->logged_in){
echo "<div id="maingraphic" class="Table_01">
<div class="HomeGraphic-01_">
<img id="HomeGraphic_01" src="images/HomeGraphic_01.gif" width="600" height="46" alt="" />
</div>
<div class="HomeGraphic-02_">
<img id="HomeGraphic_02" src="images/HomeGraphic_02.gif" width="29" height="294" alt="" />
</div>
<div class="HomeGraphic-03_">
<a href="../kjocwebsite/menus/shoulder/shouldermenu.html"
onmouseover="changeImages('HomeGraphic_03', 'images/HomeGraphic_03-over.gif'); return true;"
onmouseout="changeImages('HomeGraphic_03', 'images/HomeGraphic_03.gif'); return true;"
onmousedown="changeImages('HomeGraphic_03', 'images/HomeGraphic_03-over.gif'); return true;"
onmouseup="changeImages('HomeGraphic_03', 'images/HomeGraphic_03-over.gif'); return true;">
<img name="HomeGraphic_03" id="HomeGraphic_03" src="images/HomeGraphic_03.gif" width="133" height="120" border="0" alt="" /></a>
</div>
<div class="HomeGraphic-04_">
<img id="HomeGraphic_04" src="images/HomeGraphic_04.gif" width="438" height="6" alt="" />
</div>
<div class="HomeGraphic-05_">
<img id="HomeGraphic_05" src="images/HomeGraphic_05.gif" width="274" height="122" alt="" />
</div>
<div class="HomeGraphic-06_">
<a href="../kjocwebsite/menus/elbow/elbowmenu.html"
onmouseover="changeImages('HomeGraphic_06', 'images/HomeGraphic_06-over.gif'); return true;"
onmouseout="changeImages('HomeGraphic_06', 'images/HomeGraphic_06.gif'); return true;"
onmousedown="changeImages('HomeGraphic_06', 'images/HomeGraphic_06-over.gif'); return true;"
onmouseup="changeImages('HomeGraphic_06', 'images/HomeGraphic_06-over.gif'); return true;">
<img name="HomeGraphic_06" id="HomeGraphic_06" src="images/HomeGraphic_06.gif" width="128" height="114" border="0" alt="" /></a>
</div>
<div class="HomeGraphic-07_">
<img id="HomeGraphic_07" src="images/HomeGraphic_07.gif" width="36" height="306" alt="" />
</div>
<div class="HomeGraphic-08_">
<img id="HomeGraphic_08" src="images/HomeGraphic_08.gif" width="133" height="174" alt="" />
</div>
<div class="HomeGraphic-09_">
<img id="HomeGraphic_09" src="images/HomeGraphic_09.gif" width="128" height="192" alt="" />
</div>
<div class="HomeGraphic-10_">
<img id="HomeGraphic_10" src="images/HomeGraphic_10.gif" width="17" height="166" alt="" />
</div>
<div class="HomeGraphic-11_">
<a href="http://www.kerlanjobe.com"
onmouseover="changeImages('HomeGraphic_11', 'images/HomeGraphic_11-over.png'); return true;"
onmouseout="changeImages('HomeGraphic_11', 'images/HomeGraphic_11.png'); return true;"
onmousedown="changeImages('HomeGraphic_11', 'images/HomeGraphic_11-over.png'); return true;"
onmouseup="changeImages('HomeGraphic_11', 'images/HomeGraphic_11-over.png'); return true;">
<img name="HomeGraphic_11" id="HomeGraphic_11" src="images/HomeGraphic_11.png" width="256" height="132" border="0" alt="" /></a>
</div>
<div class="HomeGraphic-12_">
<img id="HomeGraphic_12" src="images/HomeGraphic_12.gif" width="1" height="326" alt="" />
</div>
<div class="HomeGraphic-13_">
<img id="HomeGraphic_13" src="images/HomeGraphic_13.gif" width="256" height="34" alt="" />
</div>
<div class="HomeGraphic-14_">
<img id="HomeGraphic_14" src="images/HomeGraphic_14.gif" width="27" height="160" alt="" />
</div>
<div class="HomeGraphic-15_">
<a href="../kjocwebsite/menus/Knee/kneemenu.html"
onmouseover="changeImages('HomeGraphic_15', 'images/HomeGraphic_15-over.gif'); return true;"
onmouseout="changeImages('HomeGraphic_15', 'images/HomeGraphic_15.gif'); return true;"
onmousedown="changeImages('HomeGraphic_15', 'images/HomeGraphic_15-over.gif'); return true;"
onmouseup="changeImages('HomeGraphic_15', 'images/HomeGraphic_15-over.gif'); return true;">
<img name="HomeGraphic_15" id="HomeGraphic_15" src="images/HomeGraphic_15.gif" width="157" height="134" border="0" alt="" /></a>
</div>
<div class="HomeGraphic-16_">
<img id="HomeGraphic_16" src="images/HomeGraphic_16.gif" width="251" height="160" alt="" />
</div>
<div class="HomeGraphic-17_">
<img id="HomeGraphic_17" src="images/HomeGraphic_17.gif" width="1" height="142" alt="" />
</div>
<div class="HomeGraphic-18_">
<a href="../kjocwebsite/menus/everthingelse/everthingelsemenu.html"
onmouseover="changeImages('HomeGraphic_18', 'images/HomeGraphic_18-over.gif'); return true;"
onmouseout="changeImages('HomeGraphic_18', 'images/HomeGraphic_18.gif'); return true;"
onmousedown="changeImages('HomeGraphic_18', 'images/HomeGraphic_18-over.gif'); return true;"
onmouseup="changeImages('HomeGraphic_18', 'images/HomeGraphic_18-over.gif'); return true;">
<img name="HomeGraphic_18" id="HomeGraphic_18" src="images/HomeGraphic_18.gif" width="135" height="103" border="0" alt="" /></a>
</div>
<div class="HomeGraphic-19_">
<img id="HomeGraphic_19" src="images/HomeGraphic_19.gif" width="28" height="142" alt="" />
</div>
<div class="HomeGraphic-20_">
<img id="HomeGraphic_20" src="images/HomeGraphic_20.gif" width="135" height="39" alt="" />
</div>
<div class="HomeGraphic-21_">
<img id="HomeGraphic_21" src="images/HomeGraphic_21.gif" width="157" height="26" alt="" />
</div>
</div>";

}

else{
?>

<h1>Login</h1>
<?php
/**
* User not logged in, display the login form.
* If user has already tried to login, but errors were
* found, display the total number of errors.
* If errors occurred, they will be displayed.
*/
if($form == num_errors > 0){
echo <font size=\2\ color=\#ff0000\>.$form == num_errors. error(s) found</font>;
}
?>
<form action="process.php" method="POST">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value=<?php echo $form->value("user"); ?>"></td><td><? echo $form->error("user"); ?></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>"></td><td><? echo $form->error("pass"); ?></td></tr>
<tr><td colspan="2" align="left"><input type="checkbox" name="remember" <? if($form == value("remember") != ""){ echo "checked"; } ?>>
<font size="2">Remember me next time &nbsp;&nbsp;&nbsp;&nbsp;
<input type="hidden" name="sublogin" value="1">
<input type="submit" value="Login"></td></tr>
<tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr>
<tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr>
</table>
</form>

<?
}

/**
* Just a little page footer, tells how many registered members
* there are, how many users currently logged in and viewing site,
* and how many guests viewing site. Active users are displayed,
* with link to their user information.
*/
echo "</td></tr><tr><td align=\"center\"><br><br>";
echo "<b>Member Total:</b> ".$database == getNumMembers()."<br>";
echo "There are $database->num_active_users registered members and ";
echo "$database->num_active_guests guests viewing the site.<br><br>";

include("include/view_active.php");

?>


</td></tr>
</table>


</body>
</html>
     
genevish
Mac Enthusiast
Join Date: Jan 1999
Location: Marietta, GA, USA
Status: Offline
Reply With Quote
Nov 8, 2004, 06:58 PM
 
You said this worked with the generic "example" version, before you added it to your site, so I wouldn't think it's PHP5 related, but I'm still on 4 myself.

The session.php file starts the session, so no, you don't need to.

As for the relative path, for example, at the bottom of the page you have:

include("include/view_active.php");

There needs to be an include directory with the view_active.php page inside it in the same directory as this script, otherwise you can use the full path, like you did at the top.

You should probably check the logs to see if PHP is giving an error...
Scott Genevish
scott AT genevish DOT org
     
surferboy  (op)
Mac Enthusiast
Join Date: Jul 2003
Status: Offline
Reply With Quote
Nov 9, 2004, 02:51 PM
 
still no dice with the suggested change. I notice that if I put simple statements after the echo (following the if function), they tend to show up appropriately, but if I try to paste my entire webpage in quotes after the echo, I just get a blank page- must have something to do with syntax?

I tried to ways: first keeping the <head> in the usual place, and then placing the <head> and <body> within the quotes in the echo statement. Neither worked. Here is an example of the latter (sorry in advance):

<?
/**
* Main.php
*
* This is an example of the main page of a website. Here
* users will be able to login. However, like on most sites
* the login form doesn't just have to be on the main page,
* but re-appear on subsequent pages, depending on whether
* the user has logged in or not.
*
* Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
* Last Updated: August 26, 2004
*/
include("/Library/WebServer/Documents/kjocwebsite/login/include/session.php");
?>

<html>
<title>Jpmaster77's Login Script</title>
<body>

<table>
<tr><td>


<?php
/**
* User has already logged in, so display relavent links, including
* a link to the admin center if the user is an administrator.
*/
if($session->logged_in){
echo "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="Dave Shea" />
<meta name="keywords" content="design, css, cascading, style, sheets, xh<link rel="stylesheet" href="technique.css" type="text/css" />
<meta name="description" content="A demonstration of what can be accomplished visually through CSS-based design." />
<meta name="robots" content="all" />
<title>css Zen Garden: The Beauty in CSS Design</title><link rel="stylesheet" href="technique.css" type="text/css" />

<!-- to correct the unsightly Flash of Unstyled Content. http://www.bluerobot.com/web/css/fouc.asp -->
<script type="text/javascript"></script>
<link rel="stylesheet" href="css%20files/technique.css" type="text/css" />
</style>


</head>

<div id="container">
<div id="intro">
<div id="pageHeader">
<h1><a href="http://www.kerlanjobe.com" target="_blank"><img src="images/logosm.gif" width="157" height="80" border="0px" /> </a></h1>
<p><h2><span>ACL Surgical Technique</span></h2></p>
</div>

<div id="quickSummary">
<a href="../shoulder/shouldermenu.html" target="_blank"><span><p>Shoulder Main Menu </span></a></p>
<a href="../elbow/elbowmenu.html" target="_blank"><p> Elbow Main Menu</P></a>
<a href="kneemenu.html" target="_blank"><p> Knee Main Menu </p></a>
<a href="../everthingelse/everthingelsemenu.html" target="_blank"><p>Everything Else</span></p></a>
<p><a href="../../index.html" target="_blank">Home</a></p>
</div>

<div id="preamble">
<h3><span>Browdy</span></h3>
<p class="p1"><span>Littering a dark and dreary road lay the past relics of browser-specific tags, incompatible <acronym title="Document Object Model">DOM</acronym>s, and broken <acronym title="Cascading Style Sheets">CSS</acronym> support.</span></p>
<p class="p2"><span>Today, we must clear the mind of past practices. Web enlightenment has been achieved thanks to the tireless efforts of folk like the <acronym title="World Wide Web Consortium">W3C</acronym>, <acronym title="Web Standards Project">WaSP</acronym> and the major browser creators.</span></p>
<p class="p3"><span>The css Zen Garden invites you to relax and meditate on the important lessons of the masters. Begin to see with clarity. Learn to use the (yet to be) time-honored techniques in new and invigorating fashion. Become one with the web.</span></p>
</div>
</div>

<div id="supportingText">
<div id="explanation">
<h3><span>Wenger</span></h3>
<p class="p1"><span>There is clearly a need for <acronym title="Cascading Style Sheets">CSS</acronym> to be taken seriously by graphic artists. The Zen Garden aims to excite, inspire, and encourage participation. To begin, view some of the existing designs in the list. Clicking on any one will load the style sheet into this very page. The code remains the same, the only thing that has changed is the external .css file. Yes, really.</span></p>
<p class="p2"><span><acronym title="Cascading Style Sheets">CSS</acronym> allows complete and total control over the style of a hypertext document. The only way this can be illustrated in a way that gets people excited is by demonstrating what it can truly be, once the reins are placed in the hands of those able to create beauty from structure. To date, most examples of neat tricks and hacks have been demonstrated by structurists and coders. Designers have yet to make their mark. This needs to change.</span></p>
</div>

<div id="participation">
<h3><span>Hatch</span></h3>
<p class="p1"><span>Graphic artists only please. You are modifying this page, so strong <acronym title="Cascading Style Sheets">CSS</acronym> skills are necessary, but the example files are commented well enough that even <acronym title="Cascading Style Sheets">CSS</acronym> novices can use them as starting points. Please see the <a href="http://www.mezzoblue.com/zengarden/resources/" title="A listing of CSS-related resources"><acronym title="Cascading Style Sheets">CSS</acronym> Resource Guide</a> for advanced tutorials and tips on working with <acronym title="Cascading Style Sheets">CSS</acronym>.</span></p>
<p class="p2"><span>You may modify the style sheet in any way you wish, but not the <acronym title="HyperText Markup Language">HTML</acronym>. This may seem daunting at first if you’ve never worked this way before, but follow the listed links to learn more, and use the sample files as a guide.</span></p>
<p class="p3"><span>Download the sample <a href="zengarden-sample.html" title="This page's source HTML code, not to be modified.">html file</a> and <a href="zengarden-sample.css" title="This page's sample CSS, the file you may modify.">css file</a> to work on a copy locally. Once you have completed your masterpiece (and please, don’t submit half-finished work) upload your .css file to a web server under your control. <a href="http://www.mezzoblue.com/zengarden/submit/" title="Use the contact form to send us your CSS file">Send us a link</a> to the file and if we choose to use it, we will spider the associated images. Final submissions will be placed on our server.</span></p>
</div>

<div id="benefits">
<h3><span>Benefits</span></h3>
<p class="p1"><span>Why participate? For recognition, inspiration, and a resource we can all refer to when making the case for <acronym title="Cascading Style Sheets">CSS</acronym>-based design. This is sorely needed, even today. More and more major sites are taking the leap, but not enough have. One day this gallery will be a historical curiosity; that day is not today.</span></p>
</div>

<div id="requirements">
<h3><span>Requirements</span></h3>
<p class="p1"><span>We would like to see as much <acronym title="Cascading Style Sheets, version 1">CSS1</acronym> as possible. <acronym title="Cascading Style Sheets, version 2">CSS2</acronym> should be limited to widely-supported elements only. The css Zen Garden is about functional, practical <acronym title="Cascading Style Sheets">CSS</acronym> and not the latest bleeding-edge tricks viewable by 2% of the browsing public. The only real requirement we have is that your <acronym title="Cascading Style Sheets">CSS</acronym> validates.</span></p>
<p class="p2"><span>Unfortunately, designing this way highlights the flaws in the various implementations of <acronym title="Cascading Style Sheets">CSS</acronym>. Different browsers display differently, even completely valid <acronym title="Cascading Style Sheets">CSS</acronym> at times, and this becomes maddening when a fix for one leads to breakage in another. View the <a href="http://www.mezzoblue.com/zengarden/resources/" title="A listing of CSS-related resources">Resources</a> page for information on some of the fixes available. Full browser compliance is still sometimes a pipe dream, and we do not expect you to come up with pixel-perfect code across every platform. But do test in as many as you can. If your design doesn’t work in at least IE5+/Win and Mozilla (run by over 90% of the population), chances are we won’t accept it.</span></p>
<p class="p3"><span>We ask that you submit original artwork. Please respect copyright laws. Please keep objectionable material to a minimum; tasteful nudity is acceptable, outright pornography will be rejected.</span></p>
<p class="p4"><span>This is a learning exercise as well as a demonstration. You retain full copyright on your graphics (with limited exceptions, see <a href="http://www.mezzoblue.com/zengarden/submit/guidelines/">submission guidelines</a>), but we ask you release your <acronym title="Cascading Style Sheets">CSS</acronym> under a Creative Commons license identical to the <a href="http://creativecommons.org/licenses/by-nc-sa/1.0/" title="View the Zen Garden's license information.">one on this site</a> so that others may learn from your work.</span></p>
<p class="p5"><span>Bandwidth graciously donated by <a href="http://www.dreamfirestudios.com/">DreamFire Studios</a>.</span>&nbsp;</p>
</div>
<br /><br /><br />
<div id="footer">
<center>Next Previous</center>
<center><a href="mailto:[email protected]" target="_blank"><font color="#000000">Mail Comments or Questions</a></font></center>
</div>


<div id="linkList">
<div id="linkList2">
<div id="lselect">
<h3 class="select">ACL Powerpoint Topics</h3>
<ul>
<li>Acute ACL Injuries</li>
<li>ACL General1</li>
<li>ACL General2</li>
<li>ACL General3</li>
<li>ACL AAOS 03</li>
<li>ACL '03</li>
<li>Graft Issues 1</li>
<li>Graft Issues 2</li>
<li>Graft Issues 3</li>
<li>ACL in Skeletally Immature1</li>
<li>ACL in Skeletally Immature2</li>
<li>ACL in Skeletally Immature3</li>
<li>ACL in Skeletally Immature4</li>
<li>ACL in Skeletally Immature5</li>
<li>Notch</li>
<li>Pitfalls</li>
<li>Revision ACL</li>
<li>Trans-fix</li>
<li>Update '02</li>
<li>Varus Knee ACL</li>
</ul>
</div>

<div id="larchives">
<h3 class="archives"><span>ACL Rehabilitation</span></h3>

</div>

<div id="lresources">
<h3 class="resources"><span>ACL Instrumentation</span></h3>
<h3 class="resources"><span>Home</span></h3>

</div>
</div>
</div>


</div>

<!-- These extra divs/spans may be used as catch-alls to add extra imagery. -->
<div id="extraDiv1"><span></span></div><div id="extraDiv2"><span></span></div><div id="extraDiv3"><span></span></div>
<div id="extraDiv4"><span></span></div><div id="extraDiv5"><span></span></div><div id="extraDiv6"><span></span></div>

</body>
</html>";

}
else{
?>

<h1>Login</h1>
<?
/**
* User not logged in, display the login form.
* If user has already tried to login, but errors were
* found, display the total number of errors.
* If errors occurred, they will be displayed.
*/
if($form->num_errors > 0){
echo "<font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font>";
}
?>
<form action="process.php" method="POST">
<table align="left" border="0" cellspacing="0" cellpadding="3">
<tr><td>Username:</td><td><input type="text" name="user" maxlength="30" value="<? echo $form->value("user"); ?>"></td><td><? echo $form->error("user"); ?></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" maxlength="30" value="<? echo $form->value("pass"); ?>"></td><td><? echo $form->error("pass"); ?></td></tr>
<tr><td colspan="2" align="left"><input type="checkbox" name="remember" <? if($form->value("remember") != ""){ echo "checked"; } ?>>
<font size="2">Remember me next time &nbsp;&nbsp;&nbsp;&nbsp;
<input type="hidden" name="sublogin" value="1">
<input type="submit" value="Login"></td></tr>
<tr><td colspan="2" align="left"><br><font size="2">[<a href="forgotpass.php">Forgot Password?</a>]</font></td><td align="right"></td></tr>
<tr><td colspan="2" align="left"><br>Not registered? <a href="register.php">Sign-Up!</a></td></tr>
</table>
</form>

<?
}

/**
* Just a little page footer, tells how many registered members
* there are, how many users currently logged in and viewing site,
* and how many guests viewing site. Active users are displayed,
* with link to their user information.
*/
echo "</td></tr><tr><td align=\"center\"><br><br>";
echo "<b>Member Total:</b> ".$database->getNumMembers()."<br>";
echo "There are $database->num_active_users registered members and ";
echo "$database->num_active_guests guests viewing the site.<br><br>";

include("/Library/WebServer/Documents/kjocwebsite/login/include/view_active.php");

?>


</td></tr>
</table>


</body>
</html>
     
genevish
Mac Enthusiast
Join Date: Jan 1999
Location: Marietta, GA, USA
Status: Offline
Reply With Quote
Nov 9, 2004, 09:38 PM
 
[list=1][*]Make sure there is nothing sent ot the browser before the session file is included (not a return, not a single space.)[*]If you command-click on this blank page and show the source, is anything shown?[*]What types of errors are shown with this on the command line: cat /var/log/httpd/error_log | grep PHP[/list=1]
Scott Genevish
scott AT genevish DOT org
     
surferboy  (op)
Mac Enthusiast
Join Date: Jul 2003
Status: Offline
Reply With Quote
Nov 9, 2004, 10:15 PM
 
checking the errors was not something I knew how to do: great idea. I get:

[Tue Nov 9 20:13:17 2004] [error] PHP Parse error: parse error, unexpected '<', expecting ',' or ';' in /Library/WebServer/Documents/kjocwebsite/protectedpage.php on line 20
[minime:~] jasonbro%

No source code seen.
     
genevish
Mac Enthusiast
Join Date: Jan 1999
Location: Marietta, GA, USA
Status: Offline
Reply With Quote
Nov 9, 2004, 11:18 PM
 
Ah. I hadn't looked down the page. The echo statement probably should go. Here's an example of what's wrong:

Code:
echo "This is my echo statement. I call it "George". Isn't George pretty?";
The problem is you're closing the statement with the quote in he middle, which is freaking PHP out and it's just not displaying the page at all. There are two options. One is to escape the quotes in the middle of the echo statement with a backslash, like this:

Code:
echo "This is my echo statement. I call it \"George\". Isn't George pretty?";
Since your echo statement is very long and has a lot of quotes (and you're not printing out any variables or anything), it's probably easier to just step out of PHP, write the HTML, then step back in like this:

Code:
... if($session->logged_in){ ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ...
and

Code:
... </html> <? } else{ ...
Scott Genevish
scott AT genevish DOT org
     
surferboy  (op)
Mac Enthusiast
Join Date: Jul 2003
Status: Offline
Reply With Quote
Nov 10, 2004, 12:58 AM
 
genevish, you are a brainiac. Several times, I wondered if it was the quotes issue, but I found it hard to believe that I'd have to go through it and remove so many quotes. I supposed if I knew PHP better, I would have figured it out? Thanks so much for curing my frustration!
     
surferboy  (op)
Mac Enthusiast
Join Date: Jul 2003
Status: Offline
Reply With Quote
Nov 10, 2004, 02:18 PM
 
I found another very easy to implement script at: http://www.phpsecurepages.com/index.php

Can someone take a look at this and help me answer this question: using this system, how does a user log out? If the browser is closed, does that make it necessary to re-log in?

Thanks
     
philzilla
Occasionally Useful
Join Date: Jun 2001
Location: Liverpool, UK
Status: Offline
Reply With Quote
Nov 10, 2004, 06:05 PM
 
Originally posted by surferboy:
Can someone take a look at this and help me answer this question: using this system, how does a user log out? If the browser is closed, does that make it necessary to re-log in?
RTFM, dude
Originally detailed in the FAQ's page:
phpSecurePages should remember your login data as long as your browser stays open
"Have sharp knives. Be creative. Cook to music" ~ maxelson
     
surferboy  (op)
Mac Enthusiast
Join Date: Jul 2003
Status: Offline
Reply With Quote
Nov 10, 2004, 07:19 PM
 
Originally posted by philzilla:
RTFM, dude
Saw that after my post. Thanks for taking the time. Philzil, if you are interested in testing this set of scripts, I'd love to bounce a few things off you. I am able to get it to work when I have the php file (the one I am protecting) in the root folder (/Library/WebServer/Documents/protectindex.php). I have the phpSecurePages in the same folder (documents). When I put the protectindex.php folder elsewhere, I cannot get the scripts to work, even if I change the file paths in the script at the top. When checking php error log at terminal, I get:


[Wed Nov 10 13:46:40 2004] [error] PHP Warning: main(): Failed opening 'phpSecurePages/secure.php' for inclusion (include_path='.:/usr/local/php/lib/php') in /Library/WebServer/Documents/phpsecurePages/protectindex.php on line 7
     
Chris O'Brien
Grizzled Veteran
Join Date: Nov 2003
Location: Hebburn, UK
Status: Offline
Reply With Quote
Nov 10, 2004, 07:49 PM
 
Could it possibly be something as simple as misstyping the file paths? They're case-sensitive, and according to the log you showed, you have: phpSecurePages and phpsecurePages.
Just who are Britain? What do they? Who is them? And why?

Formerly Black Book
     
surferboy  (op)
Mac Enthusiast
Join Date: Jul 2003
Status: Offline
Reply With Quote
Nov 11, 2004, 01:45 AM
 
I am able to get the scripts functioning using phpSecurePages, however, I notice an error. I protected two different pages. Each is protected when you first visit the site; however, when you hit your browser's back arrow, the previous page is no longer protected- you are simply able to view the content, despite the fat that you never did log in. Any thoughts?
     
   
 
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -4. The time now is 12:49 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,