<?php ini_set('display_errors', 'On'); error_reporting(E_ALL); $db_array = ""; #print header(css pages will differ), top (same for all pages), middle(diff for every page), footer(same for all) print_header('./Home.css'); readfile('./top.html'); print_middle($db_array); readfile('./footer.html'); function print_header($css) { $script = $_SERVER['PHP_SELF']; $html_string = ""; print <<<PAGE1 <!DOCTYPE html> <html> <head> \t<title>The Down Low</title> \t<link rel = "stylesheet" title = "basic style" type = "text/css" \thref = "{$css}" /> \t<link href='https://fonts.googleapis.com/css?family=Ubuntu:400,500' rel='stylesheet' type='text/css'> </head> PAGE1; } function print_middle($db_array) { print <<<Middle \t\t<div id="middle"> \t\t\tThis website is for people to post rants/confessions anonymously. There will also be a comment feature and an upvote feature for every post. Users can sort posts by popularity or by time.
#$user = $_COOKIE["username"]; $user = "******"; $title = $_POST["title"]; $comment = $_POST["comment"]; $stmt = mysqli_prepare($connect, "INSERT INTO comments VALUES (?, ?, ?, ?)"); mysqli_stmt_bind_param($stmt, 'ssss', $user, $title, $comment, $today2); mysqli_stmt_execute($stmt); mysqli_stmt_close($stmt); } else { $posted = "<br>Comment Title<br> \n\t<input type='text' name='title'></input><br><br> Comment<br>\n<textarea rows='8' cols='60' name ='comment'> </textarea><br>\n\t<button onclick='calc()' id='send' style='margin-right: 10px;'>Submit</button>"; } $db_array = connect($connect); #print header(css pages will differ), top (same for all pages), middle(diff for every page), footer(same for all) print_header('./Home.css'); readfile('./top.html'); print_middle($db_array, $posted); readfile('./footer.html'); function connect($connect) { if (empty($connect)) { print 'fail'; die("mysqli_connect failed: " . mysqli_connect_error()); } $table = "comments"; $result = mysqli_query($connect, "SELECT * from {$table}"); $array_final = array(); while ($row = $result->fetch_row()) { $array_row = array($row[0], $row[1], $row[2], $row[3]); array_push($array_final, $array_row); } $result->free();
<?php print_header('./Home.css'); readfile('./top.html'); print_middle(); readfile('./footer.html'); function print_header($css) { $script = $_SERVER['PHP_SELF']; $html_string = ""; print <<<PAGE1 <!DOCTYPE html> <html> <head> \t<title>The Down Low</title> \t<link rel = "stylesheet" title = "basic style" type = "text/css" \thref = "{$css}" /> \t<link href='https://fonts.googleapis.com/css?family=Ubuntu:400,500' rel='stylesheet' type='text/css'> </head> PAGE1; } function print_middle($db_array) { print <<<Middle \t\t<div id="middle"> <h3>Make new Account</h3> \t\t\t<table align="" width="50%" border="0"> \t <form name="login" method="post" action="./registration.php"> \t <tr>