function get_db_handle() { $server = 'opatija.sdsu.edu:3306'; $user = '******'; $password = '******'; $database = 'jadrn056'; if (!($db = mysqli_connect($server, $user, $password, $database))) { write_error_page("Cannot Connect!"); } return $db; }
function update_error_page($sql) { if (isset($_POST['uaction']) && $_POST['uaction'] === 'updt_error') { $eid = intval($_POST['eid']); if (in_array($eid, array(401, 402, 403, 404, 500, 503)) && write_error_page($sql, $eid)) { set_page_message(tr('Custom error page was updated!'), 'success'); } else { set_page_message(tr('System error - custom error page was NOT updated!'), 'error'); } } }
function update_error_page(&$sql, $user_id) { if (isset($_POST['uaction']) && $_POST['uaction'] === 'updt_error') { if ($_POST['eid'] == 401 or $_POST['eid'] == 403 or $_POST['eid'] == 404 or $_POST['eid'] == 500) { write_error_page($sql, $_SESSION['user_id'], $_POST['eid']); set_page_message(tr('Custom error page was updated!')); } else { set_page_message(tr('System error - custom error page was NOT updated!')); } } }
function store_data_in_db($params) { $db = get_db_handle(); $sql = "select * from parent where first_name='{$params['0']}' and secondary_phone='{$params['36']}' and email='{$params['15']}';"; $result = mysqli_query($db, $sql); if (mysqli_num_rows($result) > 0) { $row = mysqli_fetch_array($result); $parent_id = $row[0]; $sql = "select * from child where parent_id='{$parent_id}' and first_name='{$params['16']}' and birthdate='{$params['22']}' ;"; //echo "parent_id".$parent_id; $result = mysqli_query($db, $sql); if (mysqli_num_rows($result) > 0) { $row = mysqli_fetch_array($result); $child_id = $row[0]; $enrollment = 0; $program = camps($params); for ($i = 0; $i < count($program); $i++) { $sql = "select * from enrollment where program_id='{$program[$i]}' and child_id='{$child_id}';"; $result = mysqli_query($db, $sql); if (mysqli_num_rows($result) > 0) { $row = mysqli_fetch_array($result); $enrollment = 1; } } if ($enrollment == 1) { write_error_page('The child is already registered for the program selected.Click<a href="Enrollment.html"> here </a> to go back to the previous screen'); exit; } else { insert_enrollment($child_id, $params, $db); } } else { insert_child($parent_id, $params, $db); } } else { ### NOT A DUP // $sql = "Insert into parent(first_name,middle_name,last_name,address1,address2,city,state,zip,primary_phone,secondary_phone,email) values ('sdsasdf','sdasdfssa','dsd','asasdfda','dsad','fsdfs','CA',91110,2222222222,1111122222,'*****@*****.**')"; // echo "'".$params[0]."'<br>"; // echo "'".$params[1]."'<br>"; // echo "'".$params[2]."'<br>"; // echo "'".$params[3]."'<br>"; // echo "'".$params[4]."'<br>"; // echo "'".$params[5]."'<br>"; // echo "'".$params[6]."'<br>"; // echo "'".$params[7]."'<br>"; // echo "'".$params[35]."'<br>"; // echo "'".$params[36]."'<br>"; // echo "'".$params[15]."'<br>"; $sql = "insert into parent(first_name,middle_name,last_name,address1,address2,city,state,zip,primary_phone,secondary_phone,email) " . "values('{$params['0']}','{$params['1']}','{$params['2']}','{$params['4']}','{$params['5']}','{$params['6']}','{$params['7']}','{$params['8']}','{$params['35']}','{$params['36']}','{$params['15']}');"; // if(mysqli_query($db,$sql)===True) echo "success"; // else echo "No Donut"; mysqli_query($db, $sql); //$how_many = mysqli_affected_rows($db); $parent_id = mysqli_insert_id($db); //echo "parent_id in else".$parent_id; if (!empty($parent_id)) { insert_child($parent_id, $params, $db); } else { echo "A critical error occurred."; } } mysqli_close($db); }