$registrationData->email = $_POST['email']; $registrationData->city = $_POST['city']; $registrationData->addressState = $_POST['addressState']; $registrationData->pinCode = $_POST['pinCode']; $registrationData->schoolName = $_POST['schoolName']; $registrationData->schoolCode = $_POST['schoolCode']; $registrationData->principalName = $_POST['principalName']; $registrationData->principalMobile = $_POST['principalMobile']; if (isset($_POST['studentId'])) { $registrationData->state = 2; $registrationData->studentId = $_POST['studentId']; } else { $registrationData->state = 1; $registrationData->status = 1; } $registrationInfo = new dataInfo(); $response = $registrationInfo->addstudent($registrationData); $succesMsg = $response; //var_dump($succesMsg); if (isset($_POST['url'])) { header("location:" . $_POST['url']); } else { header("location:viewRegistration.php"); } } else { throw new Exception("fill required field."); } } catch (Exception $e) { $msg = $e->getMessage(); } }