Jump to content

Newbie Needs Help With Log In Script


elexion

Recommended Posts

hey everyone, i'm having some problems again with my log in scripts.i'm getting the following error message:Notice: Undefined index: gebruikersnaam in C:\wamp\www\PhP_project\controlescript.php on line 18usersname / or password is incorrect.eventhough the password and usersname is correct.<?phpsession_start ();?><!DOCTYPE html public "-//W3C//DTD XHTML 1.0 strict //EN" "http://www.w3.org/TR/xhtmll/DTD/xhtmll-strict.dtd"> <html><head><title> Roc Asa </title><link rel="stylesheet" href="stijl.css" type="text/css"></head><body><?php include ("connect.php"); $wachtwoord = ($_POST["wachtwoord"]); $query = "SELECT * from user WHERE gebruikersnaam = '{$_POST['gebruikersnaam']}' AND wachtwoord = '".$wachtwoord."'"; $result = mysql_query($query, $db) or die('the query failed'); if (mysql_num_rows($result) > 0) { echo "correct"; $rij = mysql_fetch_array($result); echo $rij['gebruikersrol']; $_SESSION['gebruikersrol']==''; header("location: index.php?content=home"); } else { echo "<p>usersname / or password is incorrect.</p>"; } ?></body></html>this is what i have so far.can anyone give me a few hints what the problem could be.thanks for the help in advance :)

Link to comment
Share on other sites

The script and the page that calls the script are having a disagreement. It looks like your calling page does not have an element named gebruikersnaam. Check your form or javascript (whichever one generates the POST data).You can always var_dump($_POST) to see what data really is being posted.If you still can't figure it out, show us the form or javascript that generates the POST data.

Link to comment
Share on other sites

thanks for the help i found the problem which took me to the next problem.i want the person that visits the website to see how he's logged in his usersname.How do i make this functional so far í have this: <?phpinclude ("connect.php");?><ul><li><a href="php"></a></li><li><a href=".php"></a></li><li><a href=".php"></a></li><li><a href=".php"></a></li><li><a href=".php"></a></li><li><a href=".php"></a></li><li><a href=".php"></a></li><li><a href=".php"></a></li><li><a href=".php"></a></li><br /><?phpif($_SESSION['gebruikersrol']=='')echo "your not logged in";if($_SESSION['gebruikersrol']=='admin'){}elseecho "you are not logged in";?></ul>the error message i get is Notice: Undefined variable: _SESSION in C:\wamp\www\PhP_project\navigatie.php on line 15your not logged inNotice: Undefined variable: _SESSION in C:\wamp\www\PhP_project\navigatie.php on line 17

Link to comment
Share on other sites

thank you for that advice Deirdre's Dad its working in a way.problem i have now is i'm not sure how to make the string showthe persons usersname when he logs in. i'm pretty sure it has somethingto do with a ._GET state but not sure how to use it.this is what i have right now <?phpsession_start();include ("connect.php");echo "your logged in as: ".$_SESSION['gebruikersnaam'] = '';?>so the now it says your logged in as can anyone help me out?

Link to comment
Share on other sites

This should work,

<?phpsession_start();include ("connect.php");$username = $_SESSION['gebruikersnaam'];print "Your logged in as: $username";?>

Link to comment
Share on other sites

then you mean its not working,the code works as i tested before posting.you must use session_start();before you do anything else on the script,other than that you have not set the session variable so its not there to print!

Link to comment
Share on other sites

to set the session variable,in your first post, it shows you are not setting the session for there username!

<?phpsession_start();include ("connect.php");if (user exist check) {$username = $_POST['username'];$_SESSION['gebruikersnaam'] = $username;}else{//user does not exist exit("error!");}?>

Link to comment
Share on other sites

hello everyone i have a little problem again not with my session variables anymore though this time it's about my querys.the code is:<?php$query = "select `project`.`projectID`, `project`.`naamproject`, `vraag`.`vraagID`, `vraag`.`vraagomschrijving` from `vraag`, `project`";$vervolg = "where `project`.`projectID` = `vraag`.`projectID`";if ($_POST['naamproject'] != 'default'){ if ($vervolg == "") { $vervolg = $vervolg." where "; } else { $vervolg = $vervolg." and "; } $vervolg = $vervolg." `vraag`.`projectID` like '%".$_POST['naamproject']."%'";}$query = $query.$vervolg;echo $vraagomschrijving;?>when i run it i for some reason get this uitloggen Notice: Undefined variable: vraagomschrijving in C:\wamp\www\new_project\strings.php on line 17ingelogt als janprojectnaam: 1leerjaar: 1project ID : PhP sessieprojectnaam: 1leerjaar: 2project ID : PhP sessieverkeerde project

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...