Making a PHP shoutbox

Hello again everyone,

I have to make a shoutbox with only PHP, but I don’t know how to continue.
I want to work with $_POST, and I need to make use of implode and explode.

My questions are as followed:

  1. What does implode and explode mean in this context? I’ve been trying to search and find out what this means and does, but so far I am thus unsuccessful ):
  2. What functions do I need to think of when making a shoutbox, and why?
    -> I would like to understand the code as much as possible for myself also, of course :slight_smile:

With HTML I’ll make a form with one value field and a submit button (so a very basic set-up in other words).

Thanks again for any help.

http://php.net/manual/en/function.implode.php
http://php.net/manual/en/function.explode.php

implode joins array elements to a string, explode does the oppposite (explodes a string to an array).

You must figure out how to store the shouts, if they are supposed to be editable/deletable by an admin, and I would also remember to escape output so you aren’t victim to XSS.

http://php.net/manual/en/function.htmlentities.php

Hello JimL,
Thank you for your reply and your help once again :slight_smile:

There is no admin yet involved with this. It is a pretty basic simple set-up for now.
These codes won’t be put online as of yet through an active webpage or anything of that sort right now. These are all exercise assignments and I am slowly starting to learn more and more and eventually will have to deal with XSS and other things pretty soon.
But not yet.

For now just making sure we have a functional shoutbox with nothing else fancy around it :slight_smile:

Below is what I’ve got so far.
It gives an error, of course.
I would like to know what to do next, and how I can use explode in this code.

Thanks in advance :slight_smile:

[code]<?php

$array = array(’;’, ‘’);
$shouts = implode(";", $array);

echo $_POST[‘shouts’];

var $_GET[‘shouts’];
//something to do with html here?

//use explode

?>

<!doctype html>

Shouts:

[/code]

PS:
I only have to use PHP for this particular assignment. No use of databases (no SQL in other words), nothing else.

Can you store the shouts somewhere? file, memory, something.

No, at least: I only understood to make a very simple PHP+HTML file with nothing ‘attached’ to it. It all ‘needs’ to be generated from the PHP (and HTML) code, nothing else.

Sponsor our Newsletter | Privacy Policy | Terms of Service