Beispiel #1
0
            $validation->display_validation_errors();
        }
    }
}
/* Mozda dodati link da moze i obrisati account? ...
        <!-- <input type="submit" name="btnDelete" value="Delete account"/> -->
*/
?>
<form id='user_edit' action='' method='post' accept-charset='UTF-8'>
    <fieldset>
        <legend>Edit your profile</legend>
        <input type='hidden' name='submitted' id='submitted' value='1'/>

        <label for='name'>Name: </label>
        <input type='text' name='name' id='name' value=<?php 
echo $user->__get('name');
?>
 maxlength="40"/><br>
        <br>
        <label for='name'>Surname: </label>
        <input type='text' name='surname' id='surname' value=<?php 
echo $user->__get('surname');
?>
 maxlength="40"/><br>
        <br>
        <label for='email'>Email: </label>
        <input type='email' name='email' id='email' value=<?php 
echo $user->__get('email');
?>
 maxlength="50"
               required/><br>
Beispiel #2
0
session_start();
// id of photo not set
if (!isset($_GET['id'])) {
    header('Location: index.php');
}
if (!empty($_POST['submitted'])) {
    $rules = array();
    $rules['comment_data'] = 'required|length[500]';
    $validation = new \validation_library\FormValidation();
    $validation->set_rules($rules);
    $allGood = $validation->validate();
    if ($allGood) {
        $query = \db\DAO::getInstance()->prepare("INSERT INTO Comments(image_id, user_id,\n        username, comment_data) VALUES (?,?,?,?)");
        $user = new \models\Korisnik();
        $user->load($_SESSION['user_id']);
        if ($query->execute([$_GET['id'], $_SESSION['user_id'], $user->__get('username'), htmlentities($_POST['comment_data'])])) {
            $page = 'aboutPicture.php?id=' . $_GET['id'];
            header('Location: ' . $page);
            exit;
        } else {
            echo "Username must be unique";
        }
        //  exit;
    } else {
        echo "Comment cannot be empty.";
    }
}
\db\DAO::getConnection()->addVisit($_GET['id']);
//page rendering
$page = new html_library\HTMLHtmlElement();
$page->add_child(new html_library\HTMLHeadElement());