我一直在开发一个有两个表的网站,user table
和content table
。通过注册表单将新用户插入用户表中没有问题。但是,当submit
content
我的is not being inserted into the database
值通过信息表格users table
时。我所做的就是复制我用于将新用户插入<?php
include_once "header.inc.php";
//set initial variables
$showform = 1; // show form is true
$errormsg = 0;
$errormovie = "";
$errorreview = "";
if($_SERVER["REQUEST_METHOD"] == "POST")
{
//create variables to store data from form - we never use POST directly w/
//user input
/* ****** NEW - CHANGED USERNAME TO LOWERCASE ****** */
$formdata['movie'] = trim($_POST['movie']);
$formdata['review'] = trim($_POST['review']);
//check for empty fields
if (empty($formdata['movie'])) {
$errorcat = "The movie title is required.";
$errormsg = 1;
}
if (empty($formdata['review'])) {
$errorcat = "The review field is empty.";
$errormsg = 1;
}
if($errormsg == 1)
{
echo "<p class='error'>Please correct the errors and submit again.</p>";
} else{
try{
//query the data
$sql = "INSERT INTO cheathamContent (movie, review)
VALUES (:movie, :review) ";
//prepares a statement for execution
$stmt = $pdo->prepare($sql);
//binds the actual value of $_GET['ID'] to
$stmt->bindValue(':movie', $formdata['movie']);
$stmt->bindValue(':review', $formdata['review']);
//executes a prepared statement
$stmt->execute();
//hide the form
$showform =0;
//provide useful confirmation to user
echo "<p>Thanks for your review!</p>";
} catch (PDOException $e) {
die( $e->getMessage() );
}
} // else errormsg
}//submit
if($showform == 1){
?>
<form name="addreview" id="addreview" method="post" action="viewlist.php">
<table class="register">
<tr>
<th>
<label for="movie">Movie Name: </label>
</th>
<td>
<input name="movie" id="movie" type="text"placeholder="Movie Title" value="<?php if(isset($formdata['movie'])){ echo $formdata['movie'];}?>" /><span class="error">* <?php if(isset($errormovie)){echo $errormovie;}?></span>
</td>
</tr>
<tr>
<th>
<label for="review">Review: </label>
</th>
<td>
<input name="review" id="review" type="text" placeholder="Review" value="<?php if(isset($formdata['review'])){ echo $formdata['review'];}?>" /><span class="error">* <?php if(isset($errorreview)){echo $errorreview;}?></span>
</td>
</tr>
<tr>
<th>
<label for="submit">Submit: </label>
</th>
<td>
<input type="submit" name="submit" id="submit" value="submit"/>
</td>
</tr>
</table>
</form>
<?php
}//end showform
include_once "footer.inc.php";
?>
的代码,并将SQL语句和变量更改为与我的内容表一致。
当我检查phpmyadmin时,这些值没有输入到表中,所以出了问题,但我不确定它是什么。
我在内容表(cheathamContent)上的所有内容都是: ID 电影VARCHAR 审查VARCHAR
var j = -~(0.707 * x);