le 11/11/2012 à 13:18
James0027
salut jai veux modifier ma donne de la table a laide dune page php La voici la page:
<?
$host="localhost";
$dbname="assistance";
$user='root';
$pass='';
$bdd = new PDO('mysql:host=localhost;dbname=assistance', $user, $pass);
$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if(isset($_GET['upd'])) $Num= $_GET['upd'];
if(isset($_POST['nom'])){
$Num = $_POST['Num'];
$nom = $_POST['nom'];
$fonction = $_POST['fonction'];
$mat = $_POST['mat'];
$Description1 = $_POST['Description1'];
$Description2 = $_POST['Description2'];
$Description3 = $_POST['Description3'];
$detail = $_POST['detail'];
$Par = $_POST['Par'];
try{$sql = "UPDATE demande SET nom=?, fonction=?, mat=?, Description1=? , Description2=?, Description3=?, detail=?, Par=? WHERE Num=?";
$query = $bdd->prepare($sql);
$query->execute(array($nom,$fonction,$mat,$Description1,$Description2,$Description3,$detail,$Par,$Num));
}
catch(EXCEPTION $e){
die($e->getMessage());
}
header("location:gestiondesdemandes.php");
}
try{
$sql = "SELECT * FROM demande WHERE Num=$Num";
$result = $bdd->prepare($sql);
$result->execute();
$ligne = $result->fetch();
}
catch(EXCEPTION $e){
die($e->getMessage());
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Modification</title>
<link rel="stylesheet" type="text/css" href="../css/styleV1.0.css" />
</head>
<body>
<form action="update.php" method="post">
<input type="hidden" name="id" value="<?php print $id; ?>"/>
<table width="492" height="380">
<tr><td width="62">Nom d`utilisateur</td><td width="248"><input type="text" name="nom" value="<?php print $ligne['nom']; ?>"/></td></tr>
<tr>
<tr>
<td width="62">Fonction</td>
<td width="248"><input type="text" name="fonction" value="<?php print $ligne['fonction']; ?>"/></td></tr>
<tr>
<td>Matricule</td><td><input type="text" name="mat" value="<?php print $ligne['mat']; ?>"/></td></tr>
<tr><td>Departement</td><td><input type="text" name="departement" value="<?php print $ligne['departement']; ?>"/></td></tr>
<tr>
<td width="62">1 er Probleme</td>
<td width="248"><input type="text" name="Description1" value="<?php print $ligne['Description1']; ?>"/></td></tr>
<tr>
<tr>
<td width="62">2 eme Probleme</td>
<td width="248"><input type="text" name="Description2" value="<?php print $ligne['Description2']; ?>"/></td></tr>
<tr>
<tr>
<td width="62"> 3 eme Probleme</td>
<td width="248"><input type="text" name="Description3" value="<?php print $ligne['Description3']; ?>"/></td></tr>
<tr>
<tr><td>Details</td><td><textarea cols="20" rows="4" name="msg"><?php print $ligne['detail']; ?>" </textarea></td></tr>
<tr><td>Travail Effectué</td><td><textarea cols="20" rows="4" name="Travail Effectué"><?php print $ligne['par']; ?>" </textarea></td></tr>
<tr><td><input type="submit" value="Modifier"/></td></tr>
</table>
<a href="admin.php"> Retour</a>
</form>
</body>
</html>
et voici ereur:
setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); if(isset($_POST['nom'])){ $Num = $_POST['Num']; $nom = $_POST['nom']; $fonction = $_POST['fonction']; $mat = $_POST['mat']; $Description1 = $_POST['Description1']; $Description2 = $_POST['Description2']; $Description3 = $_POST['Description3']; $detail = $_POST['detail']; $Par = $_POST['Par']; try{$sql = "UPDATE demande SET nom=?, fonction=?, mat=?, Description1=? , Description2=?, Description3=?, detail=?, Par=? WHERE Num=?"; $query = $bdd->prepare($sql); $query->execute(array($nom,$fonction,$mat,$Description1,$Description2,$Description3,$detail,$Par,$Num)); } catch(EXCEPTION $e){ die($e->getMessage()); } header("location:gestiondesdemandes.php"); } try{ $sql = "SELECT * FROM demande WHERE Num=$Num"; $result = $bdd->prepare($sql); $result->execute(); $ligne = $result->fetch(); } catch(EXCEPTION $e){ die($e->getMessage()); } ?>
Aides Moi svp C urgent
<?
$host="localhost";
$dbname="assistance";
$user='root';
$pass='';
$bdd = new PDO('mysql:host=localhost;dbname=assistance', $user, $pass);
$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if(isset($_GET['upd'])) $Num= $_GET['upd'];
if(isset($_POST['nom'])){
$Num = $_POST['Num'];
$nom = $_POST['nom'];
$fonction = $_POST['fonction'];
$mat = $_POST['mat'];
$Description1 = $_POST['Description1'];
$Description2 = $_POST['Description2'];
$Description3 = $_POST['Description3'];
$detail = $_POST['detail'];
$Par = $_POST['Par'];
try{$sql = "UPDATE demande SET nom=?, fonction=?, mat=?, Description1=? , Description2=?, Description3=?, detail=?, Par=? WHERE Num=?";
$query = $bdd->prepare($sql);
$query->execute(array($nom,$fonction,$mat,$Description1,$Description2,$Description3,$detail,$Par,$Num));
}
catch(EXCEPTION $e){
die($e->getMessage());
}
header("location:gestiondesdemandes.php");
}
try{
$sql = "SELECT * FROM demande WHERE Num=$Num";
$result = $bdd->prepare($sql);
$result->execute();
$ligne = $result->fetch();
}
catch(EXCEPTION $e){
die($e->getMessage());
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Modification</title>
<link rel="stylesheet" type="text/css" href="../css/styleV1.0.css" />
</head>
<body>
<form action="update.php" method="post">
<input type="hidden" name="id" value="<?php print $id; ?>"/>
<table width="492" height="380">
<tr><td width="62">Nom d`utilisateur</td><td width="248"><input type="text" name="nom" value="<?php print $ligne['nom']; ?>"/></td></tr>
<tr>
<tr>
<td width="62">Fonction</td>
<td width="248"><input type="text" name="fonction" value="<?php print $ligne['fonction']; ?>"/></td></tr>
<tr>
<td>Matricule</td><td><input type="text" name="mat" value="<?php print $ligne['mat']; ?>"/></td></tr>
<tr><td>Departement</td><td><input type="text" name="departement" value="<?php print $ligne['departement']; ?>"/></td></tr>
<tr>
<td width="62">1 er Probleme</td>
<td width="248"><input type="text" name="Description1" value="<?php print $ligne['Description1']; ?>"/></td></tr>
<tr>
<tr>
<td width="62">2 eme Probleme</td>
<td width="248"><input type="text" name="Description2" value="<?php print $ligne['Description2']; ?>"/></td></tr>
<tr>
<tr>
<td width="62"> 3 eme Probleme</td>
<td width="248"><input type="text" name="Description3" value="<?php print $ligne['Description3']; ?>"/></td></tr>
<tr>
<tr><td>Details</td><td><textarea cols="20" rows="4" name="msg"><?php print $ligne['detail']; ?>" </textarea></td></tr>
<tr><td>Travail Effectué</td><td><textarea cols="20" rows="4" name="Travail Effectué"><?php print $ligne['par']; ?>" </textarea></td></tr>
<tr><td><input type="submit" value="Modifier"/></td></tr>
</table>
<a href="admin.php"> Retour</a>
</form>
</body>
</html>
et voici ereur:
setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); if(isset($_POST['nom'])){ $Num = $_POST['Num']; $nom = $_POST['nom']; $fonction = $_POST['fonction']; $mat = $_POST['mat']; $Description1 = $_POST['Description1']; $Description2 = $_POST['Description2']; $Description3 = $_POST['Description3']; $detail = $_POST['detail']; $Par = $_POST['Par']; try{$sql = "UPDATE demande SET nom=?, fonction=?, mat=?, Description1=? , Description2=?, Description3=?, detail=?, Par=? WHERE Num=?"; $query = $bdd->prepare($sql); $query->execute(array($nom,$fonction,$mat,$Description1,$Description2,$Description3,$detail,$Par,$Num)); } catch(EXCEPTION $e){ die($e->getMessage()); } header("location:gestiondesdemandes.php"); } try{ $sql = "SELECT * FROM demande WHERE Num=$Num"; $result = $bdd->prepare($sql); $result->execute(); $ligne = $result->fetch(); } catch(EXCEPTION $e){ die($e->getMessage()); } ?>
Aides Moi svp C urgent