-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathadd_new_user_process.php
More file actions
executable file
·66 lines (52 loc) · 1.96 KB
/
add_new_user_process.php
File metadata and controls
executable file
·66 lines (52 loc) · 1.96 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
<?php
session_start();
include_once("dbconnect.php");
echo crypt(md5($password));
$username=isset($_POST['username']) ? trim($_POST['username']) : "";
$password=isset($_POST['password']) ? md5($_POST['password']) : "";
$name=isset($_POST['name']) ? trim($_POST['name']) : "";
if($username=="" || $password=="" || $name=="")
{
$_SESSION['message']="Please Input Your Details";
$_SESSION['messagetype']="errormessage";
header("location: add_new_user.php");
exit();
}
$select_user=mysql_query("select * from users where(username='$username')");
if($select_user==FALSE)
{
$_SESSION['message']="Error encourted accessing user information!" .mysql_error();
$_SESSION['messagetype']="errormessage";
header("location: add_new_user.php");
exit();
}
$total_users=mysql_num_rows($select_user); //Get the total Numebr of Records Returnd.
if($total_users>0)
{
$_SESSION['message']="This username ($username) already exist. please enter a different username! ";
$_SESSION['messagetype']="errormessage";
header("location: add_new_user.php");
exit();
}
$insert_rec=mysql_query("insert into users set username='$username', password='$password', name='$name'");
if($insert_rec==FALSE)
{
$_SESSION['message']="Error Encounterd adding user information! " .mysql_error();
$_SESSION['messagetype']="errormessage";
header("location: add_new_user.php");
exit();
}
$_SESSION['message']="User ($username) has been succesfully added.";
$_SESSION['messagetype']="sucessmessage";
header("location: manage_users.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
</body>
</html>