Hi I have form to make new article with informations and image. I susccesfuly save all info and image to database (i guess). And when I want to display info and image so only info works.
See in picture.
Any help? Thanks a lot
Inserting_post.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>APK Market</title>
<link rel="stylesheet" type="text/css" href="../style/style.css">
<link href="../bootstrap/css/bootstrap.css" rel="stylesheet" media="screen">
<script src="../bootstrap/js/bootstrap.min.js"></script>
<script src="../bootstrap/js/bootstrap.js"></script>
</head>
<body>
<form method="post" action="insert_post.php" enctype="multipart/form-data">
<div class="new_post">
<div class="headtitle">Insert new post</div>
<div class="new_title">
<p>New title</p>
<input type="text" name="title">
</div>
<div class="new_author">
<p>Author</p>
<input type="text" name="author">
</div>
<div class="new_keywords">
<p>Keywords</p>
<input type="text" name="keywords">
</div>
<div class="new_image">
<p>Image</p>
<input type="file" name="image">
</div>
<div class="new_content">
<textarea name="content" cols="20" rows="8"></textarea>
</div>
<div class="submit">
<input type="submit" name="submit" value="OK">
</div>
</div>
</form>
<script src="https://code.jquery.com/jquery.js"></script>
<script src="../bootstrap/js/bootstrap.js"></script>
</body>
</html>
<?php
include("../includes/connect.php");
if(isset($_POST['submit']))
{
$games_date = date('y-m-d-h');
$games_title = $_POST['title'];
$games_author = $_POST['author'];
$games_keywords = $_POST['keywords'];
$games_image = $_FILES['image']['name'];
$games_tmp = $_FILES['image']['tmp_name'];
$games_content = $_POST['content'];
if($games_title=="" or $games_author=="" or $games_keywords==""
or $games_content=="")
{
echo"<script>alert('any field is empty')</script>";
exit();
}
else
move_uploaded_file($games_tmp,"../uploaded_images/$games_image");
$insert_query= "insert into games(games_title,games_date,games_author,games_image,
games_keywords,games_content)
values ('$games_title','$games_date','$games_author','$games_image',
'$games_keywords','$games_cont ent')";
}
if(mysql_query($insert_query))
{
echo "<center><h1>Post published seccesfuly!</h1></center>";
}
?>
display page:
<div class="content">
<?php
include('connect.php');
$select_posts = "select * from games";
$run_posts = mysql_query($select_posts);
while($row=mysql_fetch_array($run_posts))
{
echo '<p class="games_title_result">' .$games_title = $row['games_title'];
echo '<p class="games_image_result"><img src="<?php echo $row["games_image"];?>';
echo '<p class="games_content_result">' .$games_content = $row['games_content'];
echo '<p class="games_date_result">' .$games_date = $row['games_date'];
echo '<p class="games_author_result">' .$games_author = $row['games_author'];
}
?>
</div>
Here's my answer:
echo '<p class="games_image_result"><img src="uploaded_images/'.$row["games_image"].'" />';
You got a syntax error where you include a <?php and ?> inside your php, and on your echo at that.
So when you look at your img's src, it would have those.
Also, you forgot to close your img tag and your other p tags.
Your image tag isn't closed properly and the path to the image is not complete. You are only specifying the filename. I am not sure about your directory structure
echo '<p class="games_image_result"><img src="uploaded_images/<?php echo $row["games_image"];?>" />';
Display Image from DataBase using php
# SQL Statement
$sql = "SELECT `idimage` FROM `yourTableName` WHERE id=" . mysqli_real_escape_string($_GET['id']) . ";";
$result = mysqli_query("$sql") or die("Invalid query: " . mysqli_error());
# Set header
header("Content-type: image/your image name which type of your image");
echo mysqli_result($result, 0);
}
else
echo 'Please check the ID!';
?>
I wish it's may be help you
Related
I am trying to write a basic blog that i can post blogs and view them blogs. I have posted the blog by form action however what i want to try to do now is that get the data that i got from my csv into h1 h2 p2 on my viewpost.html. How would i be able to do this.
This is my index.html
<!DOCTYPE html>
<html>
<head>
<title>My Blog</title>
<link type='text/css' rel ='stylesheet' href="style.css"/>
</head>
<body>
<form action="form_process.php" method="post">
<label for="title">Title</label>
<input type="text" name="title" id='title'/>
<label for="desc">Description</label>
<input type="text" name="desc" id='desc'/>
<label for="cont">Content</label>
<input type="text" name="cont" id='cont'/>
<input type="submit" name="formSubmit" value="Submit" />
</body>
</html>
This is form_process.php
<?php
if($_POST['formSubmit'] == "Submit")
{
$errorMessage = "";
if(empty($_POST['title']))
{
$errorMessage .= "<li>You forgot to enter a title!</li>";
}
if(empty($_POST['desc']))
{
$errorMessage .= "<li>You forgot to enter a description!</li>";
}
if(empty($_POST['cont']))
{
$errorMessage .= "<li>You forgot to enter a description!</li>";
}
$varTitle = $_POST['title'];
$varDesc = $_POST['desc'];
$varCont = $_POST['cont'];
if(empty($errorMessage))
{
$fs = fopen("mydata.csv","a");
fwrite($fs,$varTitle . ", " .$varDesc . ", " .$varCont . "\n");
fclose($fs);
header("Location: index.html");
exit;
}
}
?>
And lastly this is my viewpost.html
<!DOCTYPE html>
<html>
<head>
<title> View Post</title>
</head>
<body>
<div class="post">
<h1>Title</h1>
<h2>Description</h2>
<p>Content</p>
</body>
</html>
I have a simple webpage and a database to upload and show image on webpage.However, some image cannot be downloaded and shown correctly on webpage, some images show well. I have checked my database, each image can be inserted into database correctly.
My PHP code is below:
<?php
ini_set('mysql.connect_timeout',10);
ini_set('default_socket_timeout',5);
include_once 'dbconnect.php';
?>
<?php
if(isset($_POST['btn_Upload_Image']))
{
if(getimagesize($_FILES['image']['tmp_name']) == FALSE)
{
// echo "Please select an image.";
?>
<script>alert('Please select an image.');</script>
<?php
}
else
{
$image= addslashes($_FILES['image']['tmp_name']);
$Name= addslashes($_FILES['image']['name']);
$image= file_get_contents($image);
$image= base64_encode($image);
saveimage($Name,$image);
}
}
//displayimage();
function saveimage($Name,$Image)
{
$qry="Insert into Clothing (Picture_Name,Picture_Storage) values ( '$Name','$Image')";
// echo "$qry" ."</br>";
$result=mysql_query($qry);
if($result)
{
?>
<script>alert('Image uploaded.');</script>
<?php
}
else
{
?>
<script>alert('Image not uploaded.');</script>
<?php
}
}
function displayimage()
{
$qry = "Select * from Clothing";
$result=mysql_query($qry);
while($row = mysql_fetch_array($result))
{
echo '<img height="200" width="200" src="data:image;base64,'.$row[Picture_Storage].' "> ';
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Hello PeekABuy</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<div id="header">
<div id="left">
<label>Cropped Images </label>
</div>
</div>
<div id="body">
<div id="Hotel-InfoForm">
<form method="post" enctype="multipart/form-data">
<center>
<table align="center" width="40%" border="0">
<tr>
<td>
<input type="file" name="image" />
<br/>
<br/>
<input type="submit" name="btn_Upload_Image" value="Upload" />
</td>
</tr>
<center>
</table>
<br>
<br>
<br>
<br>
<br>
<br>
</form>
<?php
displayimage();
?>
<br>
<br>
<br>
<br>
<hr>
</div>
</div>
</body>
</html>
1:How webpage looks like; 2: Datatype of my database; 3: Inserting status
Thanks a lot!
I have a problem logging users. When logs, session work, but when you click to another page, the session will disappear and does not work and when I put session_start to the main page and to login.php, I got error that session is already running. Some ideas? Thanks
Main Page.php
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" type="text/css" href="css.css">
<link rel="icon" href="favicon.ico">
<title>----</title>
</head>
<body>
<!-- HEADER _____________________________________________________________________________ -- >
<div id="whiteblock">
<div id="grayblock">
<div id="logo">
</div>
<h1>----</h1>
<h2>----</h2>
Registration
<?php
include "Login.php";
echo $_SESSION["LogiNick"];
?>
<div id="inputposunuti">
<form name="Log" id="Log" method="post">
<label for="Nick" class="inputtext">Nick:</label>
<input type="text" name="LogiNick" id="LogiNick" class="input"> <?php echo $EmptyNick; echo $Else; ?>
<label for="Pass" class="inputtext">Password:</label>
<input type="password" name="LogiPass" id="LogiPass" class="input"> <?php echo $EmptyPass; echo $Else; ?>
<input type="submit" name="LogIn" value="⇒">
</form>
</div>
</div>
<!-- HEADER _____________________________________________________________________________ -->
<!-- MENU _______________________________________________________________________________ -->
<div id="pruh">
<div id="search">
<form name="search" method="post">
<input type="text" name="hledat" id="sirka">
<input type="submit" name="subhledat" value="Search!" id="button">
</form>
</div>
<div id="menutext">
<p>Home</p>
<p>----</p>
<p>----</p>
<p>----</p>
<p>----</p>
<p>----</p>
</div>
</div>
<!-- MENU _______________________________________________________________________________ -->
<!-- CONTENT ____________________________________________________________________________ -->
<!-- CONTENT ____________________________________________________________________________ -->
<div id="teams"></div>
</div>
<p id="creator">Created by</p>
Login.php
<?php
session_start();
include_once "db.php";
global $db;
$Else = $EmptyNick = $EmptyPass = $EmptyNick = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$LogiNick = $_POST["LogiNick"];
$LogiPass = $_POST["LogiPass"];
if (empty($_POST["LogiNick"])) {
$EmptyNick = " - Nick";
}
if (empty($_POST["LogiPass"])) {
$EmptyPass = " - Password";
}
}
if(!empty($_POST["LogiNick"]) AND !empty($_POST["LogiPass"])){
$LogiPass = $_POST["LogiPass"];
$SHA = sha1($LogiPass);
$sql = "SELECT * FROM WEB_REGISTER WHERE Nick = :nick AND Heslo = :heslo";
$query = $db->prepare($sql);
$query->execute(array('nick' => $LogiNick, 'heslo' => $SHA));
$count = $query->rowCount();
if ($count > 0) {
$_SESSION["LogiNick"];
}
}
?>
You just set a session if you put a value into it.
$_SESSION["name"]=$value;
EDITED: Answered by #James solution is bolded in the code below.
Thanks again #James.
I have a form(HTML) which has a text field and upload a file to database.
Before I was using
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="POST" name="form1" enctype="multipart/form-data"></pre>
It was working fine, now I want the page to submit the entries to database and display a different page so I tried this
<form action="page3.php"......>, but didn't worked.
However when I click Submit button it make the entry for text field in database but does not upload the file to database.
What I want it to do is: when I click submit button, text field gets entered in database, file gets uploaded to database folder(and my program make its path entry to database), and new page which is loaded for the user to see.
Any help is appreciated. Thanks.
my php code
<?php
//ob_start();
$host="localhost";
$username="root";
$password="";
$db_name="newrep";
$table_name="members";
$conn=new mysqli('localhost','root','','newrep');
if(!$conn){
die("cannot connect.");
}
//else if(!mysql_select_db($db_name)){
// die(" cannot select database.");
//}
session_start();
use foundationphp\UploadFile;
echo "Session value: ".$_SESSION['texas'];
$currentuser=$_SESSION['texas'];
echo $currentuser;
$current_year=date("Y");
//code for upload starts here
require_once 'src/foundationphp/UploadFile.php';
if (!isset($_SESSION['maxfiles'])) {
$_SESSION['maxfiles'] = ini_get('max_file_uploads');
$_SESSION['postmax'] = UploadFile::convertToBytes(ini_get('post_max_size'));
$_SESSION['displaymax'] = UploadFile::convertFromBytes($_SESSION['postmax']);
}
$max = 2048 * 1024;
$result = array();
//upload code ended above
if(!isset($_SESSION['texas']))
{
header('Location:login_page.php');
exit();
}
else {
if(isset($_POST['title'])){
echo "reaching the else";
if(isset($_POST['upload'])){
//upload in POST is for upload
print_r($_FILES);
$destination = __DIR__ . '/uploaded/'; //for upload
//upload code try and catch
try {
$upload = new UploadFile($destination);
$upload->setMaxSize($max);
//$upload->allowAllTypes();
$upload->upload();
$result = $upload->getMessages();
}
catch (Exception $e) {
$result[] = $e->getMessage();
}
}
$error = error_get_last();
if ($result || $error){
//<ul class="result">
if ($error){
echo "{$error['message']}"; }
if ($result) {
foreach ($result as $message) {
echo "<li>$message</li>";}}}
$file_path_variable= $destination.$_SESSION['current_filename'];
echo $file_path_variable;
$title=$_POST['title'];
$query="INSERT INTO proposal(title_prop, userName_prop,whitepaper_prop,year_prop) VALUES('$title','$currentuser','$file_path_variable','$current_year')";
$result_query=mysqli_query($conn,$query);
echo " in elseif ";
if(!$result_query){
echo " cannot insert ";
}
else {
**header('Location: page3.php');
exit();**
//echo "successful entry ";
}
}
//ob_end_flush();
?>
HTML code here:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Online Application</title>
<!-- <link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"> -->
<link href="bootstrap.min.css" rel="stylesheet">
<head><script src="bootstrap.min.js"></script> </head>
<body>
<div id="O_o"><br><h4>Texas State University</h4></div>
<div id="wrapper">
<form action=**"<?php $_SERVER['PHP_SELF']?>"** method="POST" id="whitepaper" name="whitepaper" role="form" enctype="multipart/form-data">
<legend><h5><b>Online Application</b></h5></legend>
<h4 id="reference" name="reference" class="heading-reference"><b>Proposal Whitepaper</b></h4>
<fieldset>
<center>
<div class="form-group">
<?php echo "Year of Proposal: $current_year";?><br>
<label class="label_title control-label" for="title">Submit Title of your proposal:</label>
<input id="title" name="title" type="text" placeholder="" class="input_title form-control" >
<p class="help-block">All fields are required.</p><!--
<button type="submit" id="submit_button" name="btn-primary" class="btn btn-primary"> Submit Title </button>-->
</div>
<div class="form-group">
<label class="label_whitepaper control-label" for="file">Upload the whitepaper of your proposal here: <br>Only .docx , .doc and .pdf format extensions are permitted.</label>
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max;?>">
<p><input type="file" id="filename" name="filename[]" title="Browse for whitepaper" class="btn-primary" multiple
data-maxfiles="<?php echo $_SESSION['maxfiles'];?>"
data-postmax="<?php echo $_SESSION['postmax'];?>"
data-displaymax="<?php echo $_SESSION['displaymax'];?>"></p>
File should be no more than <?php echo UploadFile::convertFromBytes($max);?>.<br>
<!--<p><input type="submit" name="upload" value="Upload File" class="btn-primary">-->
<button id="submit" name="upload" class="btn-primary" >Submit and continue</button>
</div>
</center>
</fieldset>
</form>
</div>
<script src="js/checkmultiple.js"></script>
<script src="jquery.min.js"></script>
<script src="prettify.js"></script>
<script src="bootstrap.file-input.js"></script>
<script>
$(document).ready(function(){
$('input[type=file]').bootstrapFileInput();
});
</script>
</body>
</html>
<?php }
mysqli_close($conn);
?>
You need to include enctype='multipart/form-data' in your form tag:
<form action='<?php echo $_SERVER['PHP_SELF']?>' method="POST" name="form1" enctype='multipart/form-data'>
Without it, attachments cannot be sent through the form.
Update
Try the below code. I fixed some HTML errors as well.
<?php
//ob_start();
$host="localhost";
$username="root";
$password="";
$db_name="newrep";
$table_name="members";
$conn=new mysqli('localhost','root','','newrep');
if(!$conn){
die("cannot connect.");
}
//else if(!mysql_select_db($db_name)){
// die(" cannot select database.");
//}
session_start();
use foundationphp\UploadFile;
echo "Session value: ".$_SESSION['texas'];
$currentuser=$_SESSION['texas'];
echo $currentuser;
$current_year=date("Y");
//code for upload starts here
require_once 'src/foundationphp/UploadFile.php';
if (!isset($_SESSION['maxfiles'])) {
$_SESSION['maxfiles'] = ini_get('max_file_uploads');
$_SESSION['postmax'] = UploadFile::convertToBytes(ini_get('post_max_size'));
$_SESSION['displaymax'] = UploadFile::convertFromBytes($_SESSION['postmax']);
}
$max = 2048 * 1024;
$result = array();
//upload code ended above
if(!isset($_SESSION['texas']))
{
header('Location:login_page.php');
exit();
}else {
if(isset($_POST['title'])){
echo "reaching the else";
if(isset($_POST['upload'])){
//upload in POST is for upload
print_r($_FILES['fieldname']);
$destination = __DIR__ . '/uploaded/'; //for upload
//upload code try and catch
try {
$upload = new UploadFile($destination);
$upload->setMaxSize($max);
//$upload->allowAllTypes();
$upload->upload();
$result = $upload->getMessages();
}catch (Exception $e) {
$result[] = $e->getMessage();
}
}
$error = error_get_last();
if ($result || $error){
//<ul class="result">
if ($error){
echo "{$error['message']}"; }
if ($result) {
foreach ($result as $message) {
echo "<li>$message</li>";
}
}
}
$file_path_variable= $destination.$_SESSION['current_filename'];
//echo $file_path_variable;
$title=$_POST['title'];
$query="INSERT INTO proposal(title_prop, userName_prop,whitepaper_prop,year_prop) VALUES('$title','$currentuser','$file_path_variable','$current_year')";
$result_query=mysqli_query($conn,$query);
//echo " in elseif ";
if(!$result_query){
echo " cannot insert ";
}else {
header('Location: page3.php');
exit();
//echo "successful entry ";
}
}
//ob_end_flush();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Online Application</title>
<!-- <link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"> -->
<link href="bootstrap.min.css" rel="stylesheet">
<script src="bootstrap.min.js"></script>
</head>
<body>
<div id="O_o"><br><h4>Texas State University</h4></div>
<div id="wrapper">
<form action="<?php= $_SERVER['PHP_SELF']?>" method="POST" id="whitepaper" name="whitepaper" role="form" enctype="multipart/form-data">
<fieldset>
<legend><h5><b>Online Application</b></h5></legend>
<h4 id="reference" name="reference" class="heading-reference"><b>Proposal Whitepaper</b></h4>
<center>
<div class="form-group">
<?php echo "Year of Proposal: $current_year";?><br>
<label class="label_title control-label" for="title">Submit Title of your proposal:</label>
<input id="title" name="title" type="text" placeholder="" class="input_title form-control" >
<p class="help-block">All fields are required.</p><!--
<button type="submit" id="submit_button" name="btn-primary" class="btn btn-primary"> Submit Title </button>-->
</div>
<div class="form-group">
<label class="label_whitepaper control-label" for="file">Upload the whitepaper of your proposal here: <br>Only .docx , .doc and .pdf format extensions are permitted.</label>
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $max;?>">
<p><input type="file" id="filename" name="filename[]" title="Browse for whitepaper" class="btn-primary" multiple
data-maxfiles="<?php echo $_SESSION['maxfiles'];?>"
data-postmax="<?php echo $_SESSION['postmax'];?>"
data-displaymax="<?php echo $_SESSION['displaymax'];?>"></p>
File should be no more than <?php echo UploadFile::convertFromBytes($max);?>.<br>
<!--<p><input type="submit" name="upload" value="Upload File" class="btn-primary">-->
<button id="submit" name="upload" class="btn-primary" >Submit and continue</button>
</div>
</center>
</fieldset>
</form>
</div>
<script src="js/checkmultiple.js"></script>
<script src="jquery.min.js"></script>
<script src="prettify.js"></script>
<script src="bootstrap.file-input.js"></script>
<script>
$(document).ready(function(){
$('input[type=file]').bootstrapFileInput();
});
</script>
</body>
</html>
<? }
mysqli_close($conn);
?>
I set up a PHP database that worked perfectly on my local server. Then, when I went to put it online through my hosting site, Site5, I was getting these kinds of errors: "Cannot modify header information – headers already sent by...". So I changed the PHP file on Site5 to have output buffering turned on. Now, I am not getting an error, however, whenever I input data, it doesn't echo it back - however, it does show up in the database in phpMyAdmin (but without an ID).
Any ideas as to why it isn't echoing back and why it's new data isn't getting an ID?
Here it is live (and broken):
http://hjaramillo.com/tell_me/index.php
<!DOCTYPE html>
<html class="no-js" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>A Message For You</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="css/media.css" rel="stylesheet">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
</head>
<?php
ob_start();
//error_reporting(0);
require 'db/connect.php';
require 'functions/security.php';
error_reporting(E_ALL);
$records = array();
if(!empty($_POST)){
if(isset($_POST['first_name'],$_POST['location'],$_POST['message'])) {
$first_name = trim($_POST['first_name']);
$location = trim($_POST['location']);
$message = trim($_POST['message']);
if(!empty($first_name) && !empty($location) && !empty($message)) {
$insert = $db -> prepare("INSERT INTO message (first_name, location, message, date) VALUES (?,?,?,NOW())");
$insert->bind_param('sss',$first_name,$location,$message);
if($insert -> execute()){
header ('Location: index.php');
die();
}
}
}
}
if($results = $db->query("SELECT * FROM message ORDER BY id DESC LIMIT 1")) {
if($results->num_rows) {
while($row = $results->fetch_object()) {
$records[] = $row;
}
$results -> free();
}
}
?>
<?php
if (!count($records)){
echo 'No messages';
} else{
?>
<?php
foreach($records as $r){
?>
<body>
<?php
}}
?>
<div class="form-show">
<div class="post-icon">
<img src="images/post_icon.png"/>
</div>
</div>
<div class="form-background">
<div class="form-container">
<div class="form-title">
<p>Tell someone that:</p>
</div>
<form action="index.php" method="post">
<div class="fields msg">
<!--<label for="message">Message</label>-->
<textarea name="message" id="message" autocomplete="off"></textarea>
</div>
<div class="fields">
<ul>
<li> <label for="first_name">Name</label> </li>
<li> <input type="text" class="s-input" name="first_name" id="first_name" autocomplete="off"> </li>
</ul>
</div>
<div class="fields last">
<ul>
<li><label for="location">Location</label></li>
<li><input type="text" class="s-input" name="location" id="location" autocomplete="off"></li>
</ul>
</div>
<input type="submit" value="Post" id="submit-button">
</form>
<div>
</div>
</div>
</div>
<div class="msg-container">
<div class="msg-intro">
<p> On <?php echo escape($r->date); ?>,</p>
<p><span style="text-transform:capitalize;"><?php echo escape($r->first_name); ?> </span> from
<span style="text-transform:capitalize;"><?php echo escape($r->location); ?></span> wanted to tell you:</p>
</div>
<div class="msg-content">
<p><?php echo escape($r->message); ?></p>
</div>
</div>
</body>
<script type="text/javascript" src="js/application.js"></script>
</html>
Someone earlier asked if my ID was set to AUTO INCREMENT - it wasn't. That was the problem, thanks!