Пример #1
0
<?php

session_start();
include "php/connect_to_mysql.php";
include "php/myFunctions.php";
$msg = "";
disableComponents();
$submit = $_POST['btnSearch'];
$submit1 = $_POST['btnUpdate'];
$submit2 = $_POST['btnDelete'];
$uid = $_GET['userid'];
if (!empty($uid) || isset($uid)) {
    selectUsersUsingId($uid);
    enableComponents();
}
if ($submit == "Search") {
    if (empty($_POST['txtUserId'])) {
        $msg = "User ID is empty!";
    } else {
        selectUsersUsingId($_POST['txtUserId']);
    }
} else {
    if ($submit1 == "Update") {
        mysql_query("update tblusers set fname= '{$_POST['txtFname']}', mname = '{$_POST['txtMname']}', lname = '{$_POST['txtLname']}', no_street = '{$_POST['txtNoStreet']}', city = '{$_POST['txtCity']}', contact_no = '{$_POST['txtContactNo']}', dob = '{$_POST['txtDOB']}', age = '{$_POST['txtAge']}', gender = '{$_POST['selGender']}' where user_id = '{$_POST['txtUserId']}'") or die(mysql_error());
        $msg = "Successfully updated the record!";
        disableComponents();
    } else {
        if ($submit2 == "Delete") {
            mysql_query("delete from tblusers where user_id = '{$_POST['txtUserId']}'") or die(mysql_error());
            mysql_query("delete from tblaccount where user_id = '{$_POST['txtUserId']}'") or die(mysql_error());
            $msg = "Successfully deleted the record!";
Пример #2
0
function selectUsersUsingId($uID)
{
    global $msg;
    global $userID;
    global $fname;
    global $mname;
    global $lname;
    global $noSt;
    global $city;
    global $contactNo;
    global $dob;
    global $age;
    global $gender;
    global $selectMaleGender;
    global $selectFemaleGender;
    $sqlSelUsers = mysql_query("select * from tblusers where user_id = '{$uID}'") or die(mysql_error());
    if (mysql_num_rows($sqlSelUsers) >= 1) {
        $getRowUser = mysql_fetch_array($sqlSelUsers);
        $userID = $getRowUser["user_id"];
        $fname = $getRowUser["fname"];
        $mname = $getRowUser["mname"];
        $lname = $getRowUser["lname"];
        $noSt = $getRowUser["no_street"];
        $city = $getRowUser["city"];
        $contactNo = $getRowUser["contact_no"];
        $dob = $getRowUser["dob"];
        $age = $getRowUser["age"];
        $gender = $getRowUser["gender"];
        if ($gender == "Male") {
            $selectMaleGender = "selected";
        } else {
            if ($gender == "Female") {
                $selectFemaleGender = "selected";
            }
        }
        enableComponents();
    } else {
        $msg = "No record found!";
        disableComponents();
    }
}