Z61 CHAT 1.1

Here is the place to post images, videos and downloads of your current and upcoming applications that you are working on.
18 posts Page 2 of 2
Contributors
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: Z61 CHAT 1.1
zachman61
mandai wrote:
Sure
Code: Select all
<form method="post">
<input name="u" value="user">
<input name="m" value="message">
<input type="submit">
</form>
<?php
if (array_key_exists("u", $_POST) && array_key_exists("m", $_POST))
{
 $chat = $_POST["u"] . ": " . $_POST["m"] . "\r\n";
 echo $chat;

 $file = date("Y-n-j") . ".txt";

 $fw = fopen($file , "a") or die("<div>Could not open, create or write to $file.</div>");
 fwrite($fw, $chat) or die("<div>Could not write to $file.</div>");
 fclose($fw);
}
?>
You could take out the html and just have it as a php script, then your program can directly post/receive echoed messages, and since the server handles the chatlog your clients don't need even direct access to it.
hey how would i make read in vb?
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Z61 CHAT 1.1
mandai
First get rid of the input element, thats just if someone visits the page in a browser. Next you'll have to put that script on a PHP-enabled server.

Once its in place you can use this to post messages from the client:
Code: Select all
        Dim wc As WebClient = New WebClient()
        Dim u As Uri = New Uri("http://localhost/chat.php")
        Dim values As System.Collections.Specialized.NameValueCollection = New System.Collections.Specialized.NameValueCollection()
        values.Add("u", "user")
        values.Add("m", "message")

        Dim data As Byte()
        Try
            data = wc.UploadValues(u, values)
        Catch ex As Exception
            MsgBox("Error posting chat: " & ex.Message)
            Return
        End Try

        Dim chat As String = System.Text.Encoding.ASCII.GetString(data)
        txtChat.Text += chat & vbCrLf
Then occasionally you can have the client refresh the chat log from the file that is stored on the server.
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: Z61 CHAT 1.1
zachman61
hey actually how can it read in the richtextbox ?
also i tested it and used textbox1 and hit send and in textbox1 i got this
Code: Select all
Silluser: message
<br><table border='1' cellpadding='2' bgcolor='#FFFFDF' bordercolor='#E8B900' align='center'><tr><td><font face='Arial' size='1' color='#000000'><b>PHP Error Message</b></font></td></tr></table><br />
<b>Warning</b>:  fopen(2010-5-24z61chat.txt) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Permission denied in <b>/home/a9136110/public_html/chat.php</b> on line <b>9</b><br />
<br><table border='1' cellpadding='2' bgcolor='#FFFFDF' bordercolor='#E8B900' align='center'><tr><td><div align='center'><a href='http://www.000webhost.com/'><font face='Arial' size='1' color='#000000'>Free Web Hosting</font></a></div></td></tr></table><div>Could not open, create or write to 2010-5-24z61chat.txt.</div>
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: Z61 CHAT 1.1
Lewis
That code looks hard I dont know how you would do this i would like to learn :P
Image
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Z61 CHAT 1.1
mandai
Your web host is putting extra code in the bottom of the php script, plus it is blocking you from writing to/reading from the txt file.
Check your security settings to make sure scripts can read/write in the current directory.
Lewis
Coding God
Coding God
Posts: 1564
Joined: Sun Dec 20, 2009 2:12 pm

Re: Z61 CHAT 1.1
Lewis
On the 000webhost file manager you have to CHMOD It 777 basicly ' read/write in the current directory'
Image
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: Z61 CHAT 1.1
zachman61
thank you lewis
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: Z61 CHAT 1.1
zachman61
Update b 1.2
I've decided that 1.1 was too buggy so im releasing a new version 1.2 with a login,register, music player and hopefully a updater since ive got the version checker complete so to it sends you to the website to download the update currently it is at 1.2 so it is to date but 1.2.1 will be the server chat changes it will revert back to 1.2 after each other day
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that :)
18 posts Page 2 of 2
Return to “Work in Progress”