| Current Path : /home/bolconlineco/public_html/admin/ |
| Current File : //home/bolconlineco/public_html/admin/topicstudycode.php |
<?php
ob_start();
include('../includes/connection/func.inc.php');
if(isset($_POST['submit']))
{
$topicname = sql_strip($_POST['materials']);
$catId=sql_strip($_POST['catId']);
$courseId = sql_strip($_POST['courseId']);
$topicId = sql_strip($_POST['topicId']);
$name = $_FILES['materials']['name'];
$temp_name = $_FILES['materials']['tmp_name'];
$allowed=array('doc','docx','pdf');
$type=explode('.',$name);
$dir="../StudyMaterials/";
$rand=mt_rand();
$fullname=$rand.$name;
if(in_array($type[1],$allowed))
{
$q="select * from topicstudy where topicId='$topicId' and courseId='$courseId'";
$res=mysql_query($q) or die(mysql_error());
if(mysql_num_rows($res) > 0)
{
header("location:topicstudymat.php?catId=$catId&courseId=$courseId&topicId=$topicId&error");
exit();
}else
{
if(move_uploaded_file($temp_name,$dir.$fullname))
{
$sql="INSERT INTO topicstudy values ('','$topicId','$courseId','$topicname','$fullname')";
$result=query($sql);
$msg="Materials inserted Successfully";
header("location:topicstudymat.php?catId=$catId&courseId=$courseId&topicId=$topicId&msg=$msg");
exit();
}
}
}else
{
$msg="Enter Correct File";
header("location:topicstudymat.php?catId=$catId&courseId=$courseId&topicId=$topicId&err=$msg");
exit();
}
}
?>