session_start(); global $scode; $linkID = mysql_connect("localhost", "root", "zangtang"); mysql_select_db("SciPark"); function findexts ($filename) { $filename = strtolower($filename) ; $exts = split("[/\\.]", $filename) ; $n = count($exts)-1; $exts = $exts[$n]; return $exts; } //------------------------------------------------------------------------------------------------------------------------------------ // VERIFY FORM FUNCTION //--------------------------------------------------------------------------------------------------------------------------------------- function VerifyForm(&$values, &$errors) { if (htmlentities($values['EventType']) == "Select") $errors['EventType'] = "Event Name Required"; if(htmlentities($values['EventType']) == "Other" || htmlentities($values['EventType']) == "Demonstration" || htmlentities($values['EventType']) == "CelebrationDay") { if(strlen($values['EventName'])== 0) $errors['EventName'] = "Event Name Required"; } if(htmlentities($values['EventType']) == "Lecture") { if(strlen($values['EventName'])== 0) $errors['EventName'] = "Lecture Series Name Required"; if(strlen($values['TopicName'])== 0) $errors['TopicName'] = "Lecture Topic Required"; if(strlen($values['SpeakerName'])== 0) $errors['SpeakerName'] = "Speaker's Info. Required"; } if(strlen($values['EventDuration'])== 0) $errors['EventDuration'] = "Event Duration Required (Time & Date)"; if(strlen($values['EventEligibility'])== 0) $errors['EventEligibility'] = "Event's Eligibility Criteria Required"; if(strlen($values['EventBatchSize'])== 0 && (htmlentities($values['EventType']) == "SciCamp" || htmlentities($values['EventType']) == "SummerCamp")) $errors['EventBatchSize'] = "Batch Size Required"; if(htmlentities($values['EventType']) == "SciCamp" || htmlentities($values['EventType']) == "TeachersPgm" || htmlentities($values['EventType']) == "SummerCamp") { if(strlen($values['EventFees'])== 0) $errors['EventFees'] = "Course Fees Required"; } $RegStartDate = $values['RegStartYear']."-".$values['RegStartMonth']."-".$values['RegStartDay']; //echo $RegStartDate; $RegLastDate = $values['RegLastYear']."-".$values['RegLastMonth']."-".$values['RegLastDay']; $BatchStartDate = $values['BatchStartYear']."-".$values['BatchStartMonth']."-".$values['BatchStartDay']; $BatchEndDate = $values['BatchEndYear']."-".$values['BatchEndMonth']."-".$values['BatchEndDay']; if(htmlentities($values['RegReqd']) == "Yes") { if(!checkdate( $values['RegStartMonth'], $values['RegStartDay'], $values['RegStartYear'])) $errors['RegStartDate'] = 'Correct Registration Starting Date Required'; if(!checkdate( $values['RegLastMonth'], $values['RegLastDay'], $values['RegLastYear'])) $errors['RegLastDate'] = 'Correct Registration Ending Date Required'; if($RegStartDate > $RegLastDate) $errors['RegLastDate'] = 'Select the date after Opening date of Registration'; if($RegLastDate > $BatchStartDate) $errors['BatchStartDate'] = 'Select the date after Last date of Registration'; if($BatchStartDate > $BatchEndDate) $errors['BatchEndDate'] = 'Select the date after Starting date of Batch'; // if($RegStartDate != "Select-Select-Select") // { // if(!checkdate( $values['RegLastMonth'], $values['RegLastDay'], $values['RegLastYear'])) $errors['RegLastDate'] = 'Correct Registration Ending Date Required'; // } } if(!checkdate( $values['BatchStartMonth'], $values['BatchStartDay'], $values['BatchStartYear'])) $errors['BatchStartDate'] = 'Correct Batch Starting Date Required'; if(!checkdate( $values['BatchEndMonth'], $values['BatchEndDay'], $values['BatchEndYear'])) $errors['BatchEndDate'] = 'Correct Batch Ending Date Required'; if($BatchStartDate > $BatchEndDate) $errors['BatchEndDate'] = 'Select the date after Starting date of Batch'; // if (htmlentities($values['RegReqd']) == "Yes" && (htmlentities($values['EventType']) == "LPF" || htmlentities($values['EventType']) == "ScienceDay" || htmlentities($values['EventType']) == "Other" || //htmlentities($values['EventType']) == "Lecture" || htmlentities($values['EventType']) == "Demonstration" || htmlentities($values['EventType']) == "CelebrationDay")) //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ FILE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $EventFile = $_SESSION['EventFile']; $Code = $_SESSION['Code'] ; $_SESSION['uploads'] = "1"; $uploaddir = "uploads/"; $query0 = "SELECT `EventNo` FROM EventsInfo Order by EventNo"; $result0 = mysql_db_query("SciPark", $query0) or die ("could not query" . mysql_error()); $tung0=mysql_affected_rows(); if($tung0 != 0) { while ($r = mysql_fetch_array($result0)) { $EventCnt = $r["EventNo"]; } $EventCnt++; } else { $EventCnt = "1"; } $ext = findexts($_FILES['Event_PDF']['name']) ; // POST Extension of File echo $ext; if($ext == "") { $_SESSION["FileUp"]= 0; } else { $_SESSION["FileUp"]= 1; } $tname = $Code."EV".$EventCnt."Brochure."; $filename = $tname.$ext; $uploadfile = $uploaddir.$filename; // echo "----->".$uploadfile; $_SESSION["uploadfile"] = $uploadfile; if($ext != "") { if(($_FILES['Event_PDF']['size']) > 5242880) { $errors['EventFL'] = "File Size is more than 5 MB"; } if((!ereg(".pdf", $filename))) { $errors['EventFL'] = "Event Brochure : Only PDF allowed"; } } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //print_r($errors); return (count($errors) == 0); } //--------------------------------------------------------------------------------------------------------------------------------------- // DISPLAY FORM FUNCTION //--------------------------------------------------------------------------------------------------------------------------------------- function outputOptionList($list, $selected) { foreach ($list as $item) echo "\n"; } function DisplayForm($values, $errors) { // $chars = "abcdefghijkmnopqrstuvwxyz023456789"; $i=0; $d=date(d); $m=date(F); $n=date(n); $y=date(Y); $optionListMonth = array( array('Value' =>'Select', 'Text' => '(select Month)'), array('Value' =>'01', 'Text' => 'January'), array('Value' =>'02', 'Text' => 'February'), array('Value' =>'03', 'Text' => 'March'), array('Value' =>'04', 'Text' => 'April'), array('Value' =>'05', 'Text' => 'May'), array('Value' =>'06', 'Text' => 'June'), array('Value' =>'07', 'Text' => 'July'), array('Value' =>'08', 'Text' => 'August'), array('Value' =>'09', 'Text' => 'September'), array('Value' =>'10', 'Text' => 'October'), array('Value' =>'11', 'Text' => 'November'), array('Value' =>'12', 'Text' => 'December'), ); $optionEventName = array( array('Value' =>'Select', 'Text' => '(select Event)'), array('Value' =>'Lecture', 'Text' => 'Lecture'), array('Value' =>'Demonstration', 'Text' => 'Demonstration'), array('Value' =>'CelebrationDay', 'Text' => 'Celebration Day'), array('Value' =>'SciCamp', 'Text' => 'Initiative in Science Education for School Children(Handson training Lab'), array('Value' =>'LPF', 'Text' => 'Lila Poonawalla Foundation Girls Science Camp'), array('Value' =>'ScienceDay', 'Text' => 'Science Day/Open Day'), array('Value' =>'SummerCamp', 'Text' => 'Summer Science Camp'), array('Value' =>'TeachersPgm', 'Text' => 'Teachers Training Program'), array('Value' =>'SchoolVisit', 'Text' => 'School Visit'), array('Value' =>'Other', 'Text' => 'Other'), ); $nextY = $y+1; //echo $nextY; $next2Y = $nextY+1; //echo $next2Y; $optionListYear = array( array('Value' => 'Select', 'Text' => "(select Year)"), array('Value' => '2023', 'Text' => "2023"), array('Value' => '2024', 'Text' => "2024"), array('Value' => '2025', 'Text' => "2025"), ); //print_r($optionListYear); $days = array( array('Value' =>'Select', 'Text' => 'Date'), array('Value' =>'01', 'Text' => '01'), array('Value' =>'02', 'Text' => '02'), array('Value' =>'03', 'Text' => '03'), array('Value' =>'04', 'Text' => '04'), array('Value' =>'05', 'Text' => '05'), array('Value' =>'06', 'Text' => '06'), array('Value' =>'07', 'Text' => '07'), array('Value' =>'08', 'Text' => '08'), array('Value' =>'09', 'Text' => '09'), array('Value' =>'10', 'Text' => '10'), array('Value' =>'11', 'Text' => '11'), array('Value' =>'12', 'Text' => '12'), array('Value' =>'13', 'Text' => '13'), array('Value' =>'14', 'Text' => '14'), array('Value' =>'15', 'Text' => '15'), array('Value' =>'16', 'Text' => '16'), array('Value' =>'17', 'Text' => '17'), array('Value' =>'18', 'Text' => '18'), array('Value' =>'19', 'Text' => '19'), array('Value' =>'20', 'Text' => '20'), array('Value' =>'21', 'Text' => '21'), array('Value' =>'22', 'Text' => '22'), array('Value' =>'23', 'Text' => '23'), array('Value' =>'24', 'Text' => '24'), array('Value' =>'25', 'Text' => '25'), array('Value' =>'26', 'Text' => '26'), array('Value' =>'27', 'Text' => '27'), array('Value' =>'28', 'Text' => '28'), array('Value' =>'29', 'Text' => '29'), array('Value' =>'30', 'Text' => '30'), array('Value' =>'31', 'Text' => '31'), ); ?>
} //--------------------------------------------------------------------------------------------------------------------------------------- $login = $_SESSION['AdminLogin'] ; $linkID = mysql_connect("localhost", "webuser", "zangtang"); mysql_select_db("SciPark"); $query0 = "SELECT * FROM AdminLogin WHERE `AdminLogin`='$login'"; $result0 = mysql_db_query("SciPark", $query0) or die ("could not query" . mysql_error()); $tung0=mysql_affected_rows(); $i=0; $j=0; if(isset($_SESSION['AdminLogin'])) { if($tung0) { if($_SERVER['REQUEST_METHOD'] == "POST") { //echo $_SESSION["TP"]; $formValues = $_POST; $formErrors = array(); //echo "the errors are :".$formValues."--".$Sname; if(isset($_POST["AddEvent"])) { if(!VerifyForm($formValues, $formErrors)) DisplayForm($formValues, $formErrors); else { //$formValues = $_POST; //$formErrors = array(); $EventType = $_POST["EventType"]; $EventName = $_POST["EventName"]; $EventOther = $_POST["EventOther"]; $TopicName = $_POST["TopicName"]; $SpeakerName = $_POST["SpeakerName"]; $EventDuration = $_POST["EventDuration"]; $EventEligibility = $_POST["EventEligibility"]; $EventBatchSize = $_POST["EventBatchSize"]; $EventExtraInfo = $_POST["EventExtraInfo"]; $EventFees = $_POST["EventFees"]; $RegStartDay = $_POST["RegStartDay"]; $RegStartMonth = $_POST["RegStartMonth"]; $RegStartYear = $_POST["RegStartYear"]; $RegReqd = $_POST["RegReqd"]; $RegLastDay = $_POST["RegLastDay"]; //echo "-->".$RegLastDay."
Problem with adding New Event into the Database...
} } else echo "Error found!!! Please fill the form correctly"; } //else close } else { $formValues = $_POST; $formErrors = array(); DisplayForm($formValues, $formErrors); }//echo $_POST["a_addr1"]; }//} ////////$_SESSIOM['H_HCBL'] = $H_HCBL; } else { DisplayForm(null, null); //echo "here1"; // } } } else { header( 'Location: Access_Denied.html' ) ; } ?>