Last active
December 23, 2015 16:19
-
-
Save ir-g/6661350 to your computer and use it in GitHub Desktop.
Chat system of primitive proportions-Uses XML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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