无论如何我可以给每个帖子一个唯一的id,所以像quote_id这样的帖子就是那个帖子和那个帖子独有的,我正在创建一个喜欢的系统所以我需要这个以便当用户喜欢帖子,它把quote_id放下来,所以我以后可以抓住它来识别用户喜欢什么,有人可以提出任何建议吗?
<form name = "quoted" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input id = "poster" type="text" name="poster" required="required" placeholder = "Credited Individual."> <br>
<textarea class = "actual_quote" name = "actual_quote" required="required" placeholder = "Write the question here!"></textarea><br><br><br>
<div class = "checkboxes" required="required">
<h3 style = "margin-top:-20px;">Please select one catagory that the quote falls into.</h3>
<label for="x"><input type="radio" name="formtype" value="Inspirational" id = "inspirational.php" checked="checked" /> <span>Inspirational</span></label><br>
<label for="x"><input type="radio" name="formtype" value="Funny" id = "funny.php" /> <span>Funny</span> </label><br>
<label for="x"><input type="radio" name="formtype" value="OutofContext" id = "outofcontext.php"/> <span>OutofContext</span></label>
</div>
<input id = "submit1" name="submit1" type="submit"><br>
</form>
<div class = "contain-info">
<p style = "float: left; font-size:14px;"><strong>Creator:</strong> Write your own name or the creator of the quote here!</p><br>
<p style = "float: left; font-size:14px;"><strong>Quote:</strong> Write the quote you thought of or found here!</p>
</div>
</div>
</div>
<?php
$db_name = 'submissions';
$db_user = 'root';
$db_pass = '';
$db_host = 'localhost';
$db = new PDO('mysql:host = localhost;dbname=submissions', $db_user, $db_pass);
$formtype = (empty($_POST['formtype'])) ? : $_POST['formtype'] ;
$poster = (empty($_POST['poster'])) ? : $_POST['poster'] ;
$actual_quote = (empty($_POST['actual_quote'])) ? : $_POST['actual_quote'] ;
$query = $db->prepare("INSERT INTO data (actual_quote, poster, formtype) VALUES ( :actual_quote, :poster, :formtype)");
$query->bindParam(':formtype', $formtype, PDO::PARAM_STR);
$query->bindParam(':poster', $poster, PDO::PARAM_STR);
$query->bindParam(':actual_quote', $actual_quote, PDO::PARAM_STR);
$query->execute();
?>