<?php
ini_set('default_charset', 'utf-8');
$host="localhost"; // Host name 
$user="Vroots"; // Mysql username 
$pass="rOhr%107"; // Mysql password 
$dbname="vsaDBn"; // Database name  
$tbl_name="vsaqtns"; // Table name
//---- Declarations
$sbj = "";
$Qpos = "";
$qnatr = "";
$exmtyp = "";
$dt = "";
$yr = "";
$questn = "";
$chA = "";
$chB = "";
$chC = "";
$chD = "";
$resp = "";
$soln = "";
$btch = "";
$tps = "";
$qsttus = "";
$stMark = "";
$paragT ="";
$fig = "";
$figpath= "";
$img2 = "";
$qid= "";
$img = "";
//----
$imagename=$_FILES["image_file"]["figname"]; 
echo $imagename;
$target_file = $target_dir . basename($_FILES["image_file"]["name"]);
echo $target_file;
// get data that sent from form 
$image = $_FILES['image_file']['tmp_name'];
$img = file_get_contents($image);
$img2 = $_POST($image);
$qid=$_POST['qid'];
$qnatr=$_POST['qnatr'];
$exmtyp=$_POST['exmtyp'];
$dt=$_POST['dt'];
$figpath=($_POST['figname'];
$sbj=$_POST['sbj'];
$yr=$_POST['yr'];
$questn=$_POST['que'];
$cha=$_POST['chA'];
$chb=$_POST['chB'];
$chc=$_POST['chC'];
$chd=$_POST['chD'];
$resp=$_POST['Ans'];
$soln=$_POST['soln'];
$fig = $img2;
$stMark=intval$_POST['stMark']);
$btch=$_POST['btch'];
$tps=$_POST['tps'];
$qsttus=$_POST['sttus'];

//if (ctype_alpha($_POST['sbj'])) {}
$sbj = $_POST['sbj'];

	/*if (ctype_alpha($_POST['Qpos'])) {
$pos = $_POST['Qpos'];
}*/
$pos = intval($_POST['Qpos']); 

//if (ctype_alpha($_POST['questn'])) {}
   $questn = $_POST['questn'];

//if (ctype_alpha($_POST['qnatr'])) {}
$qnatr = $_POST['qnatr'];

//if (ctype_alpha($_POST['exmtyp'])) {}
$exmtyp = $_POST['exmtyp'];

//if (ctype_alpha($_POST['dt'])) {}
$dt = $_POST['dt'];

//if (ctype_alpha($_POST['yr'])) {}
$yr = $_POST['yr'];


//if (ctype_alpha($_POST['chA'])) {
$cha = $_POST['chA'];

//if (ctype_alpha($_POST['chB'])) {
$chb = $_POST['chB'];

//if (ctype_alpha($_POST['chC'])) {
$chc = $_POST['chC'];

//if (ctype_alpha($_POST['chD'])) {
$chd = $_POST['chD'];

//if (ctype_alpha($_POST['Ans'])) {
$resp = $_POST['Ans'];

//if (ctype_alpha($_POST['soln'])) {
$soln = $_POST['soln'];

//if (ctype_alpha($_POST['btch'])) {
$btch = $_POST['btch'];

//if (ctype_alpha($_POST['tps'])) {
$tps = $_POST['tps'];

//if (ctype_alpha($_POST['qsttus'])) {
$qsttus = $_POST['qsttus'];
$stMark = intval($_POST['stMark']);
//if (ctype_alpha($_POST['paragT'])) {
$paragT = $_POST['paragT'];

//----
try {
    $conn = new PDO("mysql:host=localhost;dbname=vsaDBn;charset=utf8", $user, $pass);
	$conn->setAttribute(PDO::ATTR_EMULATE_PREPARES, FALSE);
    // set the PDO error mode to exception
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    //$sql="UPDATE vsaqtns SET qnatr ='$qnatr', exmtyp ='$exmtyp', dt ='$dt', sbj='$sbj', yr='$yr', questn='$questn', cha='$cha', chb='$chb', chc='$chc', chd='$chd', resp='$resp', soln='$soln', paragT='$paragT', btch='$btch', tps='$tps', qsttus='$qsttus', stMark='$stMark' WHERE pos=". $conn->quote($pos);
	$sql="INSERT INTO vsaqtns(qid, qnatr, exmtyp, dt, figpath, sbj, yr, questn, cha, chb, chc, chd, resp, soln, stMark, btch, tps, qsttus, fig)VALUES('$qid', '$qnatr','$exmtyp', '$dt', '$figpath', '$sbj','$yr','$questn', '$cha', '$chb', '$chc', '$chd', '$resp', '$soln', '$stMark', '$btch', '$tps', '$qsttus', '$fig')";
    //$sql = "Select * from vsaqtns WHERE pos=". $conn->quote($pos);
	//$sql = "UPDATE vsaqtns SET questn=? WHERE pos=?";

    // Prepare statement
    $stmt = $conn->prepare($sql);
    //$stmt = $conn->exec($sql);
    // execute the query
    $stmt->execute();

    // echo a message to say the UPDATE succeeded
    echo $stmt->rowCount() . " records UPDATED successfully";

	
//	" records UPDATED successfully";
     $conn = null;
    }
catch(PDOException $e)
    {
    echo $sql . "<br>" . $e->getMessage();
    }


?>
