Esempio n. 1
0
<?php

require_once '../contact_model.php';
require_once '../validator.php';
$contact = new Contact_model();
$contact->table = 'contacts';
$validator = new Validator();
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    $con_id = $validator->cleanData($_GET['con_id']);
    $sql = "SELECT * FROM contacts WHERE id={$con_id}";
    $result = $contact->select($sql);
}
if (!empty($result)) {
    $result = $result[0];
}
echo json_encode($result);
Esempio n. 2
0
<?php

require_once '../contact_model.php';
require_once '../validator.php';
$contact = new Contact_model();
$contact->table = 'contacts';
$validator = new Validator();
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    $con_id = $validator->cleanData($_GET['con_id']);
    $sql = "SELECT * FROM contacts WHERE id={$con_id}";
    $result = $contact->select($sql);
}
if (!empty($result)) {
    $result = $result[0];
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $username = $validator->cleanData($_POST['username']);
    $phone = $validator->cleanData($_POST['phone']);
    $email = $validator->cleanData($_POST['email']);
    $con_id = $validator->cleanData($_POST['con_id']);
    $updated = $contact->update($con_id, $username, $phone, $email);
    echo json_encode(['updated' => $updated]);
    exit;
}
?>

<!doctype html>
<html>
	<head>
		<title>Index page</title>
		<meta charset="utf-8">
Esempio n. 3
0
<?php

require_once '../contact_model.php';
require_once '../validator.php';
$contact = new Contact_model();
$contact->table = 'contacts';
$validator = new Validator();
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    $con_id = $validator->cleanData($_GET['con_id']);
    $deleted = $contact->delete_where($con_id);
    echo json_encode(['deleted' => $deleted]);
}
Esempio n. 4
0
<?php

require_once 'contact_model.php';
require_once 'validator.php';
$contact = new Contact_model();
$contact->table = 'contacts';
$validator = new Validator();
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $username = $validator->cleanData($_POST['username']);
    $phone = $validator->cleanData($_POST['phone']);
    $email = $validator->cleanData($_POST['email']);
    $currentURL = $validator->cleanData($_POST['currentURL']);
    $inserted = $contact->insert($username, $phone, $email, $currentURL);
    echo json_encode(['inserted' => $inserted]);
}
Esempio n. 5
0
<?php

require_once '../contact_model.php';
$contact = new Contact_model();
$contact->table = 'contacts';
$contacts = $contact->select();
?>

<!doctype html>
<html>
	<head>
		<title>Index page</title>
		<meta charset="utf-8">
		<link href="../../css/main.css" rel="stylesheet">
		<script type="text/javascript">
			function deleteContact(){}
			function editContact(){}
		</script>
	</head>
	<body>
		<div id="wrapper">
			<h1>Редкатировать контакты</h1>
			<table class="bordered">
			<thead>
				<tr>
					<th>Имя пользователя</th>
					<th>Номер телефона</th>
					<th>Email адресс</th>
					<th>URL</th>
					<th>Редкатировать</th>
				</tr>