我正在为我的网络应用构建审核系统。我是一个完整的初学者,所以我使用重定向而不是ajax。涉及两个页面,post_review页面和process_review页面。
以下是post_review
页面的代码:
<?php require_once("../includes/database.php");
session_start();
?>
<?php
//mysql_
$connection = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
if(mysqli_connect_errno())
{
die("Database connection failed: " .
mysqli_connect_error() .
" (" . mysqli_connect_errno() . ")");
}
$result = "";
if(isset($_GET['id']))
{
$id = (int)$_GET['id'];
$_SESSION['institute_id'] = $id;
$query = "SELECT * FROM institutes WHERE institute_id = {$id}";
$result = mysqli_query($connection, $query);
$row = mysqli_fetch_assoc($result);
//echo $row;
$id = $row["institute_id"];
$name = $row["name"];
$tagline = $row["tagline"];
$city = $row["city"];
$state = $row["state"];
}
?>
<form name="review_form" method="post" action="process_review.php">
<textarea name="review" required="required" cols="60" rows="7" placeholder="Write a review..."></textarea>
<input type="submit" class="btn btn-custom btn-lg " value="Submit" name="submit_review">
</form>
process_review.php
<?php
require_once("../includes/database.php");
session_start();
$connection = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
if(mysqli_connect_errno())
{
die("Database connection failed: " .
mysqli_connect_error() .
" (" . mysqli_connect_errno() . ")");
}
if(isset($_POST['submit_review']))
{
$review = mysqli_real_escape_string($connection, $_POST['review']);
$student_id = $_SESSION['student_id'];
$institute_id = $_SESSION['institute_id'];
echo $institute_id;
echo $student_id;
$review_query = "INSERT INTO reviews
(content, student_id, institute_id)
VALUES ($review, $student_id, $institute_id)";
$result = mysqli_query($connection, $review_query);
if(!$result){
die("Database query failed.". mysqli_error($connection));
}else{
header('Location: institute_profile_test.php?id=' . $institute_id);
}
}
?>
用户登录时已设置 $_SESSION['student_id']
。
我面临的问题是当我点击提交时,我会被重定向到process_review.php
,我发现此错误消息:
PS:我知道这可能是一个微不足道的问题,但我的项目将在4个小时后完成,我很绝望。解析错误:语法错误,第22行的D:\ xampp \ htdocs \ edhoc \ public \ process_review.php中的意外“{”