function insertUser($uname, $email, $password) { global $connection; $query = "INSERT INTO user (uname, email, password) VALUES "; $query .= "('{$uname}', '{$email}', '{$password}')"; echo $query; $result = mysqli_query($connection, $query); confirm_query($result); if ($result) { $_SESSION['login_user'] = $uname; $query = "SELECT uid FROM user WHERE "; $query .= "uname = '{$uname}'"; $result = mysqli_query($connection, $query); $rows = mysqli_num_rows($result); if ($rows == 1) { while ($row = mysqli_fetch_assoc($result)) { $_SESSION['login_user_uid'] = $row["uid"]; } } header("location: editProfile.php"); } else { $error = "Username already exists"; } if (!$connection) { mysql_close($connection); } echo "end"; }
function execute_and_confirm($statement) { global $connection; $result = mysqli_query($connection, $statement); confirm_query($result); return $result; }
function getUser($uname) { global $connection, $email, $password, $interests, $rec; $query = "SELECT uname, email, password, interests, recommendation_factor, tag_cloud FROM user "; $query .= "WHERE user.uname = '{$uname}'"; //echo $query; $result = mysqli_query($connection, $query); confirm_query($result); $rows = mysqli_num_rows($result); if ($rows == 1) { while ($row = mysqli_fetch_assoc($result)) { $email = $row["email"]; $password = $row["password"]; $i = $row["interests"]; if ($i != null) { $interests = explode(",", $i); } $recommendation_factor = $row["recommendation_factor"]; if ($recommendation_factor != null) { $rec = explode(",", $recommendation_factor); } $tag_cloud = $row["tag_cloud"]; } } }
function check($idno, $scontact, $semail) { $sql = 'SELECT instruc_id, instruct_contact, email_add FROM instructor'; $result = mysql_query($sql); confirm_query($result); while ($row = mysql_fetch_array($result)) { if ($idno == $row['instruc_id']) { ?> <script type="text/javascript"> alert("ID already Exist!"); window.location("add_instructor.php"); </script> <?php } else { if ($scontact == $row['instruct_contact']) { ?> <script type="text/javascript"> alert("Contact already Exist!"); window.location("add_instructor.php"); </script> <?php } else { if ($semail == $row['email_add']) { ?> <script type="text/javascript"> alert("Email already Exist!"); window.location("add_instructor.php"); </script> <?php } } } } return true; }
function client_set() { $query = "SELECT *\r\n\t\t\t FROM clients\r\n\t\t\t ORDER BY position ASC"; $clients = mysql_query($query); confirm_query($clients); return $clients; }
function showInterests($user) { global $connection; $query = "SELECT interests FROM user "; $query .= "WHERE user.uname = '{$user}'"; //echo $query; $result = mysqli_query($connection, $query); while ($row = mysqli_fetch_assoc($result)) { $csv_interests = $row["interests"]; if ($csv_interests != null) { $interests = explode(",", $csv_interests); foreach ($interests as $interest_id) { $query = "SELECT c_name FROM category "; $query .= "WHERE category.cid = {$interest_id}"; //echo $query; $result = mysqli_query($connection, $query); confirm_query($result); while ($row = mysqli_fetch_assoc($result)) { echo "<a href=\"catergory.php?id=" . $interest_id . "\" class=\"btn btn-info\" role=\"button\"><strong>" . $row["c_name"] . "</strong></a> "; } } } else { echo $user . " has no selected interests"; } } if (!$connection) { mysql_close($connection); } //echo "end"; }
function db_delete($table, $column_name, $column_value) { $query = "DELETE FROM {$table} "; $query .= "WHERE {$column_name} = {$column_value}"; $db_delete = mysqli_query($db, $query); confirm_query($db_delete); }
function get_all_jumpers() { global $connection; $query = "SELECT * FROM jumperdr"; $page_set = mysqli_query($connection, $query); confirm_query($subject_set); return $subject_set; }
function get_all_categories() { global $connection; $query = "SELECT * FROM categories "; $category_set = mysqli_query($connection, $query); confirm_query($category_set); return $category_set; }
function addType($type_name, $cat) { global $dbc; $query = "INSERT INTO tbltypes (type_name, cat_id) " . "VALUES ('{$type_name}', {$cat})"; $result = mysqli_query($dbc, $query); confirm_query($result, $query); return $result; }
function find_pages_for_subject($subject_id) { global $connection; $query = "select * from pages where subject_id = {$subject_id}"; $page_set = mysqli_query($connection, $query); confirm_query($page_set); return $page_set; }
function del_gall($gallid) { global $connection; $query = "SELECT * FROM `galleries` WHERE `id` = " . $gallid; $result = mysqli_query($connection, $query); $gall = mysqli_fetch_array($result); // Specify the target directory and add forward slash $dir = "../galleries/" . $gall['name'] . "/gallery/"; foreach (scandir($dir) as $item) { if ($item == '.' || $item == '..') { continue; } unlink($dir . DIRECTORY_SEPARATOR . $item); } rmdir($dir); $dir = "../galleries/" . $gall['name'] . "/gallery-thumbs/"; foreach (scandir($dir) as $item) { if ($item == '.' || $item == '..') { continue; } unlink($dir . DIRECTORY_SEPARATOR . $item); } rmdir($dir); $dir = "../galleries/" . $gall['name'] . "/"; rmdir($dir); $query = "DELETE FROM `galleries` WHERE `id` = {$gallid}"; $result = mysqli_query($connection, $query); confirm_query($result); $pagegallquery = "SELECT * FROM `pages`"; $pagegallresult = mysqli_query($connection, $pagegallquery); while ($page = mysqli_fetch_array($pagegallresult)) { if (is_array(unserialize($page['galleries']))) { $pagegalleries = unserialize($page['galleries']); $index = array_search($gallid, $pagegalleries); if ($index != false) { unset($pagegalleries[$index]); } $pagegalleries = serialize($pagegalleries); $query = "UPDATE `pages` SET `galleries`='{$pagegalleries}' WHERE id = {$page['id']}"; $result = mysqli_query($connection, $query); } } $subgallquery = "SELECT * FROM `galleries`"; $subgallresult = mysqli_query($connection, $subgallquery); while ($subgallery = mysqli_fetch_array($subgallresult)) { if (is_array(unserialize($subgallery['subgalleries']))) { $subgalleries = unserialize($subgallery['subgalleries']); $index = array_search($gallid, $subgalleries); if ($index != false) { unset($subgalleries[$index]); } $subgalleries = serialize($subgalleries); $query = "UPDATE `pages` SET `galleries`='{$subgalleries}' WHERE id = {$subgallery['id']}"; $result = mysqli_query($connection, $query); } } $success = "Gallery was deleted!"; }
function find_user_by_username($username) { global $db; $safe_username = $db->quote($username); $info = $db->query("SELECT * FROM members WHERE username = {$safe_username} "); $info = $info->fetchAll(PDO::FETCH_ASSOC); confirm_query($info); return $info; }
function page_general_query($lang, $page) { global $connection; $lang = get_lang($lang); $query = "SELECT * \n\t\t\t\tFROM pages \n\t\t\t\tWHERE '{$page}' = subject_id AND lang = '{$lang}'"; $response = mysqli_query($connection, $query); confirm_query($response); return $response; }
function getUserById($username, $password) { $connection = connect(); $query = "SELECT * from user where user_name = '{$username}' and password = '******' limit 1"; $result = mysqli_query($connection, $query); confirm_query($result); $user = mysqli_fetch_assoc($result); return $user; }
function get_price($pid) { global $connection; $query = "SELECT price FROM products WHERE id=" . $pid; $result = mysql_query($query, $connection); confirm_query($result); $row = mysql_fetch_array($result); return $row['price']; }
function search_result_for_change($pass) { global $connection; $query = "SELECT * "; $query .= "FROM abit "; $query .= "WHERE pass LIKE '{$_COOKIE["password"]}'"; $result_set = $connection->query($query); confirm_query($result_set); return $result_set; }
function get_schools() { $connection = connect(); //2.perform query $query = "SELECT * from school"; $result = mysqli_query($connection, $query); confirm_query($result); colse_connection($connection); return $result; }
function find_all_admins() { global $connection; $query = "SELECT * "; $query .= "FROM admins "; $query .= "ORDER BY username ASC"; $admin_set = mysqli_query($connection, $query); confirm_query($admin_set); return $admin_set; }
function selectOption($id) { global $connection; $stmt = $connection->prepare("call selectOption(?)"); $stmt->bind_param('i', $id); $stmt->execute(); $result = $stmt->get_result(); confirm_query($result); return $result; }
function admin_page_index() { $pagination = pagination(15, 'pages'); $page_index = '<table class="table table-hover table-bordered">'; $page_index .= '<tr><th>Name</th><th>Subject</th><th>Position</th><th>Visible</th><th>Product</th><th>Modification</th></tr>'; while ($page = mysql_fetch_array($pagination['query'])) { $page_index .= '<tr>'; $page_index .= '<td>' . $page['page_name'] . '</td>'; // to get page name and its id start global $connection; $query = "SELECT name FROM page_subjects WHERE id=" . $page['subject_id']; $subject_set = mysql_query($query, $connection); confirm_query($subject_set); while ($subject = mysql_fetch_array($subject_set)) { $page_index .= '<td>' . $subject['name'] . '</td>'; } // get page name from id end $page_index .= '<td>' . $page['position'] . '</td>'; if ($page['visible'] == 1) { $page_index .= '<td>' . ($page['visible'] = 'Yes' . '</td>'); } else { $page_index .= '<td>' . ($page['visible'] = 'No' . '</td>'); } // to get product global $connection; $query = "SELECT * FROM products WHERE page_id=" . $page['id']; $product_set = mysql_query($query, $connection); confirm_query($product_set); $pro_id = 0; $pro = 'No'; while ($product = mysql_fetch_array($product_set)) { if ($product['page_id'] == $page['id']) { $pro = $product['name']; $pro_id = $product['id']; } } // get products if ($pro != 'No') { $page_index .= '<td>' . $pro . '</td>'; } else { $page_index .= '<td>No</td>'; } $page_index .= '<td><a href="' . site_options('link') . 'admin/edit_page.php?page=' . $page['id'] . '">Edit</a> '; $alert = "'Are you sure you want to delete this page?'"; $page_index .= '/ <a href="' . site_options('link') . 'admin/delete_page.php?page=' . $page['id']; /*if($pro_id != 0){ $page_index .='&product='.$pro_id; }*/ $page_index .= '" onclick="return confirm(' . $alert . ');">Delete</a></td>'; $page_index .= '</tr>'; } $page_index .= '</table>'; $page_index .= $pagination['index']; return $page_index; }
function del_form($id) { global $connection; $query = "SELECT * FROM `forms` WHERE `id` = " . $id; $result = mysqli_query($connection, $query); $gall = mysqli_fetch_array($result); $query = "DELETE FROM `forms` WHERE `id` = {$id}"; $result = mysqli_query($connection, $query); confirm_query($result); $success = "Form was deleted!"; }
public function if_exist($sql) { $all_programmes = $this->db_query($sql); confirm_query($all_programmes); $rowexist = $this->dbNumRows($all_programmes); if ($rowexist >= 1) { return true; } else { return false; } }
function get_page_by_id($id) { global $conn; $query = "SELECT * FROM pages WHERE id={$id} LIMIT 1"; $page_set = mysql_query($query, $conn); confirm_query($page_set); if ($record = mysql_fetch_array($page_set)) { return $record; } else { return NULL; } }
function count_modele_by_day($day_no, $visible = 1) { global $connection; $safe_day_no = mysql_prep($day_no); $safe_visu = mysql_prep($visible); $query = "SELECT COUNT(*) AS c FROM programmed_courses_modele WHERE week_day_rank ={$safe_day_no} AND visible= {$safe_visu} "; $result = mysqli_query($connection, $query); confirm_query($result); $row = mysqli_fetch_assoc($result); return $row['c']; // }
function find_pages_for_subject($subject_id) { global $connection; $query = "SELECT * "; $query .= "FROM pages "; $query .= "WHERE visible = 1 "; $query .= "AND subject_id = {$subject_id} "; $query .= "ORDER BY position ASC"; $page_set = mysqli_query($connection, $query); confirm_query($page_set); return $page_set; }
function get_subjects_for_admin($count = false) { global $connection; if ($count == true) { $query = "SELECT COUNT(*) FROM page_subjects ORDER BY id ASC"; } else { $query = "SELECT * FROM page_subjects ORDER BY id ASC"; } $page_data = mysql_query($query, $connection); confirm_query($page_data); return $page_data; }
function find_pages() { //query for user by id global $connection; $query = "SELECT * "; $query .= "FROM pages "; $query .= "WHERE visible = 1 "; $query .= "ORDER BY position ASC"; $page = mysqli_query($connection, $query); confirm_query($page); return $page; }
function get_news($category_id, $public = true) { global $conn; //vrati sve iz tabele vijesti koji odgovaraju prosledjenoj kategoriji $query = "SELECT * FROM news WHERE category_id='{$category_id}'"; if ($public) { $query .= " AND visible=1"; } $result = mysqli_query($conn, $query); confirm_query($result); return $result; }
function updateUser($uname, $email, $password, $interests, $well_explained, $complete, $helpful, $good_examples) { global $connection; $query = "UPDATE user SET email = '{$email}', password = '******', interests = '{$interests}', recommendation_factor = '{$well_explained},{$complete},{$helpful},{$good_examples}' "; $query .= "WHERE uname = '{$uname}'"; echo $query; $result = mysqli_query($connection, $query); confirm_query($result); if (!$connection) { mysql_close($connection); } echo "end"; }