ChiliSchaf
Neues Mitglied
Hallo allerseits - ich hoffe ich bin im html-teil des Forums richtig...
es geht um diesen Quellcodeausschnitt:
Ich möchte in dieser Datei (module01_index.php) Daten speichern, die eingegeben werden. Dazu gebe ich dem User 3 Buttons, einmal speichern und weitere Daten hinzufügen und dann noch speichern und zurück und einfach zurück. Problem ist das "zurück" und das "speichern und zurück". Ich möchte, dass beim klick auf den jeweiligen Button, gespeichert wird und dann zurück in die main_index.php gesprungen wird. Blöderweise funktioniert das nicht. Es wird zwar gespeichert, aber ich weiß nicht, wie ich mit einem submit-button und ohne javascript kommen kann...
Hat jemand eine Idee wie ich die letzten beiden Buttons so ändern kann (oder die funktion die auf das "save" reagiert), so dass wieder in die main_index gesprungen wird?
Hier noch die main_index.php falls benötigt:
es geht um diesen Quellcodeausschnitt:
PHP:
<?
function data_add(){
$database = new Database();
?>
<form action="" method="post">
<table width="100%" height="50" border="0">
<td>
<h2>Add Data:</h2>
</td>
<tr>
<td>
<input name="type" type="text"><br>
</td>
</tr>
</table>
<table width="100%" height="225" border="0">
<td valign="bottom" >
<input name="saveAndAdd" type="submit" value="save and add next">
<input name="save" type="submit" value="save and exit">
<input name="backToMenu" type="submit" value="exit without saving">
</td>
</table>
</form>
<?php
if(isset($_POST["saveAndAdd"])){
$type = $_POST["type"];
$types = $database->loadAllTypes();
//Checks if the new type exists already
$save = true;
for($i = 0; $i < count($types); $i++){
if($type == $types[$i]){
echo "This name exists already. Please chose
another name!";
$save = false;
break;
}
}
if ($save) {
$database->saveType($type);
echo "type ".$type." was saved successfully.";
}
}else if(isset($_POST["save"])){
$type = $_POST["type"];
$types = $database->loadAllTypes();
//Checks if the new type exists already
$save = true;
for($i = 0; $i < count($types); $i++){
if($type == $types[$i]){
echo "This name exists already. Please chose
another name!";
$save = false;
break;
}
}
if ($save) {
$database->saveType($type);
echo "type ".$type." was saved successfully.";
}
}
}
Hat jemand eine Idee wie ich die letzten beiden Buttons so ändern kann (oder die funktion die auf das "save" reagiert), so dass wieder in die main_index gesprungen wird?
Hier noch die main_index.php falls benötigt:
PHP:
(...)
/**
* Header and Footer
*/
function printHeader(){
include("templates/header.tpl");
}
function printFooter(){
include("templates/footer.tpl");
}
/**
* every action for each modul is startet in here
* @return -
*/
function moduleActions() {
if (!isset($_GET["param"])) {
echo "param is not set";
}else if ($_GET["param"] == "add") {
$modulname = $_GET["loadedModule"];
$function = $modulname._add;
$function();
}
}
printHeader();
moduleActions();
printFooter();