-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddUser.php
54 lines (47 loc) · 1.45 KB
/
AddUser.php
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
error_reporting(E_ALL);
ini_set('display_errors','On');
if(!isset($_POST['submit'])){
echo '<form method="post">';
echo '<h2> USER REGISTRATION FORM </h2><br/>';
echo 'Username:<input type="text" name="uname"/><br/>';
echo 'Password:<input type="password" name="pass"/><br/>';
echo 'FullName:<input type="text" name="Fullname"/><br/>';
echo 'Email: <input type="text" name="email"/></br>';
echo '<input type="submit" name="submit" value="Submit">';
echo '</form>';
}
else{
try{
$dbname = dirname($_SERVER["SCRIPT_FILENAME"]) . "/mydb.sqlite";
// echo $dbname;
$dbh = new PDO("sqlite:$dbname");
$dbh->beginTransaction();
$uname = $_POST['uname'];
echo $uname;
$pass1 = $_POST['pass'];
$pas=md5($pass1);
echo $pass;
$fullname = $_POST['Fullname'];
// echo $fullname;
$email = $_POST['email'];
// echo $email;
if(isset($_POST['submit'])){
$dbh->exec("INSERT INTO users(username,password,fullname,email) VALUES('$uname','$pas', '$fullname',' $email')");
echo " Added successfully";
header("Location: board.php");
}
$dbh->commit();
$stmt = $dbh->prepare('select * from users');
$stmt->execute();
print "<pre>";
while ($row = $stmt->fetch()) {
print_r($row);
}
print "</pre>";
}catch(PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
}
<?php