Skip to content

Instantly share code, notes, and snippets.

@ir-g
Last active December 23, 2015 16:19
Show Gist options
  • Save ir-g/6661350 to your computer and use it in GitHub Desktop.
Save ir-g/6661350 to your computer and use it in GitHub Desktop.
Chat system of primitive proportions-Uses XML
<html>
<body>
<div>
<?php
if (isset($_REQUEST['chatmessage']))
//if "email" is filled out, send email
{
$user=$_REQUEST['user'];
$file="chatlog.xml";
$chatmessage=$_REQUEST['chatmessage'];
$data="
<message>
<id>$user</id>
<messagebody>$chatmessage</messagebody>
</message>
";
file_put_contents($file, $data, FILE_APPEND);
echo("File: $file");
echo("Data: $data");
}
else
//if "email" is not filled out, display the form
{?>
<form method='post' action='chat.php'>
User: <input name='user' type='text'><br>
Message:<br>
<textarea name='chatmessage' rows='15' cols='40'>
</textarea><br>
<input type='submit'>
</form>"
<?php
}
?>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment