Seven Secrets
Erfahrenes Mitglied
Hallo, ich habe folgendes Script:
Nur leider verstehe ich nicht, warum er nicht in die angegebene Datenbank schreibt!
Code:
/* The main screen. Printed when $state is empty. */
Function Main_Menu () {
echo "Es gibt folgende Möglichkeiten:";
echo "<FORM METHOD=\"POST\" ACTION=\"offers.php\">";
echo "<INPUT CHECKED TYPE=\"radio\" NAME=\"state\" VALUE=\"Listing\"><B>Anzeige der Stellenangebote.<BR>";
echo "<INPUT TYPE=\"radio\" NAME=\"state\" VALUE=\"Create\"><B>Ein neues Angebot eingeben.<P>";
echo "<INPUT TYPE=\"submit\" VALUE=\"Make New\">";
echo "";
};
/* List the offers in the database. */
Function Listing () {
echo "<CENTER><H2>Stellenangebote<P>";
mysql_connect($hosthame,$user,$password);
$result = mysql("care_offers","SELECT uid, desguation, discription FROM care_offers ORDER BY desguation");
echo "<TABLE BORDER = 10 CELLPADDING = 2>";
$total_rows = mysql_numrows($result); $counter = 0;
echo "<TR><TD><B>Bezeichnung<TD><B>Beschreibung";
while($counter < $total_rows):
$uid = mysql_result($result,$counter,"uid"); echo "<TR><TD>\n";
echo "<A HREF=offers.php?uid=$uid=Print_Contact>";
echo mysql_result($result,$counter,"discription");
echo "\n";
echo "<TD>\n";
echo mysql_result($result,$counter,"discription"); echo "<TD>\n";
$counter = $counter + 1;
endwhile;
echo "";
};
/* Save updates to database. Call Print_Contact to list new information for updated contact entry. */
Function Commit_Update ($uid, $desguation, $ddiscription){
mysql_connect($hosthame,$user,$password);
$result = mysql("care_offers","UPDATE care_offers SET desguation = '$desguation',
discription = '$discription' WHERE uid = $uid");
$state = "";
Print_Contact($uid);
};
/* Save new contact information to database. Call Print_Contact to display new contact entry. */
Function Commit_Save ($desguation, $discription) {
mysql_connect($hostname,$user,$password);
$result = mysql("care_offers","INSERT INTO care_offers (desguation, discription) VALUES ('$desguation', '$discription')");
$new_uid = mysql_insert_id();
$state = "";
Print_Offer($new_uid);
};
/* This function displays the contact Information in a form. It is used for both the create and update contact options. */
Function Offers_Form ($state,$uid){
if($state == "Update"){
$state = "Commit_Update";
$result = mysql("care_offers","SELECT * FROM care_offers WHERE uid = $uid");
$last_name = mysql_result($result,0,"desguation");
$first_name = mysql_result($result,0,"discription");
}
else {
$state = "Commit_Save";
}
echo "<CENTER><H2>Angebot eingeben<P>\n";
echo "<FORM METHOD = \"POST\" ACTION=\"offers.php\">\n";
echo " <INPUT TYPE = \"HIDDEN\" NAME = \"uid\" VALUE = \"$uid\">\n";
echo " <INPUT TYPE = \"HIDDEN\" NAME = \"state\" VALUE = \"$state\">\n";
echo " Bezeichnung: <BR><INPUT TYPE = \"TEXT\" NAME=\"desguation\" \n";
echo " VALUE = \"$desguation\" MAXLENGTH = 20><BR>\n";
echo " Beschreibung: <BR><INPUT TYPE = \"TEXT\" NAME=\"discription\"\n";
echo " VALUE = \"$discription\" MAXLENGTH = 750 SIZE = 75><BR>\n";
echo " <CENTER><INPUT TYPE=\"submit\" VALUE=\"Submit Contact\">\n";
echo "\n";
};
/* Print address and comments for a contact. Also give option to update. */
Function Print_Offer ($uid) {
mysql_connect($hosthame,$user,$password);
echo "<TABLE BORDER = 10 CELLPADDING = 2>";
echo "<TR><TD>Sie haben folgende Daten eingetragen:";
echo "<TD>";
$result = mysql("care_offers","SELECT * FROM care_offers WHERE uid = $uid");
echo "<TR><TD>Bezeichnung";
echo "<TD>";
echo mysql_result($result,0,"desguation"); echo "\n";
echo "<TR><TD>Beschreibung";
echo "<TD>";
echo mysql_result($result,0,"discription");
echo "\n";
echo "\n";
echo "";
echo "<FORM METHOD = \"POST\" ACTION=\"offers.php\">";
echo "<INPUT TYPE = \"HIDDEN\" NAME = \"uid\" VALUE = \"$uid\">\n";
echo "<INPUT TYPE = \"HIDDEN\" NAME = \"state\" VALUE = \"Update\">\n";
echo "<CENTER><INPUT TYPE=\"submit\" VALUE=\"Update Contact Information\">";
echo "<FORM METHOD = \"POST\" ACTION=\"offers.php\">";
echo "<CENTER><INPUT TYPE=\"submit\" VALUE=\"Return To Main Menu\">";
echo "\n";
};
/* The main loop. Call functions based on the value of $state, which gets set via a hidden INPUT TYPE. */
switch($state):
case "";
Main_Menu();
break;
case "Listing";
Listing();
break;
case "Create";
Offers_Form($state, $uid);
break;
case "Update";
Contact_Form($state, $uid);
break;
case "Commit_Update";
Commit_Update($uid, $desguation, $ddiscription);
break;
case "Commit_Save";
Commit_Save($desguation, $discription);
break;
case "Print_Offer";
Print_Offer($uid);
endswitch;
?>
Nur leider verstehe ich nicht, warum er nicht in die angegebene Datenbank schreibt!