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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
| <?php
if (isset($_POST['t_rechercher']))
{
$cn = new pdo('mysql:host=localhost;dbname=dbmou', 'root', '');
$sth = $cn->prepare('SELECT LAST_NAME,LOGIN,WKG_NAME,BE_NAME FROM user WHERE LAST_NAME like :recherche');
$sth->execute(array(':recherche'=>'%' . $_POST['t_rechercher'] . '%'));
while ($enrg = $sth->fetch(PDO::FETCH_NUM))
{
echo '<form id="form1" name="form1" method="post" action="requete.php">
<table width="420" border="0">
<tr>
<td width="169" bgcolor="#CCFF00"><label>
<input name="rechercher" type="submit" id="rechercher" value="Rechercher" />
</label></td>
<td width="169" bgcolor="#CCFF00"><label>
<input name="t_rechercher" type="text" id="t_rechercher" value="$enrg[0]" />
</label>Recherche par nom</td>
</tr>
<tr>
<td>Nom</td>
<td><label>
<input name="t_nom" type="text" id="t_nom" value="$enrg[0]"/>
</label></td>
<td><label>
</tr>
<tr>
<td>login</td>
<td><label>
<input name="t_login" type="text" id="t_login" value="$enrg[1]" />
</label></td>
</tr>
<tr>
<td>WKG</td>
<td><label>
<input name="t_wkg" type="text" id="t_wkg" value="$enrg[2]" />
</label></td>
</tr>
<tr>
<td>BE</td>
<td><input name="t_be" type="text" id="t_be" value="$enrg[3]"/></td>
</tr>
<tr>
<td colspan="2"><label>
<input name="nouveau" type="reset" id="nouveau" value="Nouveau"/>
<input name="ajouter" type="submit" id="ajouter" value="Ajouter"/>
<input name="modifier" type="submit" id="modifier" value="Modidier"/>
<input name="supprimer" type="submit" id="supprimer" value="Supprimer"/>
</label></td>
</tr>
</table>
<p> </p>
</form>';
}
//else
//{
//echo '<body onLoad="alert(\'Client introuvable...\')">';
//echo '<meta http-equiv="refresh" content="0;URL=index.php">';
//}
//else
{
if (isset($_POST['ajouter']))
if($nom=='')
{
echo '<body onLoad="alert(\'Le nom obligatoire\')">';
echo '<meta http-equiv="refresh" content="0;URL=index.php">';
}
elseif ($prenom=='')
{
echo '<body onLoad="alert(\'login obligatoire...\')">';
echo '<meta http-equiv="refresh" content="0;URL=index.php">';
}
elseif($tel=='')
{
echo '<body onLoad="alert(\'Workgroup obligatoire...\')">';
echo '<meta http-equiv="refresh" content="0;URL=index.php">';
}
else
{
$rqt="insert user_basalte values('$nom','$LOGIN','$WKG','$BE')";
mysql_query($rqt);
echo '<body onLoad="alert(\'Ajout effectuée...\')">';
echo '<meta http-equiv="refresh" content="0;URL=index.php">';
mysql_close();
}
if (isset($_POST['modifier']))
if($nom=='' || $LOGIN=='' ||$WKG=='' )
{
echo '<body onLoad="alert(\'fair une recherch avant la modification ou verifiez les champs obligatoire...\')">';
echo '<meta http-equiv="refresh" content="0;URL=index.php">';
}
else
{
$rqt="update user set LAST_NAME='$nom',LOGIN='$LOGIN',WKG_NAME='$WKG',BE_NAME='$BE' where LAST_NAME='$rech'";
mysql_query($rqt);
echo '<body onLoad="alert(\'Modification effectuée...\')">';
echo '<meta http-equiv="refresh" content="0;URL=index.php">';
mysql_close();
}
elseif(isset($_POST['supprimer']))
{
$rqt="delete FROM user where LAST_NAME ='$rech'";
mysql_query($rqt);
echo '<body onLoad="alert(\'Suppression effectuée...\')">';
echo '<meta http-equiv="refresh" content="0;URL=index.php">';
mysql_close();
}
}
}
?>
<?php
$cn=mysql_connect("localhost","root","");
mysql_select_db("sdmsg",$cn)or die(mysql_error());
$req="SELECT LAST_NAME,WKG_NAME,LOGIN,BE_NAME FROM user WHERE LAST_NAME LIKE '%" . $_POST['t_rechercher'] . "%'";
mysql_query($req);
$res=mysql_query($req,$cn);
?>
<table width="630" align="left" bgcolor="#CCCCCC">
<tr >
<td width="152">LAST_NAME</td>
<td width="152">WKG_NAME</td>
<td width="152">LOGIN</td>
<td width="66">BE_NAME</td>
</tr>
<?php
$var=0;
while($row=mysql_fetch_array($res))
{
if ($var==0)
{
?>
<tr bgcolor="#EEEEEE">
<td><?php echo $row[0]; ?></td>
<td><?php echo $row[1]; ?></td>
<td><?php echo $row[2]; ?></td>
<td><?php echo $row[3]; ?></td>
</tr>
<?php
$var=1;
}
else
{
?>
<tr bgcolor="#FFCCCC">
<td><?php echo $row[0]; ?></td>
<td><?php echo $row[1]; ?></td>
<td><?php echo $row[2]; ?></td>
<td><?php echo $row[3]; ?></td>
</tr>
<?php
$var=0;
}
}
?>
</table> |
Partager