<?php
$login=mysql_connect('localhost', 'wauhaha_karaoke', 'cross123','wauhaha_karaoke');
mysql_selectDB("wauhaha_karaoke",$login);


$SupID = $_GET['SupID'];
$ProID=$_POST['ProID'];
$ProName=$_POST['ProName'];
$p=$_POST['p'];



$result=mysql_query("select * from ksupplier where SupID='$SupID'");
$row = mysql_fetch_array($result);
$SupName = $row['SupName'];
if(($ProName=="")||($p=="")){
	echo "<script>alert('Please fill in your form completely')</script>";
	echo "<script language='javascript'>window.location='addnewkstock.php?SupID=$SupID'</script>";

}else{

$query=mysql_query("INSERT INTO kstock(ProID,SupName,SupID,ProName,ProPrice)VALUE('$ProID','$SupName','$SupID','$ProName','$p')");

if($query){
		echo "<script>alert('Add Successful')</script>";
		echo "<script language='javascript'>window.location='http://www.wauhaha.com/karaoke/addkstock.php?SupID=$SupID'</script>";die;
}else
		echo "<script>alert('Add Fail')</script>";
		echo "<script language='javascript'>window.location='http://www.wauhaha.com/karaoke/addnewkstock.php?SupID=$SupID'</script>";die;
}
?>