-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.php
More file actions
38 lines (35 loc) · 1.06 KB
/
database.php
File metadata and controls
38 lines (35 loc) · 1.06 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
<?php
session_start();
if(!$_SESSION['username']){
header("location:login.php");
}
$conn=mysqli_connect("localhost",$_SESSION['sqluser'],$_SESSION['sqluser'],$_SESSION['dbname'])or die("cannot connect");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Welcome <?php echo $_SESSION["username"]?></title>
<link href="scripts/bootstrap.css" rel="stylesheet" type="text/css" media="all">
</head>
<body>
<h3>use the text area to type your query and execute</h3>
<form method="post" action="">
<textarea name="sql" id="sql" rows="5" cols="50"></textarea>
<input class="btn btn-danger" type="submit" value="execute"/>
</form>
<?php
echo "<h5>";
if(isset($_POST['sql'])){
$sql=$_POST['sql'];
$result=mysqli_query($conn,$sql);
if($result){
echo "query executed successfully";
}
$_POST['sql']="";
}
echo "</h1>";
?>
</body>
</html>