<?php require '../classes/db.php'; require '../classes/validate.php'; $vl = new Validate(); $db = new Database(); $db->connect(); if (isset($_POST['user']) && isset($_POST['pass1'])) { $user = $vl->test_input($_POST['user']); $pass = $vl->test_input($_POST['pass1']); if (!empty($user) && !empty($pass)) { $query = sprintf("\n\t\tSELECT * \n\t\tFROM signup \n\t\tWHERE user = '******' AND password = '******'\n\t\t LIMIT 1;", $db->mysqli_escape($user), $db->mysqli_escape(md5($pass))); $result = $db->selectdata($query); if (mysqli_num_rows($result) == 1) { $row = mysqli_fetch_array($result); $_SESSION['user'] = $user; $_SESSION['id'] = $row['id']; $_SESSION['proimg'] = $row['imgname']; header('Location:../profile/user.php'); } else { $_SESSION['warning'] = 'no such user'; header('Location:../register/login.php'); } } else { $_SESSION['warning'] = 'cant leave empty'; header('Location:../register/login.php'); } } else { die('Error'); }
<?php require '../classes/db.php'; $db = new Database(); $db->connect(); if (isset($_POST['username'])) { $username = $_POST['username']; $sql_check = "select id from signup where user='******'"; $result = $db->selectdata($sql_check); if (mysqli_num_rows($result)) { echo '<font color="red">The nickname <STRONG>' . $username . '</STRONG> is already in use.</font>'; } else { echo 'OK'; } }
<?php require '../classes/validate.php'; require '../classes/db.php'; $vl = new Validate(); $db = new Database(); $db->connect(); if (isset($_POST['pass1']) && isset($_POST['pass2']) && isset($_POST['prev'])) { $prev = $vl->test_input($_POST['prev']); $pass1 = $vl->test_input($_POST['pass1']); $pass2 = $vl->test_input($_POST['pass2']); if (!empty($prev) && !empty($pass1) && !empty($pass2)) { $query1 = sprintf("\n\t\tSELECT * \n\t\tFROM signup \n\t\tWHERE user = '******' AND password = '******'\n\t\t LIMIT 1;", $db->mysqli_escape($_SESSION['user']), $db->mysqli_escape(md5($prev))); $res = $db->selectdata($query1); if (!mysqli_num_rows($res) == 1) { $_SESSION['wrong'] = 'Invalid Current Password'; header('Location:../profile/edit_profile.php'); } if ($vl->valid_password($pass1, $pass2)) { $query = sprintf("UPDATE `signup` SET `password`='%s' WHERE id =%d; ", md5($pass1), $_SESSION['id']); if ($result = $db->insertquery($query)) { $_SESSION['pass_update'] = 'Password Changed'; header('Location:../profile/edit_profile.php'); } else { die('Error'); } } else { die('Error'); } } }
<?php require '../classes/db.php'; $db = new Database(); $db->connect(); //fetch table rows from mysql db $sql = "select * from event"; $result = $db->selectdata($sql); //create an array $emparray = array(); while ($row = mysqli_fetch_assoc($result)) { $emparray[] = $row; } echo json_encode($emparray); $fp = fopen('../jsonelement/empdata.json', 'w'); fwrite($fp, json_encode($emparray)); fclose($fp);