gpt4 book ai didi

javascript - HTML + PHP。带 POST 的表单不发送输入类型 = 文本

转载 作者:行者123 更新时间:2023-12-02 14:16:00 26 4
gpt4 key购买 nike

我在使用 POST 方法发送表单参数时遇到问题。我在表格中输入了文本和 radio 。问题是仅使用该帖子发送 radio 类型输入,这意味着我丢失了文本类型输入中的值。

我尝试过使用 $_REQUEST,但没有任何改变。

仅供引用,我仅使用 Materialize 和 jQuery

这是我的 HTML 代码:

    <form id="testingform" name="testingform" method = "POST" action = "controller/create_soal.php">
<?php include "controller/soal_editor.php";?>
<div id="soal_baru"></div>
<div class="row">
<input class="waves-effect waves-light btn col s12" type="button" onClick="newSoal()" value="+ Tambah Soal"/>
</div>
<div class="row">
<input type="submit" value="Publish >>>" class="waves-effect waves-light btn col s12"/>
</div>
</form>

这是上面包含的 PHP 代码:

    $msg = $msg . '<div  class = "card-panel">
<div class = "row">
<div class="input-field col s12">
<input placeholder="Judul" id="judul" type="text" form="testingform" class="active validate" required/>
<label for="judul">Judul</label>
</div>
</div>
<div class = "row">
<div class="input-field col s12" style="color:#d5d5d5;">
Deadline:
</div>
<div class="input-field col s6">
<input placeholder="Deadline" id="deadline" type="datetime-local" required/>
</div>
</div>
<div class = "row">
<div class="input-field col s6">
<p>Ujian ini ditujukan untuk:</p>';
$sql = "SELECT * FROM jabatan WHERE 1;";
$retval = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_array($retval, MYSQLI_ASSOC)) {
$msg = $msg . '<p>
<input id="' . $row['id'] . 'jabatan" type="radio" name="jabatan" value="' . $row['id'] . '"/>
<label for="' . $row['id'] . 'jabatan">' . $row['label'] . '</label>
</p>';
}
$msg = $msg . '</div><div class="input-field col s6"><p>Ujian ini untuk menilai:</p>';
$sql1 = "SELECT * FROM dimensi WHERE 1;";
$retval1 = mysqli_query($conn, $sql1);
while ($row = mysqli_fetch_array($retval1, MYSQLI_ASSOC)) {
$msg = $msg . '<p>
<input id="' . $row['id'] . 'dimensi" type="radio" name="dimensi" value="' . $row['id'] . '"/>
<label for="' . $row['id'] . 'dimensi">' . $row['labeldimensi'] . '</label>
</p>';
}
$msg = $msg . '</div></div></div>';
echo $msg;

最佳答案

您错过了每个文本输入字段的名称标签。所以试试这个:

        $msg = $msg . '<div  class = "card-panel">
<div class = "row">
<div class="input-field col s12">
<input placeholder="Judul" id="judul" name="judul" type="text" form="testingform" class="active validate" required/>
<label for="judul">Judul</label>
</div>
</div>
<div class = "row">
<div class="input-field col s12" style="color:#d5d5d5;">
Deadline:
</div>
<div class="input-field col s6">
<input placeholder="Deadline" id="deadline" name="deadline" type="datetime-local" required/>
</div>
</div>
<div class = "row">
<div class="input-field col s6">
<p>Ujian ini ditujukan untuk:</p>';
$sql = "SELECT * FROM jabatan WHERE 1;";
$retval = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_array($retval, MYSQLI_ASSOC)) {
$msg = $msg . '<p>
<input id="' . $row['id'] . 'jabatan" type="radio" name="jabatan" value="' . $row['id'] . '"/>
<label for="' . $row['id'] . 'jabatan">' . $row['label'] . '</label>
</p>';
}
$msg = $msg . '</div><div class="input-field col s6"><p>Ujian ini untuk menilai:</p>';
$sql1 = "SELECT * FROM dimensi WHERE 1;";
$retval1 = mysqli_query($conn, $sql1);
while ($row = mysqli_fetch_array($retval1, MYSQLI_ASSOC)) {
$msg = $msg . '<p>
<input id="' . $row['id'] . 'dimensi" type="radio" name="dimensi" value="' . $row['id'] . '"/>
<label for="' . $row['id'] . 'dimensi">' . $row['labeldimensi'] . '</label>
</p>';
}
$msg .= '</div></div></div>';
echo $msg;

关于javascript - HTML + PHP。带 POST 的表单不发送输入类型 = 文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39029799/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com