0

Well, i'm very new to Javascript and PHP, and I have a problem.

The idea: I want to do some post area, where in a single PHP page people will fill a form and it will create a little bootstrap panel. Don't worry about multiple pages, it's like a... wall. Example:

<div class="col-sm-6">
<div class="panel panel-primary">
  <div class="panel-heading">
    <h3 class="panel-title">My message</h3>
  </div>
  <div class="panel-body">
  <h6>This is a test!</h6>
  </div>
  </div>
</div>

I don't know exactly how to do this. What i think is that in another page, there will be a form receiving the html contents for the panel title and body and then the PHP code will create html code [not a file] using this text and will put them in another file.

EDIT: As you can see in the comments, i'll have to use PHP and mySQL. I'm still not sure on how to do that.

MucaP
  • 992
  • 1
  • 10
  • 18

1 Answers1

1

Okay, i made this for you. The following is just for give you a start, the code is not correctly written, but it will give you a way to start your "project".

Firstly, create your database for storage your post, as follow :

TABLE_POST
title
content
date
autor

Then wall.php :

Start your file by getting with a query, all existing post in your database :

var post_list = "select id, pseudo, title, date, autor from table_post";

Once you have it, display it as you want :

<div>
foreach (post in post_list) {
echo "<div>";
echo "<h1>".post["title"]."</h1>";
echo "<p>".post["content"]."</p>";
      ...
echo "</div>";
}
</div>

In an other page, you can have your form : form.php

<form id='myform' method='post' action='add_post.php'>
<input type='text' id='title'/>
<input type='text id='content' />
<input type='text' id='autor' />
<input type='submit' value='Post it !'>
</form>

And in an other page, you can have the function to insert in the database :

add_post.php

insert into table_post VALUES ($_POST["title"], $_POST["content"], NOW(), $_POST["autor"]);

I repeat, i just give a structure for your achievement, i didn't provide a correct syntaxe of the code. Hope it can help you

Jax Teller
  • 1,447
  • 2
  • 15
  • 24
  • Thank you! Well, a little too much, it's a lot simpler, no date or author, but that helps. Thank You! – MucaP Jul 22 '16 at 14:55