View sourcecode

The following files exists in this folder. Click to view.

insertUser.php

26 lines UTF-8 Unix (LF)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
error_reporting
(E_ALL);
ini_set('display_errors'1);

require_once(
'check_login.php');
require_once(
'database_connection.php');

$username htmlentities(trim($_POST['username']));
$password sha1(trim($_POST['password']));
$active   1;

$sql "INSERT INTO user1 (username, password, active) 
        VALUES (:username, :password, :active);"
;

$stm $pdo->prepare($sql);
$stm->execute(array(
    
'username' => $username,
    
'password' => $password,
    
'active'   => $active
));

$lastID $pdo->lastInsertID();

header("location: admin.php?mess=En användare med id: $lastID har skapats.");
exit;