473,386 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

in this page, the user must specify his username and his password, then it supports d

Leen
22
in this page, the user must specify his username and his password, then it supports diverse on 'login'. but there is a fault. sentence after the welcome, he said: "Undefined index: prenom, nompere, nom". Why?u can help me...

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <?php
  3. session_start();
  4. if(isset($_POST["nom"]))
  5. {
  6. $_session["nom"]=$_POST["nom"];
  7. include("MySQLConnection.php");
  8. $sql= "Select * FROM etudiante WHERE userName_etu=".$_POST['userNom']." and password_etu= MD5(".$_POST['pass'].")";
  9. $reponse=mysql_query($sql);
  10. if(mysql_num_rows($reponse) > 0)
  11. {
  12.  $d=mysql_fetch_array($reponse);
  13.  $_session["Prenom"] = $d["prenom_etu"];
  14.  $_session["Nom"] = $d["nom_etu"];
  15. }
  16. else
  17. {
  18.  echo ("error" . mysql_error()); 
  19. }
  20. mysql_close();
  21. }
  22. ?>
  23. <html>
  24. <head>
  25. <title>Sign In Reponse</title>
  26. </head>
  27. <body>
  28. <p><strong>Welcome <?php echo($_SESSION["prenom"]. "" . $_SESSION["nompere"]. "" . $_SESSION["nom"]); ?></strong></p>
  29. <p><script type="java/script"> alert ("What do want to do? please choose <br>
  30.  <a href= "NewYear.php">Registration new year</a></br>
  31.  <a href= "Note.php">Leaving the School</a></br>
  32.  <a href= "Modifier.php">Modify personal information</a></br>
  33.  <a href= "Note.php">See ur notes</a></br>);
  34. </body>
  35. </html>
Aug 21 '10 #1
3 1306
Atli
5,058 Expert 4TB
If you want to manipulate a session variable, you need to use the $_SESSION array. It needs to be upper-case, not lower or mixed case. (That is, doing $_session or $_Session will NOT work. It has to be $_SESSION)

Also, you should verify that the session variables you use in you welcome message are actually set before using them, or you may end up with "Undefined index" warnings. Those warnings are shown when you try to print an index of an array that doesn't exist, so you need to make sure it does before using it.

For example:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. session_start();
  3.  
  4. if(!isset($_SESSION['name'])) {
  5.     $name = "Some name to use when no name is set";
  6. }
  7. else {
  8.     $name = $_SESSION['name'];
  9. }
  10. ?>
  11. <html>
  12. <head>etc...
  13. <body>
  14.     <h1>Welcome, <?php echo $name; ?></h1>
  15. </body>
  16. </html>
  17.  
Aug 22 '10 #2
Leen
22
thank u for ur help.
i used session in upper-case. and i simplified this page to the minimum, but now a new problem appeared:
he said: diagnose connection problems
why???
this is my new page:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <?php
  3. session_start();
  4. include("MySQLConnection.php");
  5. $sql= "Select nom_etu,prenom_etu,pere_nom_etu FROM etudiante WHERE userName_etu=".$_POST['userNom']." and password_etu= MD5(".$_POST['pass'].")";
  6. $reponse=mysql_query($sql);
  7. if(mysql_num_rows($reponse) < 0)
  8. {
  9.  echo ("error" . mysql_error()); 
  10. }
  11. mysql_close();
  12. ?>
  13. <html>
  14. <head>
  15. <title>Sign In Reponse</title>
  16. </head>
  17. <body>
  18. <p><strong>Welcome <?php echo($_SESSION["prenom_etu"]. "" . $_SESSION["pere_nom_etu"]. "" . $_SESSION["nom_etu"]); ?></strong></p>
  19. <p><script type="java/script"> alert ("What do want to do? please choose <br>
  20.  <a href= "NewYear.php">Registration new year</a></br>
  21.  <a href= "Note.php">Leaving the School</a></br>
  22.  <a href= "Modifier.php">Modify personal information</a></br>
  23.  <a href= "Note.php">See ur notes</a></br>);
  24. </body>
  25. </html>
Aug 22 '10 #3
Atli
5,058 Expert 4TB
Where is that error coming from? It's not something PHP itself would say.

Also:
Expand|Select|Wrap|Line Numbers
  1. if(mysql_num_rows($reponse) < 0) 
This will never be true. mysql_num_rows always returns 0 or higher. (Or FALSE, but that's basically the same as 0)

P.S.
Please remember to use [code] tags when posting code!
Aug 22 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: deko | last post by:
I want to use htaccess for authentication on my php site since I only have a few users who need access to secure areas. So, I created a new directory off public_html (secretDocs) and in that...
4
by: Lobang Trader | last post by:
Hi all, I am trying to create a username and a password class. I would like to know what are the RECOMMENDED minimum and maximum length for both fields? These fields will be something like...
2
by: john brown | last post by:
There is a web page that I access frequently and would like to automate the authentication of the username and password. I would like to user a perl script but I'm not really sure about the steps....
0
by: N.K. | last post by:
Hello, I'm doing automated database dump and want to be able to specify Username and Passowrd in my shell script for pg_dump. When I do man pg_dump there are no options for password. There is...
5
by: Tony | last post by:
Please help, I've scoured the web but cannot find an answer to this! I want to use WebRequest to get the contents of a web page. The trouble is, the page require you to go to a login page (using...
3
by: Funky | last post by:
Hi, I have developed an ASP.NET application which has been running in production for around 3 months without any major glitches. Recently, a user was attempting to upload a rather large CSV file...
1
by: thoducng | last post by:
I am writing some code to access share folder on a remote network. DirectoryInfo dicInfo = new DirectoryInfo("remoteNetwork\shareFolder"); if (dicInfo.Exists) { //application code...
0
by: stefan.fasth | last post by:
Hi I wanna post a username/password to another site, which recieves the information with request.form. I have a page which fills a form with hidden input boxes. When the user enters the page...
8
by: ajos | last post by:
hi frnds, im trying to convert my servlets database configuration from ms access to mysql database.however im getting some error like no driver found exception. to verify this error ive...
4
by: jonny | last post by:
I would like to add a password and user name to my website. If the username and password is correct than activate the hyperlinks and buttons. Could you please share some code how how to achieve...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.