问题在于,当我点击提交时,我没有调用php文件并将其重定向到另一个html页面,在firefox中,当我选择三个复选框时,它会重定向到该html页面,同样在chrome上。 我试图使用无线电而不是复选框,但它有同样的问题。 如果我使用输入文本而不是复选框它的工作原理! 同一个人可以帮助我吗?!?!?
这是表格:
<form action="editOpenedDays.php" method="post">
<input type="checkbox" name="lunedi" value="lun"/>Lunedì<br>
<input type="checkbox" name="martedi" value="mar"/>Martedì<br>
<input type="checkbox" name="mercoledi" value="mer"/>Mercoledì<br>
<input type="checkbox" name="giovedi" value="gio"/>Giovedì<br>
<input type="checkbox" name="venerdi" value="ven"/>Venerdì<br>
<input type="checkbox" name="sabato" value="sab"/>Sabato<br>
<input type="checkbox" name="domenica" value="dom"/>Domenica<br><br>
<input type="submit" name="submit" value="Inserisci/Modifica">
</form>
<?php
include 'connect.php';
$ID = $_SESSION['userId'];
$days['lunedi'] = isset($_POST["lunedi"]) ? $_POST["lunedi"] : "";
$days['martedi'] = isset($_POST["martedi"]) ? $_POST["martedi"] : "";
$days['mercoledi'] = isset($_POST["mercoledi"]) ? $_POST["mercoledi"] : "";
$days['giovedi'] = $isset($_POST["giovedi"]) ? $_POST["giovedi"] : "";
$days['venerdi'] = isset($_POST["venerdi"]) ? $_POST["venerdi"] : "";
$days['sabato'] = isset($_POST["sabato"]) ? $_POST["sabato"] : "";
$days['domenica'] = isset($_POST["domenica"]) ? $_POST["domenica"] : "";
$formattedDays = null;
foreach ($days as $day){
}
if ($days != null){
$stmt=$conn->prepare();
$stmt->bind_param("s", $formattedDays);
$stmt->execute();
header("Location: informazioni.php");
}
else{
echo "Non sono state inseriti giorni di apertura";
}
PS:对不起我的英文
答案 0 :(得分:1)
$isset($_POST["giovedi"])
尝试删除&#39; $&#39;在isset()上。 ;)
顺便说一下,你可以替换它:
$days['lunedi'] = isset($_POST["lunedi"]) ? $_POST["lunedi"] : "";
$days['martedi'] = isset($_POST["martedi"]) ? $_POST["martedi"] : "";
$days['mercoledi'] = isset($_POST["mercoledi"]) ? $_POST["mercoledi"] : "";
$days['giovedi'] = isset($_POST["giovedi"]) ? $_POST["giovedi"] : "";
$days['venerdi'] = isset($_POST["venerdi"]) ? $_POST["venerdi"] : "";
$days['sabato'] = isset($_POST["sabato"]) ? $_POST["sabato"] : "";
$days['domenica'] = isset($_POST["domenica"]) ? $_POST["domenica"] : "";
由此:
$dayTab = array('lunedi', 'martedi', 'mercoledi', 'giovedi', 'venerdi', 'sabato', 'domenica');
foreach($dayTab as $day) {
$days[$day] = $_POST[$day] ?: '';
}