[SOLVED] ['PHP_SELF'] in a Frameset

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jimmy
Forum Newbie
Posts: 6
Joined: Tue Jul 13, 2004 8:30 pm

['PHP_SELF'] in a Frameset

Post 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
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

<a href="">here</a>
is what is shown on the form's action page...
Deemo
Forum Contributor
Posts: 418
Joined: Sun Jan 18, 2004 11:48 am
Location: Washington DC

Post by Deemo »

Its $_SERVER['PHP_SELF'] not $_SESSION!
User avatar
James M.
Forum Contributor
Posts: 119
Joined: Wed Mar 31, 2004 6:41 pm
Location: Tallahassee

Post by James M. »

couldnt you just use $PHP_SELF?
jimmy
Forum Newbie
Posts: 6
Joined: Tue Jul 13, 2004 8:30 pm

Post 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
jimmy
Forum Newbie
Posts: 6
Joined: Tue Jul 13, 2004 8:30 pm

Post by jimmy »

Sorry about the code, I did read the sticky, I just don't know how I guess!
Jim
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the solution was mentioned by Deemo.. :roll:
jimmy
Forum Newbie
Posts: 6
Joined: Tue Jul 13, 2004 8:30 pm

Post by jimmy »

Thanks Deemo (and feyd) it worked like a charm.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

You should message the tutorial author to avoid further problems for other readers.
Post Reply