我正在尝试显示两条消息。 第一个告诉我该项目已发布到数据库。 第二个告诉我该项目已存在于数据库中。
这是我到目前为止所做的。
<?php
$connection = mysql_connect("localhost", "root", ""); // Establishing Connection with Server
$db = mysql_select_db("mydatabase", $connection); // Selecting Database from Server
if(isset($_POST['submit'])){ // Fetching variables of the form which travels in URL
$name = $_POST['name'];
if($name !=''){
//Insert Query of SQL
$query = mysql_query("insert into items(name) values ('$name')");
echo "<span>Data Inserted successfully...!!</span>";
}
else{
echo "<p>Item Exist. Try something else.</p>";
}
}
mysql_close($connection); // Closing Connection with Server
?>