-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.php
More file actions
58 lines (51 loc) · 1.51 KB
/
process.php
File metadata and controls
58 lines (51 loc) · 1.51 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
<?php
// include 'database.php';
session_start();
//create a variable
$uname = (htmlspecialchars($_POST['username']));
$filename = (htmlspecialchars($_POST['filename']));
$contents = (htmlspecialchars($_POST['content']));
$flag = 1;
// $content = "<script></script>";
// echo "$contents";
$connect=mysqli_connect('localhost:3307','root','','mydatabase');
if ($connect === false) {
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$result = mysqli_query($connect,"SELECT * FROM iit") or die (mysql_error());
$row = mysqli_fetch_array($result);
// echo $row['uname'];
while ($row = mysqli_fetch_array($result)) {
if($row['uname'] == $uname && $row['filename'] == $filename)
{
echo "Error : Similiar Filename and Usernames Exists";
// echo "TSTART \n";
// echo "<script>console.log('asasa');</script>";
// echo "<script>toastr.error('The username and password do not match.', 'Load Failed!');</script>";
// echo "yo";
$flag = 2;
$_SESSION['repeat'] = $flag;
header('Location: index.php');
break;
}
}
if($flag == 1)
{
mysqli_query($connect,"INSERT INTO iit (uname, filename, contents)
VALUES ('$uname','$filename','$contents');");
if(mysqli_affected_rows($connect) > 0){
echo "<p>Form Added</p>";
echo $contents;
$flag = 1;
$_SESSION['repeat'] = $flag;
header('Location: index.php');
} else {
echo "Form NOT Filled<br />";
echo mysqli_error ($connect);
echo "<a href='index.php'>Go Back</a>";
}
}
// print_r($_POST);
// echo $_POST['first_name'];
// echo '<br />';
// echo $_POST['emailid'];