-
Notifications
You must be signed in to change notification settings - Fork 0
/
editSubject2.php
48 lines (43 loc) · 1.03 KB
/
editSubject2.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
<?php
if(!isset($_SESSION))
{
session_start();
}
include_once("config.php");
if((isset($_GET["type"])) && $_GET["type"]=="del")
{
$subject_id = $_GET["subject_id"];
$q2 = mysql_query("delete from subjects where subject_id = '$subject_id';");
if($q2)
{
$_SESSION["Msg"] = "Subject deleted successfully";
}
else
{
$_SESSION["Msg"] = "Error occured.".mysql_error();
}
}
else
{
$subject_id = $_POST["subject_id"];
$subject_name= $_POST["subject_name"];
$q1 = mysql_query("select * from subjects where subject_name='$subject_name' and subject_id != '$subject_id';");
if(mysql_num_rows($q1)==0)
{
$q2 = mysql_query("update subjects set subject_name='$subject_name' where subject_id = '$subject_id';");
if($q2)
{
$_SESSION["Msg"] = "Subject updated successfully";
}
else
{
$_SESSION["Msg"] = "Error occured.".mysql_error();
}
}
else
{
$_SESSION["Msg"] = "Subject name already exists";
}
}
header("Location: addSubject.php");
?>