-
Notifications
You must be signed in to change notification settings - Fork 0
/
Data-Edit.php
156 lines (141 loc) · 6.06 KB
/
Data-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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
session_start();
$servername = "shareddb-u.hosting.stackcp.net";
$username = "DBMSPROJECT-31333374d5";
$password = "DBMSPROJECT@";
$con=mysqli_connect($servername,$username,$password,"DBMSPROJECT-31333374d5");
$title=$_GET["title"];
$result=mysqli_query($con,"SELECT * FROM datatable where title='".$title."' and password='".$_SESSION["password"]."' ");
$string="";
$count = 0;
if($result){
$row=mysqli_fetch_array($result);
$count= $row["counter"]+1;
if(isset($row)){
for($i=0;$i<strlen($row["data"]);$i++){
$string=$string.$row['data'][$i];
}
$result1=mysqli_query($con,"UPDATE datatable SET counter='".$count."' where title='".$title."' and password='".$_SESSION["password"]."' ");
}
else{
}
}
else{
}
$val=1;
$title1="";
if(isset($_POST["edit"])){
$data=mysqli_real_escape_string($con,$_POST["data"]);
$final=strval($data);
if((($_POST["title"]))!=null){
$title1=$_POST["title"];
}
else{
$title1=$title;
}
$result=mysqli_query($con,"UPDATE datatable SET data='".$final."' , title='".$title1."' where title='".$title."' and password='".$_SESSION["password"]."' ");
if($result==$val){
echo '<script type="text/JavaScript">
alert("Your file is Edited!");
</script>';
echo "<script>window.location.href='AllCodes.php';</script>";
}
}
else{
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Codeditor</title>
<link href="https://fonts.googleapis.com/css2?family=Jost:wght@500&display=swap" rel="stylesheet">
<script type="text/javascript" src="jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script>
</head>
<style class="text/css">
.nav-item{
margin-left: 20px;
}
</style>
<body>
<form method="post">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark sticky-top">
<a class="navbar-brand" href="#"><img src="https://cdn1.iconfinder.com/data/icons/seo-icons-5/96/Coding-512.png" width="40px" style="margin-right: 15px;">Code Collector</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="Dashboard.php">Dashboard <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item ">
<a class="nav-link" href="AllCodes.php">All Repository</a>
</li>
<li class="nav-item">
<a class="nav-link" href="About.php">About</a>
</li>
<li class="nav-item ">
<a class="nav-link" href="Setting.php">Settings </a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
More
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="index.php">Log out</a>
</div>
</li>
</ul>
</div>
</nav>
<div class="d-flex justify-content-center" >
<div class="alert" style="width:800px;" role="alert">
<h3 class="alert-heading">View your Data</h3>
<p>A repository will contain your file.</p>
<hr>
<p class="mb-0"></p>
</div>
</div>
<div class="d-flex justify-content-center" style="margin-top: -20px;">
<input class="form-control" type="text" style="width:750px;" placeholder="<?php
$result=mysqli_query($con,"SELECT name FROM signup1 where email='".$_SESSION["email"]."' and password='".$_SESSION["password"]."' ");
if($result){
$row=mysqli_fetch_array($result);
echo '@'.$row[0];
}
?>" readonly>
</div>
<div>
<div class="d-flex justify-content-center">
<div class="form-row" style="margin-top: 10px;">
<div>
<label for="validationServer03">File Name</label>
<input class="form-control" type="text" name="title" style="width:750px; margin-bottom: 10px;" placeholder="<?php
echo $title;?>
" >
</div>
</div>
</div>
<div class="d-flex justify-content-center">
<div class="form-group">
<label for="exampleFormControlTextarea1">Your Data</label>
<textarea class="form-control" name="data" style="width:750px;" id="exampleFormControlTextarea1" rows="20" required ><?php
echo $string;
?>
</textarea>
</div>
</div>
<div class="d-flex justify-content-center">
<button type="submit" name="edit" id="edit" style="margin-bottom: 10px;width:750px;" class="btn btn-dark">Edit the Code</button>
</div>
<div class="d-flex justify-content-center">
<a href="Dashboard.php"><button type="button" style="width:750px;margin-bottom: 50px;" class="btn btn-dark">Go to HomePage</button></a>
</div>
</form>
</body>
</html>