-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathphpaddblog.php
More file actions
52 lines (39 loc) · 1.09 KB
/
phpaddblog.php
File metadata and controls
52 lines (39 loc) · 1.09 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
<?php
session_start();
?>
<html>
<body>
<?php
$con = mysql_connect("mysql-user-master.stanford.edu", "ccs147strand14", "faexeepi");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("c_cs147_strand14", $con);
$url=$_POST["blog-url"];
$indicator=$_POST["indicator"];
$username=$_SESSION["user"];
$query = "SELECT * FROM associations WHERE username='$username' AND url='$url'";
$result = mysql_query($query);
$count = mysql_num_rows($result);
if($count == 1){
echo "<script type='text/javascript'>
window.alert('You already added this blog!')
</script>";
} else {
$sql= "INSERT INTO associations (username, url) VALUES ('$username', '$url')";
$retval=mysql_query($sql, $con);
echo "<script type='text/javascript'>
window.alert('Blog Added!')
</script>";
}
if ($indicator == 'blogs')
$returnurl = 'myblogs.php';
if ($indicator == 'discover')
$returnurl = 'discover.php';
if ($indicator == 'stream')
$returnurl = 'streamview.php';
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$returnurl.'">';
?>
</body>
</html>