I am a beginner and also a diploma student...
please help me solve this error... I tried many online solution but it cant help ... I'm new to php and mysql...
$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="slr"; // Database name
$tbl_name="software"; // Table name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form
$soft_name=$_POST['soft_name'];
$installed_date=$_POST['installed_date'];
$expiry_date=$_POST['expiry_date'];
$product_key=$_POST['product_key'];
// Insert data into mysql
$sql="INSERT INTO $software(soft_name, installed_date, expiry_date, product_key)VALUES('$soft_name', '$installed_date', '$expiry_date', '$product_key')";
$result=mysql_query($sql);
// if successfully insert data into database, displays message "Successful".
if($result){
echo "Successful";
echo "
";
echo "Back to main page";
} else {
echo "ERROR";
}
// close connection
mysql_close();
?>
No comments:
Post a Comment