

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
 <html xmlns="http://www.w3.org/1999/xhtml">   
 <head>   
 <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />   
 <title>Insert Data</title>   
 </head>   
   
 <body>   
 <h1>Insert Data</h1>  
 <?php  
 $host = "localhost";
$username = "root";
$password = "";
$db = "dbsekonomi"; 

   
 $conn = mysql_connect ($host, $username, $password);  
 if ($conn) {  
  $buka = mysql_select_db ($db);  
  if (!$buka) {  
  die ("Database tidak dapat dibuka");  
  }  
 } else {  
  die ("Server MySQL tidak terhubung");  
 }  
   
 $error=0;  
 if(isset($_POST['enter']))  
 { 
  $sql9 = mysql_query("TRUNCATE TABLE dataset");
 $count=$_POST['count']+1;  
 for($j=1;$j<$count;$j++)  
 {  
 $yt= "yt".$j;  
 $yt = addslashes (strip_tags ($_POST[$yt])); 
 $x1= "x1".$j;  
 $x1 = addslashes (strip_tags ($_POST[$x1]));  
 $x2= "x2".$j;  
 $x2 = addslashes (strip_tags ($_POST[$x2])); 
 $x3= "x3".$j;  
 $x3 = addslashes (strip_tags ($_POST[$x3])); 
 $x4= "x4".$j;  
 $x4 = addslashes (strip_tags ($_POST[$x4])); 
 
 
 
 $q="INSERT INTO dataset(yt,x1,x2,x3,x4) VALUES ('$yt','$x1','$x2','$x3','$x4')";  
 $r=mysql_query($q);  
 if(!$r){$error++;}  
 }  
 if($error) { echo "STATUS : IMPORT DATA ERROR";}  
 else echo "STATUS : IMPORT DATA BERHASIL";
header('Location: DATASET.php'); 
 }  
 ?>  
 <a href="DATASET.php">KEMBALI</a>
 </body>  
 </html>  
