Jump to content

Newbie needs some help please!


hmburg

Recommended Posts

I want to try and make an html page password protected.  I found a useful script to do this but it opens a very basic user/password screen.  How can I incorporate this screen into the same design as my html pages?  The script calls for the code of the page I want to protect to be inserted in a certain place, I have done this and all workd prefectly, just the style is non-existant!  Any help gratefully received, here is the code I have:

 

<?php

$username = "hmburg52";

$password = "cathie99";

$randomword = "bibblebobblechocolatemousse";

 

if (isset($_COOKIE['MyLoginPage'])) {

  if ($_COOKIE['MyLoginPage'] == md5($password.$randomword)) {

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

 

 

<title>Care Quest South West</title>

<meta name="robots" content="noindex,nofollow">

 

<link rel="icon" href="favicon.ico" type="image/ico" />

<link rel="shortcut icon" href="favicon.ico" type="image/ico" />

 

<link href="../care.css" rel="stylesheet" type="text/css" />

 

 

</head>

<body>

<table  border="0" width="1070" align="center">

<tr>

<td>

 

<div id="header"></div>

<br>

<table  border="0" width="870" align="center" >

<tr>

<td>

<div id="button"><a href="../indextrial.html"><img src="../images/button1a.jpg" border="0" width="174" height="20" name="pic1" onmouseover="document.pic1.src='../images/button1b.jpg';" onmouseout="document.pic1.src='../images/button1a.jpg';" alt="" id="pic1"></a><a href="../brochure.html"><img src="../images/button2a.jpg" border="0" width="174" height="20" name="pic2" onmouseover="document.pic2.src='../images/button2b.jpg';" onmouseout="document.pic2.src='../images/button2a.jpg';" alt="" id="pic2"></a><a href="../contact.html"><img src="../images/button3a.jpg" border="0" width="174" height="20" name="pic3" onmouseover="document.pic3.src='../images/button3b.jpg';" onmouseout="document.pic3.src='../images/button3a.jpg';" alt="" id="pic3"></a><a href="../recruitment.html"><img src="../images/button4a.jpg" border="0" width="174" height="20" name="pic4" onmouseover="document.pic4.src='../images/button4b.jpg';" onmouseout="document.pic4.src='../images/button4a.jpg';" alt="" id="pic4"></a><img src="../images/button5a.jpg" border="0" width="174" height="20" name="pic5" ></div>

</td>

</tr>

</table>

 

<table  border="0" width="1070" align="center">

<tr>

<td>

<div id="main_content">

<br>

<div class="stafftext1">

Staff Area

</div>

<br>

<br>

 

</td>

</tr>

</table>

</td>

</tr>

</table>

 

 

 

<table class="footer"  border="0" width="100%" align="center">

<tr>

<td>

 

</td>

</tr>

</table>

 

</body>

</html>

 

<?php

      exit;

  } else {

      echo "<p>Bad cookie. Clear please clear them out and try to login again.</p>";

      exit;

  }

}

 

if (isset($_GET['p']) && $_GET['p'] == "login") {

  if ($_POST['name'] != $username) {

      echo "<p>Sorry, that username does not match. Use your browser back button to go back and try again.</p>";

      exit;

  } else if ($_POST['pass'] != $password) {

      echo "<p>Sorry, that password does not match. Use your browser back button to go back and try again.</p>";

      exit;

  } else if ($_POST['name'] == $username && $_POST['pass'] == $password) {

      setcookie('MyLoginPage', md5($_POST['pass'].$randomword));

      header("Location: $_SERVER[php_SELF]");

  } else {

      echo "<p>Sorry, you could not be logged in at this time. Refresh the page and try again.</p>";

  }

}

?>

 

<form action="<?php echo $_SERVER['PHP_SELF']; ?>?p=login" method="post"><fieldset>

<label><input type="text" name="name" id="name" /> Name</label><br />

<label><input type="password" name="pass" id="pass" /> Password</label><br />

<input type="submit" id="submit" value="Login" />

</fieldset></form>

 

 

Link to comment
https://forums.phpfreaks.com/topic/152037-newbie-needs-some-help-please/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.