我有一个张贴表格,您可以在其中张贴您的姓名、文字、地点和联系方式。4 个标签。
html 中的 post 表单代码如下所示:
<div class="form">
<form id="contactform" action="post.php" method="post">
<p class="contact"><label for="who">Who</label></p>
<input id="who" name="who" placeholder="Who are you? (First & Second name)" required="" type="text">
<p class="contact"><label for="email">Text</label></p>
<input id="what" name="what" placeholder="Text" required="" type="text">
<p class="contact"><label for="username">Where</label></p>
<input id="where" name="where" placeholder="Country, City, Street..." required="" type="text">
<p class="contact"><label for="password">Contact</label></p>
<input type="text" id="contact" name="contact" placeholder="Phone number or email"required="">
<input class="buttom" name="submit" id="submit" tabindex="5" value="Submit" type="submit">
post.php 代码如下所示:
<?php header("Location: feed.php"); ?>
<?php
define ( 'DB_NAME','database_name');
define ( 'DB_USER','user');
define ( 'DB_PASSWORD','foot');
define ( 'DB_HOST','localhost');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!link) {
die('Could not connect: ' .mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);
if (!$db_selected) {
die('Can\'t use ' . DB_NAME . ': ' . mysql_error());
}
$value1 = $_POST['who'];
$value2 = $_POST['text'];
$value3 = $_POST['where'];
$value4 = $_POST['contact'];
$sql = "INSERT INTO content (`who`, `text`, `where`, `contact`) VALUES ('$value1', '$value2', '$value3', '$value4')";
if (!mysql_query($sql)) {
die('Error: ' . mysql_error());
}
echo "You've just posted your text!";
mysql_close();
?>
我想要的是您应该能够通过写作来发布文本,例如 www.mywebsite.com/post.php?name=MyName&text=MyText&place=MyPlace&contact=Contact
因此,您应该能够通过 url 填写表格。
有任何想法吗?