-
Notifications
You must be signed in to change notification settings - Fork 1
/
add_user.php
65 lines (49 loc) · 1.6 KB
/
add_user.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
55
56
57
58
59
60
61
62
63
64
65
<?php
$host="localhost";
$db_name="emr_system";
$table_name="members";
mysql_connect("$host", "root", "")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$upload_dir='image/';
$target_file =$upload_dir . basename($_FILES['fileToUpload']['name']);
$tmp_name = $_FILES["fileToUpload"]["tmp_name"];
$name = $_FILES["fileToUpload"]["name"];
move_uploaded_file($tmp_name, "$upload_dir/$name");
$username = $_POST['username'];
$pass = $_POST['password'];
$type = $_POST['type'];
$ic = $_POST['ic'];
$phonenumber = $_POST['phonenumber'];
$email = $_POST['email'];
$gender = $_POST['gender'];
$doctorname = $_POST['drname'];
$specility = $_POST['special'];
$picture = $target_file;
$password = sha1($pass);
$form_data = array(
'userId' => NULL,
'username' => $username,
'password' => $password,
'type' => $type,
'ic' => $ic,
'phoneNo' => $phonenumber,
'email' => $email,
'gender' => $gender,
'doctorName' => $doctorname,
'speciality' => $specility,
'picture' => $picture ,
);
function dbRowInsert($table_name, $form_data)
{
$fields = array_keys($form_data);
$sql = "INSERT INTO ".$table_name." (`".implode('`,`', $fields)."`)VALUES('".implode("','", $form_data)."')";
$sqlresult = mysql_query($sql);
echo "<script type='text/javascript'>
window.alert('New Profile successfully created!');
window.location.href = 'main1.php';
</script>";
return $sqlresult;
}
mysql_select_db("$db_name");
dbRowInsert('members',$form_data);
?>