<?php

require_once "../../../../include/config.php";
$userId = 1;
$currentUser = selectById('tblusers', $userId)[0];
?>
<h4 class="">Update</h4>

<fieldset>
    <div class="form-group input-group">
                      <span class="input-group-addon">
                          <span class="fa fa-user-md"></span>
                      </span>
        <input class="form-control" placeholder="<?php 
echo $currentUser['userName'];
?>
" name="username" type="text"
               required="required" id="txtUsername">
    </div>
    <div class="form-group input-group">
                      <span class="input-group-addon">
                            <span class="fa fa-envelope"></span>
                      </span>
        <input class="form-control" placeholder="<?php 
echo $currentUser['userEmail'];
?>
" name="userEmail" type="email"
               required="required" autofocus="" id="txtUserEmail">
    </div>
    <div class="form-group">
        <button type="submit" class="btn btn-info btn-block" id="updateUsernameEmail">UPDATE
Example #2
0
<?php

require_once "include/config.php";
session_start();
$validUserId = $_SESSION["validUserId"] = 1;
$validUser = selectById('tblusers', $validUserId)[0];
?>
<!DOCTYPE html>
<html lang="fa">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title>AsreMajazi CMS</title>
</head>
<body>
<div id="wrapper">
    <!-- Sidebar -->
    <div id="sidebar-wrapper">
        <a href="index.php">WebSiteName</a>
        <div class="avatar">
            <img src="<?php 
echo "include/uploads/" . $validUser['userPic'];
?>
" width="80" height="80"
                 class="img-responsive img-circle"/>
        </div>
        <li data-toggle="collapse" href="#collapseExample" aria-expanded="false"
            aria-controls="collapseExample">
Example #3
0
 * @package Example-application
 */
require './settings.php';
if (!empty($_POST)) {
    $id = isset($_POST['id']) ? $_POST['id'] : '';
    $currads = selectAll();
    if (isset($_GET['action']) && $_GET['action'] == 'update' && isset($currads[$id])) {
        $data = prepareData($_POST);
        updateInDb($id, $data);
    } else {
        $data = prepareData($_POST);
        insertToDb($data);
    }
} elseif (isset($_GET['del'])) {
    deleteFromDb((int) $_GET['del']);
} elseif (isset($_GET['edit']) && !isset($_GET['action'])) {
    $data = selectById($_GET['edit']);
    $formParam = prepareData($data);
}
if (!isset($formParam)) {
    $formParam = prepareData();
}
$cities = get_cities();
$categories = get_categories();
$ads = selectAll();
$smarty->assign("cities", $cities);
$smarty->assign("categories", $categories);
// assoc array group => array
$smarty->assign("formParam", $formParam);
$smarty->assign("allads", $ads);
$smarty->display('index.tpl');
Example #4
0
    $stmt->bind_param('i', $id);
    $stmt->execute();
    echo $stmt->affected_rows;
    $stmt->free_result();
    $stmt->close();
}
try {
    $host = 'localhost';
    $dbname = 'testrest';
    $user = '******';
    $password = '******';
    $db = new mysqli($host, $user, $password, $dbname);
    switch ($_SERVER['REQUEST_METHOD']) {
        case 'GET':
            if (isset($_GET['id'])) {
                selectById($db, $_GET['id']);
            } else {
                selectAll($db);
            }
            break;
        case 'POST':
            $data = json_decode(file_get_contents("php://input"));
            insert($db, $data);
            break;
        case 'PUT':
            if (isset($_GET['id'])) {
                $data = json_decode(file_get_contents("php://input"));
                update($db, $_GET['id'], $data);
            }
            break;
        case 'DELETE':