Bon, le même remis un peu droit, tu t'y retrouveras peut-être plus facilement, j'ai optimisé pas mal de if/else, ça réduit la quantitéde code.
Je me demande si le problème ne vient pas de ce que tu as trois boutons submit
<?php
session_start();
$index = (isset($_SESSION['index'])) ? $_SESSION['index'] : "";
$testKor = (isset($_SESSION['testKor'])) ? $_SESSION['testKor'] : 0;
?>
<!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=windows-1250" />
<meta name="generator" content="PSPad editor, www.pspad.com" />
<meta name="Author" content=" Authorsnames YC MP" />
<link rel="stylesheet" type="text/css" href="Ausbau_style.css" />
<title>Prakt_S2 Formular</title>
</head>
<body>
<!--
HTML_KODE fuer Titel des Fensters
NB Die ganze Fenster Fonktionniert nur mit Ausbau_style.css
-->
<div id="textFeld">
<div id="ImaTitre">
<img id="athena" src="image/athene_G.gif" alt="Athene" /><br />
<p>
<br />
<br />
<br />
<br />
</p>
<h1 id="ex1">FORMULAR EINTRAG der WERTE </h1><br />
<br />
</div>
<!--
***********************************************
HTML_KODE Links fuer andere Fenster
***********************************************
-->
<a class="linx" href="Prakt_S1.php">Home</a><br />
<a class="linx" href="Prakt_S3.php">Tabelle</a><br />
<br />
</tr>
<?php
/*-------------------------------------------------*/
/* Variablen decl??????
/*-------------------------------------------------*/
$chTemp_5 = (isset($ligne['MatStatus'])) ? $ligne['MatStatus'] : "";
$chTemp_7 = (isset($ligne['dateiFormat'])) ? $ligne['dateiFormat'] : "";
/*-------------------------------------------------*/
/* Nouveau Texte Kor && Del
/*-------------------------------------------------*/
$indeX = (isset($_POST["q5"])) ? $_POST["q5"] : "";
$_SESSION['index'] = "$indeX";
if (isset($_POST["q5"]) && isset($_POST["btn_KOR"] ))
{
echo " T'a presser Korrige et donne ";
echo $indeX;
echo "<br />";
echo "<br />";
echo "Ici au debut de KOR testKor est egal a zero";
echo $testKor;
echo "<br />";
include "dbConnect.php";
$mysql_result = mysql_query("SELECT `lehrveran` ,`titel` ,`autor`,`thema`, `matType`, `MatStatus`, `dateiFormat`, `url`
FROM `".$table."` WHERE `index`='". $indeX ."' ");
while ($ligne = mysql_fetch_array($mysql_result))
{
$chTemp_1 = (isset($ligne['titel'])) ? $ligne['titel'] : "";
$chTemp_2 = (isset($ligne['autor'])) ? $ligne['autor'] : "";
$chTemp_3 = (isset($ligne['thema'])) ? $ligne['thema'] : "";
$chTemp_4 = (isset($ligne['lehrveran'])) ? $ligne['lehrveran'] : "";
$chTemp_5 = (isset($ligne['MatStatus'])) ? $ligne['MatStatus'] : "";
$chTemp_6 = (isset($ligne['matType'])) ? $ligne['matType'] : "";
echo "<br />";
echo "Ici chTemp_5 contient ";
echo $chTemp_5;
$chTemp_7 = (isset($ligne['dateiFormat'])) ? $ligne['dateiFormat'] : "";
echo "<br />";
echo "Ici chTemp_7 contient ";
echo $chTemp_7;
$chTemp_8 = (isset($ligne['url'])) ? $ligne['url'] : "";
echo "<br />";
echo "<br />";
$testKor = "1";
$_SESSION['testKor'] = $testKor;
echo "Ici a la fin de Var de session testKor devrait etre egal a 1 ";
echo $testKor;
echo "<br />";
}
}
elseif (isset($_POST["q5"]) && isset($_POST["btn_DEL"] ))
{
echo " T'a presser Delete et donne ";
echo $indeX;
include "dbConnect.php";
$request = "DELETE FROM `". $table ."` WHERE `index`=". $indeX ." LIMIT 1";
$requestA ="ALTER TABLE `". $table ."` DROP COLUMN `index`";
$requestB ="ALTER TABLE `". $table ."` ADD `index` INT UNSIGNED NOT NULL AUTO_INCREMENT , ADD INDEX (`index`)";
mysql_query($request) or exit(mysql_error());
mysql_query($requestA) or exit(mysql_error());
mysql_query($requestB) or exit(mysql_error());
mysql_close($dbcon);
echo " Der Eintrag ist gelöscht.";
echo $indeX ;
}
?>
<pre>
<?php
var_dump($_POST);
?>
</pre>
<?php
///////////////////////////////////////////////
//
// Test pour sauvegarde
//
/////////////////////////////////////////////
$Lehrveran = (isset($_POST["LVA"])) ? $_POST["LVA"] : "";
$testLehrveran = (isset($_POST["LVA"])) ? 1 : 0;
/////////////////////////////////////////////////////////////
echo "<br />";
echo " La valeur initiale de testLehrveran= ".$testLehrveran;
echo "<br />";
/////////////////////////////////////////////////////////////
$Titel = (isset($_POST["titel"])) ? $_POST["titel"] : "";
$testtitel = (isset($_POST["titel"])) ? 1 : 0;
/////////////////////////////////////////////////////////////
echo "<br />";
echo " La valeur initiale de testtitel= ".$testtitel;
echo "<br />";
/////////////////////////////////////////////////////////////
$autor = (isset($_POST["autor"])) ? $_POST["autor"] : "";
$testautor= (isset($_POST["autor"])) ? 1 : 0;
/////////////////////////////////////////////////////////////
echo "<br />";
echo " La valeur initiale de testautor= ".$testautor;
echo "<br />";
/////////////////////////////////////////////////////////////
$Thema = (isset($_POST["thema"])) ? $_POST["thema"] : "";
$testthema = (isset($_POST["thema"])) ? 1 : 0;
/////////////////////////////////////////////////////////////
echo "<br />";
echo " La valeur initiale de testthema= ".$testthema;
echo "<br />";
/////////////////////////////////////////////////////////////
$matType = (isset($_POST["MaterialsTyp"])) ? $_POST["MaterialsTyp"] : "";
$testmatType = (isset($_POST["MaterialsTyp"])) ? 1 : 0;
/////////////////////////////////////////////////////////////
echo "<br />";
echo " La valeur initiale de testmatType= ".$testmatType;
echo "<br />";
/////////////////////////////////////////////////////////////
$conVar = (isset($_POST["mein_C_Box"])) ? substr($concaVar, 1,$lengthStr) : "";
$testconVar = (isset($_POST["mein_C_Box"])) ? 1 : 0;
/////////////////////////////////////////////////////////////
echo "<br />";
echo " La valeur initiale de testconVar= ".$testconVar;
echo "<br />";
echo " La valeur initiale de conVar= ".$conVar;
echo "<br />";
/////////////////////////////////////////////////////////////
$matStat = (isset($_POST["mein_Feld"])) ? $_POST["mein_Feld"] : "";
$testmatStat = (isset($_POST["mein_Feld"])) ? 1 : 0;
/////////////////////////////////////////////////////////////
echo "<br />";
echo " La valeur initiale de testmatStat= ".$testmatStat;
echo "<br />";
echo " La valeur initiale de matStat= ".$matStat;
echo "<br />";
/////////////////////////////////////////////////////////////
$Url = (isset($_POST["url"])) ? $_POST["url"] : "";
$testUrl = (isset($_POST["url"])) ? 1 : 0;
/////////////////////////////////////////////////////////////
echo "<br />";
echo " La valeur initiale de testUrl= ".$testUrl;
echo "<br />";
/////////////////////////////////////////////////////////////
$addtest = $testLehrveran + $testtitel + $testautor + $testthema + $testmatType + $testconVar + $testmatStat + $testUrl;
echo " Valeur de addTset = ".$addtest;
echo "<br />";
if ((isset($_POST["btn_Speich"] )) && ($testKor == 1) && ($addtest == 8))
{
echo "Ici au debut de Speichern&&nachKor testKor doit etre a un Valeur= ";
echo $testKor;
echo "<br />";
include "dbConnect.php";
echo "contenu de addTest en haut de UPDATE ";
echo $addTest;
echo "<br />";
$Titel = (isset($_POST["titel"])) ? $_POST["titel"] : "";
$autor = (isset($_POST["autor"])) ? $_POST["autor"] : "";
$Thema = (isset($_POST["thema"])) ? $_POST["thema"] : "";
$Lehrveran = (isset($_POST["LVA"])) ? $_POST["LVA"] : "";
$matStat = (isset($_POST["mein_Feld"])) ? $_POST["mein_Feld"] : "";
echo $matStat;
$matType = (isset($_POST["MaterialsTyp"])) ? $_POST["MaterialsTyp"] : "";
$conVar = (isset($_POST["mein_C_Box"])) ? substr($concaVar, 0,$lengthStr) : "";
echo "<br />";
echo " La valeur de concaVar avant control est = ".$concaVar;
echo "<br />";
$Url = (isset($_POST["url"])) ? $_POST["url"] : "";
$dixAddTest = 0;
$testKor = 0;
$_SESSION['testKor'] = "$testKor";
echo "<br />";
echo "Ici dans Kor testKor doit etre remis a zero ";
echo $testKor;
echo "<br />";
echo "<br />";
$reqUpdate ="UPDATE `". $table ."`
SET `lehrveran` = '". $Lehrveran ."',
`titel` = '". $Titel ."',
`autor` = '". $autor ."',
`thema` = '". $Thema ."',
`matType` = '". $matType ."' ,
`MatStatus` = '". $matStat ."',
`dateiFormat` = '". $conVar ."',
`url` = '". $Url ."'
WHERE `index` = ". $index;
mysql_query($reqUpdate) or exit(mysql_error());
mysql_close($dbcon);
echo " Die Replace wurde geschickt";
echo $testKor;
}
?>
<form method="post" action="./Prakt_S2.php">
<!--
*************************************************
HTML_KODE fuer das Formular
Anfang mit TextFelder fuer den Titel
**************************************************
-->
<div class = "hell">
<h3>Hier ist der Titel zu erfassen</h3>
<textarea rows="2" cols="20" name="titel">
<?php
if (($testKor = 1)&&(isset($chTemp_1))){echo $chTemp_1;}
?>
</textarea>
</div>
<!--
HTML_KODE fuer das Formular
Hier 3 Pulldown menus mit die Moeglichkeit eine neue Eintrag durch ein untere
Formular zu machen.
Das Ergebnis der unteren Formularen werden in 3 anderen Tabelle gespeichert und
wieder im Pdown gebracht. Hier st die erste mischung zwischen PHP und HTML
Das Ganze ist durch eine Table organisert, um eine so schoen wie moeglich
Darstellung zu haben.
-->
<div class = "leer">
<h3>Hier sind die Autor, Thema, und Lehrveranstaltung zu erfassen</h3>
<!--
Titel
-->
<table class="large" border="1" >
<tr>
<td class="a1" >Autor :</td>
<td class="a1" >Thema :</td>
<td class="a1" >Lehrveranstaltung :</td>
</tr>
<tr>
<td>
<!--
Der Pulldown menu fuer Autorseingabe ist hier zu finden.
Die anderen Pulldown menu Theme, LVA, und Mat. Type folgen genau dieses Muster.
Deswegen wird diese Kommentar nicht wiederholt.
Dies Block Braucht die PHPDatei dbContabAutor.php, um seine Aufgabe zu machen.
D.h. Die Autorsname im Textfeld des pulldown menu mitzubringen.
Inhalt von dbContabAutor.php
Es ist klar dass, normaleweise diese Informationen, auf Sicherheit Grund, hier
nicht zu geben sind.
$host = "localhost"; //Var. Serversname
$user = "MP"; //Var. Username
$pass = "rapass"; //Var. Password
$name = "neuedbase"; //Var. DBasesname
$table = "tabautor"; //Var. Tabellesname
$dbcon =@mysql_connect($host, $user, $pass) or exit(mysql_error());
@mysql_select_db($name) or exit(mysql_error());
// Die erste Befehl macht eine Verbindung mit der DBank
// Die zweite selektiert die Tabelle
// Beine sind eine mischng zwischen PHP und mySQL
// Die whileschleife nimmt jede erste Eintrag der Tabelle
// und schreibt es im option TAG von HTML, der macht danach die Darstellung.
-->
<select name="autor">
<option>
<?php
if (($testKor == 1)&&(isset($chTemp_2))){echo $chTemp_2;}
?>
</option>
<?php
include "dbContabAutor.php";
$mysql_result = mysql_query("SELECT * FROM $table;") ;
//prendre chaque rangée
// afficher rubrique
while ($ligne = mysql_fetch_array($mysql_result))
{
?>
<option><?print($ligne["autorID"]); ?>
</option>
<?php
}
?>
</select>
</td>
<!--
Pulldown menu fuer Thema
Siehe oben Komentar fuer Pulldown menu von Autor
-->
<td>
<select name="thema">
<option>
<?php
if (($testKor == 1)&&(isset($chTemp_3))){echo $chTemp_3;}
?>
</option>
<?php
include "dbContabThema.php";
$mysql_result = mysql_query("SELECT * FROM $table;");
while ($ligne = mysql_fetch_array($mysql_result))
{
?>
<option>
<?php print($ligne["thema_ID"]); ?>
</option>
<?php
}
?>
</select>
</td>
<!--
Pulldown menu fuer Lehrveranstaltung
Siehe oben Komentar fuer Pulldown menu von Autor
-->
<td>
<?php
//echo "<br />";
//echo " Contenu de lva= ".$chTemp_4;
//echo "<br />";
?>
<select name="LVA">
<option>
<?php
if (($testKor == 1)&&(isset($chTemp_4))){echo $chTemp_4;}
?>
</option>
<?php
include "dbContabLVA.php";
$mysql_result = mysql_query("SELECT * FROM $table;") ;
while ($ligne = mysql_fetch_array($mysql_result))
{
?>
<option>
<?php
print($ligne["lva_ID"]);
?>
</option>
<?php
}
?>
</select>
</td>
</tr>
<!--
Links fuer untere Formularen Autor, Thema, LVAsliste
-->
<tr>
<td><a href="Form_Autor.php">Form_neue Autor</a> und Autorsliste</td>
<td><a href="Form_Thema.php">Form_neue Thema</a> und Themasliste</td>
<td><a href="Form_LVA.php">Form_neue LVA</a> und LVAsliste</td>
</tr>
</table>
</div>
<!--
Formular radio button fuer Status des materiales
-->
<?php echo $chTemp_5; ?>
<div class = "hell">
<h3>Status des Materiales</h3>
<input type="radio" name="mein_Feld" value="z" <?php if(isset($chTemp_5) && $chTemp_5=="z") {print "checked=\"checked\"";} ?> />Option 1 : officiell freigegeben<br />
<input type="radio" name="mein_Feld" value="y" <?php if(isset($chTemp_5) && $chTemp_5=="y") {print "checked=\"checked\"";} ?> />Option 2 : inoffiziell<br />
<input type="radio" name="mein_Feld" value="x" <?php if(isset($chTemp_5) && $chTemp_5=="x") {print "checked=\"checked\"";} ?> />Option 3 : Unklar<br />
</div>
<!--
Pulldown menu fuer MaterialesTyp
Siehe oben Komentar fuer Pulldown menu von Autor
-->
<div class = "leer">
<h3>Hier ist das typ des Materiales zu erfassen</h3>
<select name="MaterialsTyp">
<option>
<?php
if (($testKor = 1)&&(isset($chTemp_6))){echo $chTemp_6;}
?>
</option>
<option>Aufgabe</option>
<option>Klausur</option>
<option>Übung</option>
<option>Lösung</option>
<option>Ressourse</option>
</select>
</div>
<div class = "hell">
<h3>Hier soll man das Format des Lehrmaterial geben</h3><br />
<!--
Formular check box fuer die Eingabe des DateiFormats
Hier wird auch eine table benutzt, um den Layout zu organisieren.
Das CheckboxsErgebnis ist ein string. Er wurde zusammen mit der
Ergebnissen des CB_Block gefasst.
Jede CB_Ergebnis ist miteinander konkateniert durch die foreach
Schleife. Diese Methode wurde gewahlt, weil Das Dateiformat fuer
die DatenB. ein SET ist. D. h., man muss ein String der Form a,b,c,d,e,f
liefern. Die Logische Entscheidung wuerde nicht diese Methode empfehlen,
wegen die zusatzliche Arbeit, um diese String zu interpretieren.
Wenn man z. b. Das Ergebnis von dem CB am Bildschirm zeigen will
-->
<table class="large" border="1">
<tr>
<th class="a" colspan="3" >Man kann hier bis sechs DateiFormat wählen</th>
</tr>
<tr class="a">
<td >
<?php $checked = strstr($chTemp_7, "a") ? " checked=\"checked\"" : null; ?>
<input type="checkbox" name="mein_C_Box[]" value="a"<?php echo($checked); ?>
/><b>: L<sup>A</sup>T<sub>E</sub>X</b>
</td>
<td>
<?php $checked = strstr($chTemp_7, "b") ? " checked=\"checked\"" : null; ?>
<input type="checkbox" name="mein_C_Box[]" value="b"<?php echo($checked); ?>
/><b>: HTML</b>
</td>
<td >
<?php $checked = strstr($chTemp_7, "c") ? " checked=\"checked\"" : null; ?>
<input type="checkbox" name="mein_C_Box[]" value="c"<?php echo($checked); ?>
/><b>: PDF</b>
</td>
</tr>
<tr class="a">
<td >
<?php $checked = strstr($chTemp_7, "d") ? " checked=\"checked\"" : null; ?>
<input type="checkbox" name="mein_C_Box[]" value="d"<?php echo($checked); ?>
/><b>: PNG</b>
</td>
<td>
<?php $checked = strstr($chTemp_7, "e") ? " checked=\"checked\"" : null; ?>
<input type="checkbox" name="mein_C_Box[]" value="e"<?php echo($checked); ?>
/><b>: URL</b>
</td>
<td>
<?php $checked = strstr($chTemp_7, "f") ? " checked=\"checked\"" : null; ?>
<input type="checkbox" name="mein_C_Box[]" value="f"<?php echo($checked); ?>
/><b>: JAVA</b>
</td>
</tr>
</table>
</div>
<?php
$lengthStr="";
$concaVar = "";
$varComa =",";
if (!isset($_POST["mein_C_Box"]))
$_value = "";
else
{
foreach($_POST["mein_C_Box"] as $_value)
{
switch ($_value)
{
case "a" :
$concaVar .= $varComa . $_value;
break;
case "b" :
$concaVar .= $varComa . $_value;
break;
case "c" :
$concaVar .= $varComa . $_value;
break;
case "d" :
$concaVar .= $varComa . $_value;
break;
case "e" :
$concaVar .= $varComa . $_value;
break;
case "f" :
$concaVar .= $varComa . $_value;
break;
default :
$_val = "Fehl. Dat. ";
}
$lengthStr = strlen ($concaVar);
$lengthStr = $lengthStr - 1;
$conVar = substr($concaVar, 1,$lengthStr);
}
}
?>
<!--
TextFelder fuer Anbage der UrlAdresse
-->
<div class = "leer">
<h3>Hier ist das Uniforme Ressourse Locator URL zu geben</h3>
<textarea rows="2" cols="20" name="url" >
<?php
if (($testKor = 1)&&(isset($chTemp_1))){echo $chTemp_8;}
?>
</textarea>
<p>
<br />
</p>
<div class = "bemerk" >
<table>
<tr>
<td>Eintrag zu korrigieren<br /> oder löschen: </td>
<td><input type="text" size="3" name="q5" /> <input type="submit" name="btn_KOR" value="KOR" /> <input type="submit" name="btn_DEL" value="DEL " /> </td>
</tr>
<tr> <br /></tr>
</table>
</div>
</div>
<div class = "hell">
<fieldset>
<legend>
<b> Werte zu schicken </b>
<input type="submit" name="btn_Speich" value="Speichern" /> <br />
</legend>
<!--
Es gibt hier drei Art aus Test
Erste fall
if (isset($_POST["LVA"]))
{$Lehrveran = $_POST["LVA"]; }
else
{$Lehrveran = "";}
Es ist nur benutzt, um störende Fehlermeldung nicht zu haben
Zweite und dritte fall sind benutzt, um zu sichern daß alle
Variablen gesetzt sind.
Wenn ja, Werte schicken
Wenn nein, Werte nicht schicken
Der Inhalt selbst wird nicht geprüft
if ($etwas == "")
{$testetwas =0;}
else
{$testetwas =1;}
if (isset($_POST["titel"]))
{$Titel = $_POST["titel"];$testtitel= 1;}
else
{$Titel = ""; $testtitel= 0;}
Gleiche Prinzip, aber man kann direkt die Var. benutzen
Ein letzte Test sorgt fuer die Ausdruck von Eingabe,
wenn alle Daten dabei sind.
Nur $addTest == 8 ist druckt den Text, sonst nichts
-->
<!--
Dies switchCase ist benutzt um das Ergebnis von radio Button zu interpretieren
und am Bldschirm zu darstellen. Hier auch diese Methode wurde gewahlt wegen
das DateisFormat ENUM der DatenBank.
-->
<br />
<?php
switch ($matStat)
{
case "z" :
$matS = "freigegeben";
break;
case "y" :
$matS = "inoffiziell";
break;
case "x" :
$matS = "Unklar";
break;
default :
$matS = "Fehl. Dat.";
}
echo $matS;
echo "Das Status des Materiales ist: ".$matS ;
?>
<br />
<?php
echo "Das Format des Materiales ist: ";
$concaVar = $conVar;
$start = 0;
$end = strlen ($concaVar);
while ($start < $end) {
$letter = $concaVar{$start};
switch ($letter)
{
case "a" :
echo " L<sup>A</sup>T<sub>E</sub>X ";
break;
case "b" :
echo "HTML ";
break;
case "c" :
echo "PDF ";
break;
case "d" :
echo "PNG ";
break;
case "e" :
echo "URL ";
break;
case "f" :
echo "JAVA ";
break;
default :
$_val = "Fehl. Dat. ";
}
$start = $start + 2;
}
?>
<br />
<?php
echo "Die URL-Adresse ist:".$Url ;
?>
<br />
<br />
</fieldset>
</div>
</form>
</div> <!--Ende Z_FassungsSeite-->
</body>
</html>