Exercice 1 :
<table>
<tr align="center">
</tr>
<tr>
</tr>
<tr>
<tr align="left">
</tr>
<tr align="center">
</tr>
</table>
</form>
<script>
$('#message').hide();
</script>"
<?php
function database_open($db) {
$host = '127.0.0.1';
$user = 'root';
$pass = '';
$errnum=mysqli_connect_errno();
if ($errnum)
{ $errmsg=mysqli_connect_error();
exit();
return $acces;
}
function database_close($link) {
mysql_close($link);
$db=database_open('scott');
$login=$db->real_escape_string(htmlspecialchars($_POST['login']));
$pass=$db->real_escape_string(htmlspecialchars($_POST['pass']));
$data=$req->fetch_row();
if($data[0]==1){
echo "
<script>
$('#message').slideDown(1000);
</script>";
}else{
echo "
<script>
$('#message').html('Connection échouée!!!');
$('#message').slideDown(1000);
</script>";
?>
Exercice 2 :
Correction: Exercice 2
<?php
require("list_modifiable.php");
require("list_option.php");
function database_open($db) {
$host = '127.0.0.1';
$user = 'root';
$pass = '';
$errnum=mysqli_connect_errno();
if ($errnum)
{ $errmsg=mysqli_connect_error();
echo "Connexion impossible:$errmsg";
exit();
return $acces;
function database_close($link) {
mysql_close($link);
$db=database_open('scott');
function creer_nouveau(){
?>
<table>
<tr>
</tr>
<tr>
</tr>
<tr>
<?php
$db=database_open('scott');
while($data=$req->fetch_row()){
$tableau[]=$data[0];
list_modifiable($tableau,"job");
?>
</tr>
<tr>
<td>
<?php
$db=database_open('scott');
$tableau=array();
while($data=$req->fetch_row()){
$tableau[]=$data[0];
list_option($tableau,"chef");
?></td>
</tr>
<tr>
</tr>
<tr>
<tr>
<td>
<?php
$db=database_open('scott');
$tableau=array();
while($data=$req->fetch_row()){
$tableau[]=$data[0];
list_option($tableau,"dept");
?> </td>
</tr>
<tr>
<tr align="left">
</tr>
</table>
</form>
<?php
if (isset($_GET['new'])){
if($_GET['new']==0){
creer_nouveau();
if (isset($_POST['nom'])){
$nom=$_POST['nom'];
$num=$_POST['n'];
$job=$_POST['job'];
$chef=$_POST['chef'];
$sal=$_POST['sal'];
$dept=$_POST['dept'];
$dat=$_POST['d'];
$db=database_open("scott");
$mgr=$req->fetch_row()[0];
$ndept=$req->fetch_row()[0];
$dat=strtotime($dat);
$dat1=date('y-m-d',$dat);
$req=$db->query($sql);
$req=$db->query($sql);
}}}
?>
Fichier liste_modifiable.php
<?php
function list_modifiable($tableau,$name){
for($i=0;$i<count($tableau);$i++){
echo "</datalist>";
}
?>
Fichier list_option.php
<?php
function list_option($dept,$name){
for($i=0;$i<count($dept);$i++){
echo "</select>";
?>