-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsertq-action.php
More file actions
67 lines (62 loc) · 1.71 KB
/
Copy pathinsertq-action.php
File metadata and controls
67 lines (62 loc) · 1.71 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
<link href="style.css" rel="stylesheet" type="text/css" />
<div class="header">
<?php
error_reporting(0);
session_start();
include("connect.php");
$userId = $_SESSION['uid'];
//echo $userId;
if($_SESSION['user']=="")
{
//echo "Welcome Guest | <a href=login.php>Login</a> | <a href=register.php>Register</a> <br /><br />";
header("location:logout.php");
}
else
{
echo "Welcome <strong class=changecase>".$_SESSION['user']."</strong> | <a href=logout.php>Logout</a> | <a href=insert-topic.php>Insert Topic</a> <br /><br />";
}
?><a href="index.php"><strong>Home</strong></a>
<br />
</div>
<h3>Insert Topics</h3>
<?php
$in_topic = $_REQUEST['insert'];
//echo $itopic;
if ($in_topic == "itopic")
{//main topic
$topic = $_POST['topic'];
$muid = $_POST['muid'];
$sql = "select count(topic_name) from main_topic where topic_name='$topic'";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
//print_r($row);
if ($row[0] == "1")
{
echo "<div class=content>Topic already exists.</div>";
}
else
{
$sqli = insert("main_topic","topic_name,muid","'$topic','$muid'");
header("location:insert-topic.php");
}
}
else
{//sub topic
$smid = $_POST['smid'];
$stopic = $_POST['stopic'];
$suid = $_POST['suid'];
$sql = "select count(subTopic_name) from sub_topic where smid='$smid' and subTopic_name='$stopic'";
$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($result);
//print_r($row);
if ($row[0] == "1")
{
echo "<div class=content>Sub Topic already exists.</div>";
}
else
{
$sqli = insert("sub_topic","subTopic_name,smid,suid","'$stopic','$smid','$suid'");
header("location:insert-topic.php");
}
}
?>