Het lukt mij maar niet om een vaiable te gebruiken van een pagina voor een andere pagina via een session.

Ik heb een pagina die de gebruikersnaam en wachtwoord controleert van een formulier met een mysql database en dat werkt. Men krijgt dan een variable $authlevel en die wil ik dan meegeven aan bv. de pagina download.php

Dit is de usercheck.inc.php
-------------------------------
<?php
session_start();

$dbhost="localhost";
$dbuser="zzzzzzzzzz";
$dbpass="xxxxxxxxxxxxxx";
$db="websecurity";

$mysql_id=mysql_connect("$dbhost","$dbuser","$dbpass");

$sql="SELECT * FROM `users`";

$result=mysql_db_query("$db","$sql",$mysql_id) or die("Fout bij uitvoeren query");

while ($line=mysql_fetch_row($result)) {

if ($line[1]==$name && $line[2]==$password) {
$authlevel=$line[3];
}
else {
$authlevel="0";
}
}
mysql_close($mysql_id);

/* $_SESSION["level"]=$authlevel;
echo $authlevel;
echo $_SESSION["level"];
echo $authlevel; */

echo $authlevel;
session_register("authlevel");
$_SESSION["level"]=$authlevel;


?>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 //EN" "http://www.w3.org/TR/html4/strict.dtd">;
<html lang="nl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
<META NAME="GENERATOR" content="Microsoft FrontPage 6.0">
<META NAME="DESCRIPTION" CONTENT="beschrijving inhoud">
<META NAME="KEYWORDS" CONTENT="inhoud,sleutelworden">
<META NAME="WEB_AUTHOR"="Rene Wennekes">
<title>Dit is de titel</title>
</head>
<body>

<br>
<a href="download.php">Download pagina</a>

</body>
</html>
----------------------------------------------------------------
Dit is de download.php
----------------------------------------------------------------
<?php
session_start();

session_register("authlevel");
echo $authlevel;
echo $_SESSION["level"];


/* $authlevel=$_SESSION["level"];


$authlevel=$_SESSION["level"];
echo $_SESSION["level"];

echo $authlevel;
echo $_SESSION["level"];
echo $authlevel; */

?>
------------------------------------------------
Ik had twee methodes gezien op internet, maar beide wekren niet.
Je ziet dat ik een een paar regels gedeactiveerd heb.

Het resultaat van download.php is helemaat niets, nada.

Wat doe ik fout?

Mvg,

Rene
Code tags?

Zijn die fout? Welke code tags?
Kun je misschien wat specifieker zijn, want zolang doe ik geen php.

Mvg,

Rene
Niemand een idee?

Ik weet dat ik nog een uurtje te vroeg ben maar ff mijn php.ini staat op een windows doos.

[Session]
; Handler used to store/retrieve data.
session.save_handler = files

; Argument passed to save_handler. In the case of files, this is the path
; where data files are stored. Note: Windows users have to change this
; variable in order to use PHP's session functions.
; As of PHP 4.0.1, you can define the path as:
; session.save_path = "N;/path"
; where N is an integer. Instead of storing all the session files in
; /path, what this will do is use subdirectories N-levels deep, and
; store the session data in those directories. This is useful if you
; or your OS have problems with lots of files in one directory, and is
; a more efficient layout for servers that handle lots of sessions.
; NOTE 1: PHP will not create this directory structure automatically.
; You can use the script in the ext/session dir for that purpose.
; NOTE 2: See the section on garbage collection below if you choose to
; use subdirectories for session storage
;session.save_path = /tmp

; Whether to use cookies.
session.use_cookies = 1

; This option enables administrators to make their users invulnerable to
; attacks which involve passing session ids in URLs; defaults to 0.
; session.use_only_cookies = 1

; Name of the session (used as cookie name).
session.name = PHPSESSID

; Initialize session on request startup.
session.auto_start = 0

; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0

; The path for which the cookie is valid.
session.cookie_path = /

; The domain for which the cookie is valid.
session.cookie_domain =

; Handler used to serialize data. php is the standard serializer of PHP.
session.serialize_handler = php

; Define the probability that the 'garbage collection' process is started
; on every session initialization.
; The probability is calculated by using gc_probability/gc_divisor,
; e.g. 1/100 means there is a 1% chance that the GC process starts
; on each request.

session.gc_probability = 1
session.gc_divisor = 100

; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
session.gc_maxlifetime = 1440

; NOTE: If you are using the subdirectory option for storing session files
; (see session.save_path above), then garbage collection does *not*
; happen automatically. You will need to do your own garbage
; collection through a shell script, cron entry, or some other method.
; For example, the following script would is the equivalent of
; setting session.gc_maxlifetime to 1440 (1440 seconds = 24 minutes):
; cd /path/to/sessions; find -cmin +24 | xargs rm

; PHP 4.2 and less have an undocumented feature/bug that allows you to
; to initialize a session variable in the global scope, albeit register_globals
; is disabled. PHP 4.3 and later will warn you, if this feature is used.
; You can disable the feature and the warning separately. At this time,
; the warning is only displayed, if bug_compat_42 is enabled.

session.bug_compat_42 = 1
session.bug_compat_warn = 1

; Check HTTP Referer to invalidate externally stored URLs containing ids.
; HTTP_REFERER has to contain this substring for the session to be
; considered as valid.
session.referer_check =

; How many bytes to read from the file.
session.entropy_length = 0

; Specified here to create the session id.
session.entropy_file =

;session.entropy_length = 16

;session.entropy_file = /dev/urandom

; Set to {nocache,private,public,} to determine HTTP caching aspects
; or leave this empty to avoid sending anti-caching headers.
session.cache_limiter = nocache

; Document expires after n minutes.
session.cache_expire = 180

; trans sid support is disabled by default.
; Use of trans sid may risk your users security.
; Use this option with caution.
; - User may send URL contains active session ID
; to other person via. email/irc/etc.
; - URL that contains active session ID may be stored
; in publically accessible computer.
; - User may access your site with the same session ID
; always using URL stored in browser's history or bookmarks.
session.use_trans_sid = 0

; The URL rewriter will look for URLs in a defined set of HTML tags.
; form/fieldset are special; if you include them here, the rewriter will
; add a hidden <input> field with the info which is otherwise appended
; to URLs. If you want XHTML conformity, remove the form entry.
; Note that all valid entries require a "=", even if no value follows.
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=,fieldset="
session.save_path= E:\PHP\sessiondata ; argument passed to save_handler

Staat dit allemaal goed?

Ik kan nog steeds geen globala variabele doorzenden naar een andere pagina.
Ik zit hier echt mee vast.

Mvg,

Rene
Session_register = oud
Zoals jij het doet = dubbel op

Die opmerking over de code tags ging over deze code tags: [ignore]
[/ignore] die je gebruikt om ervoor te zorgen dat je code gehighlight wordt.

Zet verder eens error_reporting(E_ALL); bovenaan je script.
Kan iemand nog even de juiste syntax (een voorbeeld) ff laten zien.

Deze variabelen kun je toch meenemen naar een ander php webpagina en hoeft toch niet alleen te werken in de php-webpagina met dezelfde naam??????

Mvg,

Rene

<?php
//pagina 1
session_start();

$_SESSION['var'] = "Dit is een sessie.";

?>

<?php
//pagina 2
session_start();
echo $_SESSION['var'];
?>
Rik,

net ff jouw scriptje geplakt in 1.php en 2.php, maar krijgt wederom geen uivoer.

1.php en daarna 2.php geladen , maar scherm blijft leeg.

Rene
Sorry dat ik bump, maar het probleem is OPGELOST!!!!!!!!

path stond goed voor het opslaan van de sessiedata, maar IUSR_SERVERNAAM had geen schrijfrechten. Schrijfrechten gegeven......en het werkt.

Kan ik weer verder ......

grt,

Rene

Reageren