-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddNew.php
More file actions
55 lines (45 loc) · 1.19 KB
/
addNew.php
File metadata and controls
55 lines (45 loc) · 1.19 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
<?php
if (isset($_POST['file'])){
$file = $_POST['file'];
}
else{
$file = 'test3';
}
/*
//Localhost
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "root";
$dbname = "CodeSharing";
$port = 3308;
*/
//AWS for Heroku
$dbhost = "sulnwdk5uwjw1r2k.cbetxkdyhwsb.us-east-1.rds.amazonaws.com";
$dbuser = "k22qr254pzknzhib";
$dbpass = "rwzwygqrxexbnl6x";
$dbname = "lrqf9g5qj2a9xm0i";
$port = 3306;
$connection = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname, $port);
// $connection = mysqli_connect("localhost", "root", "root", "CodeSharing");
if (!$connection) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
date_default_timezone_set("UTC");
$timestamp = date('Y-m-d G:i:s');
$sql = "INSERT INTO ".$dbname.".currentFiles (fileName, lastEdited, text) VALUES ('".$file."', '".$timestamp."', '//Work on your code here!')";
$result = mysqli_query($connection, $sql);
//$row_cnt = mysqli_num_rows($result);
$exists = 'false';
if($result){
$status = 'ok';
}
else{
$status = 'error';
}
mysqli_close($connection);
?>
<div id='result'><?php echo($status); ?>
</div>