<?php
//$servername = "localhost";
//$username = "u773459596_iwebbclientus2";
//$password = "[@^=k4!z[W7";
//$dbname = "u773459596_iwebbclientdb2";

$servername = "localhost";
$username = "u836566291_pcs";
$password = "VSJgO:Y8=rZ";
$dbname = "u836566291_pcs";

//dynamic data add fields
$roll =$_POST["roll"];
$cname =$_POST["cname"];
$fname =$_POST["fname"];
$post =$_POST["post"];
$dob =$_POST["dob"];
$remarks =$_POST["remarks"];




try {
  $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
  // set the PDO error mode to exception
  $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  $sql = "INSERT INTO data (roll,cname,fname,post,dob,remarks)
  VALUES ('$roll','$cname','$fname', '$post', '$dob', '$remarks')";
  // use exec() because no results are returned
  $conn->exec($sql);
  echo "<script>alert('Client Data Addedd Successfully!');</script>";
  echo "<script>window.location.replace('index.php');</script>";
} catch(PDOException $e) {
  echo $sql . "<br>" . $e->getMessage();
}

$conn = null;
?>