<?php
include("config.php");
if (isset($_POST['submit_val']))
{
$cmeal = mysql_real_escape_string($_POST['meal']);
$meal = "INSERT INTO ebmealplans( MealPlanName, CreatedOn ) VALUES ( '{$cmeal}', NOW() )";
if(!mysql_query($meal, $link))
{
die("Error : " .mysql_error());
}
$croom = mysql_real_escape_string($_POST['room']);
$ref_key = mysql_insert_id();
$room = "INSERT INTO ebroomtypes( RoomTypeName, CreatedOn ) VALUES ( '{$croom}', NOW() )";
if(!mysql_query($room, $link))
{
die("Error : " .mysql_error());
}
if($room)
{
echo "<script> alert('Stored successfully'); </script>";
}
else
{
echo "<script> alert('Failed to store to database. Contact your administrator'); </script>";
}
mysql_close($link);
echo "<script> location.href='managevouchers.php'; </script>";
}
?>
look at this coding. i stored some values to two tables per form submission ($meal and $room). if values are inserted into database successfully na it should show the alert message. but here i am checking $room only. if i want to check $meal na what should i do? if i put another one like this...
if($meal)
{
echo "<script> alert('Voucher stored successfully'); </script>";
}
else
{
echo "<script> alert('Failed to store to database. Contact your administrator'); </script>";
}
it shown the alert message two times. how to avoid that? how to show alert message if values are inserted into mysql tables (more than two tables at a time?)