-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtutor_edit.php
100 lines (77 loc) · 2.42 KB
/
tutor_edit.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php include("session_start.php"); ?>
<?php include("tutor_authenticate.php"); ?>
<?php
// form submited code
if(isset($_POST['tutor_id']))
{
include('db_connection.php');
$sql = "UPDATE tutor SET " .
" login = '" . $_POST['login'] .
"', password = '" . $_POST['password'] .
"', name = '" . $_POST['name'] .
"' WHERE tutor_id = " . $_POST['tutor_id'] . " LIMIT 1;";
//echo '<br />sql = ' . $sql . '<br />';
//exit;
if(!mysqli_query($sql))
{
if(mysqli_errno() == 1062) // rec exists
{
//print 'Record already exists for "' . $_REQUEST['txtFullName'] . '"';
$_SESSION['msg'] = 'Record already exists with this login: ' . $_POST['login'];}
else
{
$_SESSION['msg'] = mysqli_errno() . '<br />Error: ' . mysqli_error();
}
} // if(!mysqli_query($sql))
else
{
$_SESSION['msg'] = 'Record updated successfully.';
}
$_GET['tutor_id'] = $_POST['tutor_id'];
//mysqli_close($con);
//echo "<br>end";
}
// else code
if(isset($_GET['tutor_id']))
{
include('db_connection.php');
$sql = 'SELECT * FROM tutor WHERE tutor_id = ' . $_GET['tutor_id'];
$result = mysqli_query($sql);
//echo '<br />sql = ' . $sql . '<br />';
//exit;
$row = mysqli_fetch_array($result);
//mysqli_close($con);
//echo "<br>end";
}
?>
<?php include("top.php"); ?>
<?php include("tutor_submenu.php"); ?>
<div id="contenttext">
<div style="padding:10px">
<span class="titletext">Edit Tutor</span> </div>
<div class="bodytext" style="padding:12px;" align="justify">
<strong>Edit Tutor</strong>
<p>Here we will edit Tutor.</p>
<table align="center" border="1">
<form action="tutor_edit.php" method="post">
<tr>
<td><strong>tutor ID:</strong> </td>
<td>
<?php echo $row['tutor_id'];?>
<input type="hidden" name="tutor_id" value="<?php echo $row['tutor_id'];?>" />
</td>
</tr>
<tr><td><strong>Login:</strong> </td><td><input type="text" name="login" value="<?php echo $row['login'];?>" /> </td></tr>
<tr><td><strong>Password:</strong> </td><td><input type="password" name="password" value="<?php echo $row['password'];?>" /> </td></tr>
<tr><td><strong>Name:</strong> </td><td><input type="text" name="name" value="<?php echo $row['name'];?>" /> </td></tr>
<tr><td align="center">
<input type="button" value="Back" onclick="location.href = 'tutor_main.php';"/>
</td><td align="center" />
<input type="submit" value="Update" />
<input type="reset" />
</td></tr>
</form>
</table>
</div>
</div>
<?php include("bottom.php"); ?>