Précédent   Forum des professionnels en informatique > PHP > Langage
Langage Forum sur le langage PHP, la POO, les conventions, la sécurité, etc. Avant de poster : FAQ Langage, toutes les FAQ PHP, cours langage et sources PHP
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 23/04/2011, 21h59   #1
 
Femme noura wafi
Étudiant
Inscription : avril 2011
Messages : 12
Détails du profil
Informations personnelles :
Nom : Femme noura wafi
Localisation : Tunisie

Informations professionnelles :
Activité : Étudiant
Secteur : Conseil

Informations forums :
Inscription : avril 2011
Messages : 12
Points : -5
Points : -5
Par défaut Undefined index en php5

bonsoir,
j'ai une grande problème en php5 concernant l'appel d'une fonction dans la valeur d'un formulaire le code est le suivant:
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
require_once("connexion.php");
class hotel
{
public $Nomhotel;
public function affinomhotel()
{
$Nomhotel1=$_POST['nomhotel'];
$requete ="select Nomhotel from hotel where Nomhotel LIKE '%$Nomhotel1%'";
if($result =mysql_query($requete)){
while($ligne = mysql_fetch_array($result)) { 
$Nomhotel=$ligne[0];
echo $Nomhotel;
}
}
}
}
$obj =new hotel;
$obj->affinomhotel();
?>
ce code pour la fonction que je veux l'appeler et voici le code que je fais pour l'appeler:
Code html :
<input name="nomhotel" type="text" value ="<?php require_once('recherchernomhotel.php');?>">

il m'affiche la faute suivante:
Citation:
Notice: Undefined index: nomhotel in D:\EasyPHP-5.3.3\www\pfe\recherchernomhotel.php on line 8
palmerie
Sauriez-vous m'aider, s'il vous plait ?
Merci.
babamama est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/04/2011, 12h15   #2
Modérateur
 
Inscription : septembre 2010
Messages : 7 103
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 103
Points : 8 466
Points : 8 466
$_POST['nomhotel'] n'existe pas, verfie bien tes valeurs d'entré
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/04/2011, 19h21   #3
Membre du Club
 
Avatar de betadev
 
Homme
Développeur Web
Inscription : octobre 2008
Messages : 80
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 27
Localisation : Tunisie

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : octobre 2008
Messages : 80
Points : 56
Points : 56
Bonjour,

Apparemment tu as besoin de faire une recherche sur les noms des hotels .
Bon , voici un petit exemple pour exploiter la class :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
</head>
 
<body>
<?
if(isset($_POST['nomhotel']))
{
	require_once("connexion.php");
	class hotel
	{
		public $Nomhotel;
		public function affinomhotel()
		{
			$Nomhotel1=$_POST['nomhotel'];
			$requete ="select Nomhotel from hotel where Nomhotel LIKE '%$Nomhotel1%'";
			if($result =mysql_query($requete)){
				while($ligne = mysql_fetch_array($result)) { 
					$Nomhotel=$ligne[0];
					echo $Nomhotel;
				}
			}
		}
	}
 
	$obj =new hotel;
	$obj->affinomhotel();
}
?>
<form id="form1" name="form1" method="post" action="">
    <input name="nomhotel" type="text" />
    <input type="submit" name="Submit" value="Envoyer" />
</form>
</body>
</html>
betadev est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/04/2011, 22h31   #4
Membre habitué
 
Avatar de omar24
 
Homme Omar
Inscription : septembre 2010
Messages : 146
Détails du profil
Informations personnelles :
Nom : Homme Omar
Localisation : Maroc

Informations professionnelles :
Secteur : High Tech - Multimédia et Internet

Informations forums :
Inscription : septembre 2010
Messages : 146
Points : 125
Points : 125
Je pense que ta classe est un peu mal conçue !!!
en tout cas essaye de donner un argument à la fonction affinomhotel($nomhotel) et quand tu veux l'utiliser fais comme ça affinomhotel($_POST['nomhotel']) à condition que tu sois sur d'avoir envoyer un nomhotel dans ta requete post et que tu aies dèjà un objet de type Hotel.
omar24 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 06h16.


 
 
 
 
Partenaires

Hébergement Web