Page 1 of 1

['PHP_SELF'] in a Frameset

Posted: Tue Jul 13, 2004 8:30 pm
by jimmy
I'm trying to use
<a href="<?=$_SESSION['PHP_SELF']?>">here</a>
in a Frameset. It loads the whole page frameset inside the main frame.
The best way to explain my problem is to go to
HTTP://www.rivermount.net/parents
and put in a wrong user name and password. Then click the try again.
Wow! I just tried it to make sure I was saying the right thing and noticed that Mozilla does it correctly but IE6 doesn't. I guess that doesn't really suprise anyone does it. I would love to get my head around this.
Jim Durand
?>

Posted: Tue Jul 13, 2004 9:32 pm
by feyd

Code: Select all

<a href="">here</a>
is what is shown on the form's action page...

Posted: Tue Jul 13, 2004 9:42 pm
by Deemo
Its $_SERVER['PHP_SELF'] not $_SESSION!

Posted: Wed Jul 14, 2004 12:16 am
by James M.
couldnt you just use $PHP_SELF?

Posted: Wed Jul 14, 2004 1:00 am
by jimmy
It was from a tutorial. It works fine as a single web page.
Here is the accesscontrol.php

Code: Select all

<?php // accesscontrol.php
include_once 'common.php';
include_once 'db.php';

session_start();

$uid = isset($_POST['uid']) ? $_POST['uid'] : $_SESSION['uid'];
$pwd = isset($_POST['pwd']) ? $_POST['pwd'] : $_SESSION['pwd'];

if(!isset($uid)) {
  ?>
  <!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>
    <title> Please Log In for Access </title>
    <meta http-equiv="Content-Type"
      content="text/html; charset=iso-8859-1" />
  </head>
  <body>
  <h1> Login Required </h1>
  <p>You must log in to access this area of the site. If you are
     not a registered user, please download the PDF Form available on this
page and return it to the College.</p>
  <p><form method="post" action="<?=$_SERVER['PHP_SELF']?>">
    User ID: <input type="text" name="uid" size="8" /><br />
    Password: <input type="password" name="pwd" SIZE="8" /><br />
    <input type="submit" value="Log in" />
  </form></p>
<a href="Parent_Access_Form.pdf">Parent Access Form</a> 

</body>
  </html>
  <?php
  exit;
}

$_SESSION['uid'] = $uid;
$_SESSION['pwd'] = $pwd;

dbConnect("rivermount_net");
$sql = "SELECT * FROM parents WHERE
        userid = '$uid' AND password = PASSWORD('$pwd')";
$result = mysql_query($sql);
if (!$result) {
  error('A database error occurred while checking your '.
        'login details.\\nIf this error persists, please '.
        'contact you@example.com.');
}

if (mysql_num_rows($result) == 0) {
  unset($_SESSION['uid']);
  unset($_SESSION['pwd']);
  ?>
  <!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>
    <title> Access Denied </title>
    <meta http-equiv="Content-Type"
      content="text/html; charset=iso-8859-1" />
  </head>
  <body>
  <h1> Access Denied </h1>
  <p>Your user ID or password is incorrect, or you are not a
     registered user on this site. To try logging in again, click
     <a href="<?=$_SESSION['PHP_SELF']?>">here</a>. To register for
 access,please download the PDF Form available on this
page and return it to the College.</p>
<BR>
<a href="Parent_Access_Form.pdf">Parent Access Form</a> 

  </body>
  </html>
  <?php
  exit;
}

   $sql = "UPDATE parents SET
              last_visit = now()
	 WHERE
			 userid = '$uid'";
			     mysql_query($sql);

			  
$username = mysql_result($result,0,'fullname');
$joined = mysql_result($result,0,'join_date');
$visited = mysql_result($result,0,'last_visit');
?>
! Weirdan> please use the php tags ! :arrow: Posting code in the forums

Posted: Wed Jul 14, 2004 1:01 am
by jimmy
Sorry about the code, I did read the sticky, I just don't know how I guess!
Jim

Posted: Wed Jul 14, 2004 2:13 am
by feyd
the solution was mentioned by Deemo.. :roll:

Posted: Wed Jul 14, 2004 4:25 am
by jimmy
Thanks Deemo (and feyd) it worked like a charm.

Posted: Wed Jul 14, 2004 6:31 am
by m3mn0n
You should message the tutorial author to avoid further problems for other readers.