473,761 Members | 3,651 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Leen
22 New Member
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 1331
Atli
5,058 Recognized Expert Expert
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 New Member
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 Recognized Expert Expert
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
37738
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 directory there is a .htaccess file that looks like this: AuthType Basic AuthName "someuser" AuthUserFile "/home/mydirectory/.htpasswds/secretDocs/passwd" require valid-user
4
6077
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 this: private static final int DEFAULT_MINIMUM_LENGTH = ??????
2
18582
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. If someone could point me in the right direction. I don't know if it's this simple but wouldn't it just be a matter of using the LWP module. Calling the webpage and passing in the parameters? Any help would be appreciated. <html>...
0
3460
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 -U username to specify username which actually doesn't work for me, I still get prompted for username, but there is nothing to specify password. Is there anyway of going around this? I need to automate everything
5
17577
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 ASP - not ASP.NET), and enter a username and password to get in. How do I use WebRequest in this situation? I cannot find any way of supplying the username and password. The '.Credentials' does not work because that is only for Windows...
3
1783
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 and ran into a strange problem. After roughly 3 minutes of processing, the application reprompted the user for their user name and password (NT authentication). At this point, the ASP.NET page re-fired the last event that it was processing.
1
4019
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 followed
0
1424
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 a onLoad submits the form and opens the recieving page in a new window. If the user now switches back to the sending windows and checks the
8
28597
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 made a simple database in jsp(just to check if my mysql is working smoothly otherwise) which access' the username.....but in the process im getting a error--> java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO) i have...
4
1795
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 this? I have several buttons and links on my home page and do not want it to be active until the user enters the correct password. Using ASP.NET with Visual Studio 2005.
0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9336
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10111
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9948
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5215
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3866
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2738
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.