我已经使用 GET 将一个变量传递给了一个新页面,并希望将该值插入到我的数据库的表中,但是它表示未定义的变量 $ exex 。我试图在“提交”中回应它。如果声明,但也没有在那里看到。它只回显isset GET if语句中的变量。
以下是代码:
<?php
session_start();
include "includes/connec.inc.php";
if (isset($_GET['exid'])){
$exex=$_GET['exid'];
}
$sql = "SELECT id FROM eaouser WHERE email = '" . $_SESSION['email'] . "'";
$result = mysqli_query($conn,$sql);
$row = mysqli_fetch_array($result);
$eaofid=$row['id'];
if (isset($_POST['submit'])){
if (isset($_POST['feedbacks'])){
$feedback = $_POST['feedbacks'];
if (!empty($feedback)){
$INSERT = "INSERT Into feedback (exfid,eaofid,comment) values(?,?,?)";
$stmt = $conn->prepare($INSERT);
$stmt->bind_param("iis", $exex, $eaofid, $feedback);
$stmt->execute();
if ($stmt==TRUE){
echo "<script> alert('Feedback sent!');
window.location='feedback.php'
</script>";
}else{
echo "<script> alert('Error sending feedback!');
window.location='feedback.php'
</script>";
}
}else{
echo "<script> alert('Feedback form is empty!');
window.location='feedback.php'
</script>";
}
}
}
HTML:
<div class="panel-body">
<form method="POST" action="feedback.php">
<div class="form-group">
<label for="message-text" class="col-form-label">Comment on the experiment:</label>
<textarea class="form-control" name="feedbacks" cols="142" rows="5" placeholder="Type here..."></textarea>
<br>
<button type="submit" name="submit" class="btn" style="background-color: purple;color: white">Send feedback</button>
</div>
</form>
</div>