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... - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
<?php
-
session_start();
-
if(isset($_POST["nom"]))
-
{
-
$_session["nom"]=$_POST["nom"];
-
include("MySQLConnection.php");
-
$sql= "Select * FROM etudiante WHERE userName_etu=".$_POST['userNom']." and password_etu= MD5(".$_POST['pass'].")";
-
$reponse=mysql_query($sql);
-
if(mysql_num_rows($reponse) > 0)
-
{
-
$d=mysql_fetch_array($reponse);
-
$_session["Prenom"] = $d["prenom_etu"];
-
$_session["Nom"] = $d["nom_etu"];
-
}
-
else
-
{
-
echo ("error" . mysql_error());
-
}
-
mysql_close();
-
}
-
?>
-
<html>
-
<head>
-
<title>Sign In Reponse</title>
-
</head>
-
<body>
-
<p><strong>Welcome <?php echo($_SESSION["prenom"]. "" . $_SESSION["nompere"]. "" . $_SESSION["nom"]); ?></strong></p>
-
<p><script type="java/script"> alert ("What do want to do? please choose <br>
-
<a href= "NewYear.php">Registration new year</a></br>
-
<a href= "Note.php">Leaving the School</a></br>
-
<a href= "Modifier.php">Modify personal information</a></br>
-
<a href= "Note.php">See ur notes</a></br>);
-
</body>
-
</html>
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: -
<?php
-
session_start();
-
-
if(!isset($_SESSION['name'])) {
-
$name = "Some name to use when no name is set";
-
}
-
else {
-
$name = $_SESSION['name'];
-
}
-
?>
-
<html>
-
<head>etc...
-
<body>
-
<h1>Welcome, <?php echo $name; ?></h1>
-
</body>
-
</html>
-
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: - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
<?php
-
session_start();
-
include("MySQLConnection.php");
-
$sql= "Select nom_etu,prenom_etu,pere_nom_etu FROM etudiante WHERE userName_etu=".$_POST['userNom']." and password_etu= MD5(".$_POST['pass'].")";
-
$reponse=mysql_query($sql);
-
if(mysql_num_rows($reponse) < 0)
-
{
-
echo ("error" . mysql_error());
-
}
-
mysql_close();
-
?>
-
<html>
-
<head>
-
<title>Sign In Reponse</title>
-
</head>
-
<body>
-
<p><strong>Welcome <?php echo($_SESSION["prenom_etu"]. "" . $_SESSION["pere_nom_etu"]. "" . $_SESSION["nom_etu"]); ?></strong></p>
-
<p><script type="java/script"> alert ("What do want to do? please choose <br>
-
<a href= "NewYear.php">Registration new year</a></br>
-
<a href= "Note.php">Leaving the School</a></br>
-
<a href= "Modifier.php">Modify personal information</a></br>
-
<a href= "Note.php">See ur notes</a></br>);
-
</body>
-
</html>
Atli 5,058
Recognized Expert Expert
Where is that error coming from? It's not something PHP itself would say.
Also: - 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!
Sign in to post your reply or Sign up for a free account.
Similar topics |
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
|
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 = ??????
|
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>...
|
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
|
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...
| |
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.
|
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
|
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
|
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...
|
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.
|
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...
| |
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,...
|
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...
|
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...
|
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,...
|
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...
|
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...
| |
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
|
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...
| | |