| 12
 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
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 
 | <?php require_once('../Connections/mysqlConnection.php'); ?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "super";
$MM_donotCheckaccess = "false";
 
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { 
  // For security, start by assuming the visitor is NOT authorized. 
  $isValid = False; 
 
  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. 
  // Therefore, we know that a user is NOT logged in if that Session variable is blank. 
  if (!empty($UserName)) { 
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. 
    // Parse the strings into arrays. 
    $arrUsers = Explode(",", $strUsers); 
    $arrGroups = Explode(",", $strGroups); 
    if (in_array($UserName, $arrUsers)) { 
      $isValid = true; 
    } 
    // Or, you may restrict access to only certain users based on their username. 
    if (in_array($UserGroup, $arrGroups)) { 
      $isValid = true; 
    } 
    if (($strUsers == "") && false) { 
      $isValid = true; 
    } 
  } 
  return $isValid; 
}
 
$MM_restrictGoTo = "index.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {   
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) 
  $MM_referrer .= "?" . $_SERVER['QUERY_STRING'];
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo); 
  exit;
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }
 
  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
 
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
 
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
//ICI////////////////////////////début de mon code adapté
///////////////////////////////////////////////////
//etape1 création de l'étudiant depuis le forumulaire
 
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO eleves (nom, prenom, classe, tel, mail) VALUES (%s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['nom'], "text"),
                       GetSQLValueString($_POST['prenom'], "text"),
                       GetSQLValueString($_POST['classe'], "text"),
                       GetSQLValueString($_POST['tel'], "text"),
                       GetSQLValueString($_POST['mail'], "text"));
 
  mysql_select_db($database_mysqlConnection, $mysqlConnection);
  $Result1 = mysql_query($insertSQL, $mysqlConnection) or die(mysql_error());
 
   //récupération de l'ID de l'étudiant ajouté
   $eleveID = mysql_insert_id(); 
   echo $eleveID;
}
 
//Etape2 lancement de la requete pour trouver les 121 techniques enregistrées dans la database
 
mysql_select_db($database_mysqlConnection, $mysqlConnection);
$query_Recordset1 = "SELECT ID
FROM techniques" ;
$Recordset1 = mysql_query($query_Recordset1, $mysqlConnection) or die(mysql_error());
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
	$eleveID= 555;
	while( $row_Recordset1 = mysql_fetch_assoc($Recordset1)){
	 	 $techniqueID = $row_Recordset1['ID'];	
		echo "ddddd ".$eleveID." ".$techniqueID;
			//Etape3:  insertion du code pour créer les 120 techniques
			$insertSQL2 = sprintf("INSERT INTO evaluations (elevesID, techniquesID, date) VALUES (%s, %s, %s)",
 
 
			 GetSQLValueString($eleveID, "int"), //je récupère l'id de l' étudiant depuis la fonction mysql_insert_id()
             GetSQLValueString($techniqueID, "smallint"),  //de m^me à partir du tabelau mysql_fetch
             'NOW()'
 
			 );
 
 
	}
//création effective des techniques
mysql_select_db($database_mysqlConnection, $mysqlConnection);
  $Result2 = mysql_query($insertSQL2, $mysqlConnection) or die(mysql_error());
 
//redirection
$insertGoTo = "gestionEtudiant.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
 
 
 
//autre////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
mysql_select_db($database_mysqlConnection, $mysqlConnection);
$query_rsMenuClasses = "SELECT DISTINCT classe FROM eleves ORDER BY classe ASC";
$rsMenuClasses = mysql_query($query_rsMenuClasses, $mysqlConnection) or die(mysql_error());
$row_rsMenuClasses = mysql_fetch_assoc($rsMenuClasses);
$totalRows_rsMenuClasses = mysql_num_rows($rsMenuClasses);
 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Ajouter un étudiant</title>
<link href="styleAdmin.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="styleMenuHorizontal_6.css" />
 
 
<link href="style1.css" rel="stylesheet" type="text/css" media="all" />
</head>
 
<body>
<div id="conteneur">
  <div id="entete"><img src="../images/ban2.jpg" alt="logo Guitares Electriques" width="750" height="150" /></div>
  	<div id="navbar">
   	<div id="menu">
   		<ul>
			<li><a href="gestionEtudiant.php">Gestion des étudiants</a></li>
			<li><a id="ok" href="#">Gestion des évals</a></li>
				<ul id="sousmenu">
					<li><a href="evalGestionEtudiant.php">Par étudiant</a></li>
					<li><a href="evalGestionAtelier.php">Par étudiant et atelier</a></li>
					<li><a href="evalGestionDate.php">Par étudiant et date</a></li>
					<li><a href="evalGestionTechnique.php">Par étudiant et tech</a></li>
					<li><a href="evalLast.php">Les 3 dernières</a></li>
				</ul>	
			<li><a href="../index.php">Voir le site</a></li>
			<li><a href="#">Déconnexion</a></li>
		</ul>
	</div><!--fin menu-->
   </div><!--fin navbar-->
  <div id="contenu">
    <h1>Ajouter un étudiant</h1>
    <p>Modifier la classe celle affichée est une valeur par défaut.</p>
    <p><a href="gestionEtudiant.php">Retour</a></p>
    <form action="<?php echo $editFormAction; ?>" name="form1" id="form1" method="POST">
      <table width="268" border="0">
        <tr>
          <th width="98" class="marronTableau" scope="row">Nom</th>
          <td width="154" class="jauneTableau"><input type="text" name="nom" id="nom" /></td>
        </tr>
        <tr>
          <th class="marronTableau" scope="row">Prénom</th>
          <td class="jauneTableau"><input type="text" name="prenom" id="prenom" /></td>
        </tr>
        <tr>
          <th class="marronTableau" scope="row">Classe</th>
          <td class="jauneTableau"><select name="classe" id="classe">
            <?php
do {  
?>
            <option value="<?php echo $row_rsMenuClasses['classe']?>"><?php echo $row_rsMenuClasses['classe']?></option>
            <?php
} while ($row_rsMenuClasses = mysql_fetch_assoc($rsMenuClasses));
  $rows = mysql_num_rows($rsMenuClasses);
  if($rows > 0) {
      mysql_data_seek($rsMenuClasses, 0);
	  $row_rsMenuClasses = mysql_fetch_assoc($rsMenuClasses);
  }
?>
          </select></td>
        </tr>
        <tr>
          <th class="marronTableau" scope="row">Téléphone</th>
          <td class="jauneTableau"><input type="text" name="tel" id="tel" /></td>
        </tr>
        <tr>
          <th class="marronTableau" scope="row">Mail</th>
          <td class="jauneTableau"><input type="text" name="mail" id="mail" /></td>
        </tr>
        <tr>
          <th class="marronTableau" scope="row">Fichier photo</th>
          <td class="jauneTableau"> </td>
        </tr>
        <tr>
          <th scope="row"> </th>
          <td><input type="submit" name="button" id="button" value="Valider " />
          <input type="reset" name="Reset" id="Reset" value="Effacer" /></td>
        </tr>
      </table>
      <input type="hidden" name="MM_insert" value="form1" />
    </form>
    <p> </p>
    <p> </p>
  </div>
  <div id="pied"></div>
</div>
<!--insert de ma bibliothèque jquery-->
<script src="jquery-1.9.1.js"></script>
<!--code js jquery -->
<script>
$(document).ready(function(){
	$("#ok").click(function(){
		$("#sousmenu").toggle();
		});
});	
</script>
</body>
</html>
<?php
mysql_free_result($rsMenuClasses);
?> | 
Partager