-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_institute_user.php
More file actions
71 lines (54 loc) · 1.77 KB
/
add_institute_user.php
File metadata and controls
71 lines (54 loc) · 1.77 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
67
68
69
70
71
<?php
/**
* File: add_institute_user.php
* Description: Adds new records to instrument_users table(s)
*
* @package StraboSpot Web Site
* @author Jason Ash <jasonash@ku.edu>
* @copyright 2025 StraboSpot
* @license https://opensource.org/licenses/MIT MIT License
* @link https://strabospot.org
*/
include("logincheck.php");
$userpkey = (int)$_SESSION['userpkey'];
include("prepare_connections.php");
$credentials = $_SESSION['credentials'];
if($userpkey != 3) exit();
include('includes/header.php');
if($_POST['submit'] != ""){
$institutionPkey = $_POST['institutionPkey'] ?? '';
if(!is_numeric($institutionPkey) || $institutionPkey == "") exit("No institute chosen.");
$institutionPkey = (int)$institutionPkey;
$email = strtolower(trim($_POST['email'] ?? ''));
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
exit("Invalid email format.");
}
$userpkey = $db->get_var_prepared("SELECT pkey FROM users WHERE email=$1", array($email));
if($userpkey == "") exit("User not found.");
$db->prepare_query("INSERT INTO instrument_users (users_pkey, institution_pkey) VALUES ($1, $2)", array($userpkey, $institutionPkey));
echo "User $email added to $facilityPkey<br><br>";
?>
<a href="/apparatus_users_admin">Continue</a>
<?php
exit();
}
$institutionRows = $db->get_results("select * from institute order by institute_name")
?>
<form method="POST">
Add User to Institute:<br><br>
<select name="institutionPkey">
<option value="">select...</option>
<?php
foreach($institutionRows as $row){
?>
<option value="<?php echo $row->pkey?>"><?php echo $row->institute_name?></option>
<?php
}
?>
</select><br><br>
Email: <input type="text" name="email"><br><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
include('includes/footer.php');
?>