<?php

$host="localhost"; // Host name 
$username="pspmrsm1_mrbs"; // Mysql username 
$passwordw="mrbspassw0rd"; // Mysql password 
$db_name="pspmrsm1_mrbs"; // Database name 
$tbl_name="mrbs_room"; // Table name 

// Connect to server and select database.
mysql_connect("$host", "$username", "$passwordw")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// Get values from form 
$room=$_POST['room_name'];
$capacity=$_POST['capacity'];


// Insert data into mysql 
$sql="INSERT INTO $tbl_name(room_name,capacity, area_id)VALUES('$room','$capacity', '1')";
$result=mysql_query($sql);

// if successfully insert data into database, displays message "Successful". 
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='daftarbilik.php'>Back to main page</a>";
}

else {
echo "ERROR";
}
?> 

<?php 
// close connection 
mysql_close();
?>