View file setting/update.php

File size: 2.46Kb
<?php
include_once "../config.php";
include_once "../inc/inc.php";
include_once "../inc/func.php";
include_once "../inc/user.php";
// include_once "../themes/$theme/index.php";
$id = (int)$id;
if ($id == 0) {
    echo'Произошла ошибка. <a href="/index.php">Главная</a>';
    include_once "../themes/$theme/foot.php";
    exit;
} 
$query = "SELECT id FROM " . $pref . "useres WHERE id=" . $id;
$res = mysql_query($query);
$res = implode(mysql_fetch_array($res, MYSQL_ASSOC));
if ($res == '') {
    echo 'Произошла ошибка. <a href="/index.php">Главная</a>';
    include_once "../themes/$theme/foot.php";
    exit;
} 
if (($id != $idid) || ($kto != 'user')) {
    echo 'Произошла ошибка. <a href="/index.php">Главная</a>';
    include_once "../themes/$theme/foot.php";
    exit;
} 

if ($act == 'name') {
    $imia = htmlspecialchars(stripslashes($imia));
    if (!ereg("[А-Яа-я]{3,20}", $imia)) {
        header("Location: anketa.php?badname&id=" . $id);
        exit;
    } 
    $query = 'UPDATE ' . $pref . 'useres SET name="' . $imia . '" WHERE id=' . $id;
    mysql_query($query) or die ('ERROR');
    header("Location: anketa.php?id=" . $id);
    exit;
} 

if ($act == 'city') {
    $city = htmlspecialchars(stripslashes($city));
    if (!ereg("[А-Яа-я]{3,20}", $city)) {
        header("Location: anketa.php?badcity&id=" . $id);
        exit;
    } 
    $query = 'UPDATE ' . $pref . 'useres SET city="' . $city . '" WHERE id=' . $id;
    mysql_query($query) or die ('ERROR');
    header("Location: anketa.php?id=" . $id);
    exit;
} 

if ($act == 'email') {
    $email = htmlspecialchars(stripslashes($email));
    if (!eregi("^[a-z0-9\._-]+@[a-z0-9\._-]+\.[a-z]{2,4}\$", $email)) {
        header("Location: anketa.php?bademail&id=" . $id);
        exit;
    } 
    $query = 'UPDATE ' . $pref . 'useres SET email="' . $email . '" WHERE id=' . $id;
    mysql_query($query) or die ('ERROR');
    header("Location: anketa.php?id=" . $id);
    exit;
} 

if ($act == 'icq') {
    $icq = htmlspecialchars(stripslashes($icq));
    if (!ereg("[0-9]{5,12}", $icq)) {
        header("Location: anketa.php?badicq&id=" . $id);
        exit;
    } 
    $query = 'UPDATE ' . $pref . 'useres SET icq="' . $icq . '" WHERE id=' . $id;
    mysql_query($query) or die ('ERROR');
    header("Location: anketa.php?id=" . $id);
    exit;
} 
// include_once "../themes/$theme/foot.php";
?>