Login Register






[TUT]Writing into an online file filter_list
Author
Message
[TUT]Writing into an online file #1
Hi Smile

Don't know how to call it in other words Biggrin sorry Smile
you can post suggestions Tongue

Ok, so today, I will teach you, how you can make a VB.NET app connect to the internet, and post some data there.

We will use:
=> a PHP file named index.php
=> a simple VB.NET code
=> a log.txt file. It doesn't have to contain anything

Setting up the web files:

First of all, make a new text document.

Write in the following code:
PHP Code:
<?php $action = $_GET['action']; $data = $_GET['data']; if ($action == "delete"){ unlink("log.txt"); $new = fopen("log.txt", 'a'); fclose($new); } if ($action == "write"){ $open = fopen("log.txt", 'a'); fwrite($open, $data."\n"); fclose($open); } ?>
Credits go to some unknown person Biggrin

Okay, save this as: index.php

Now make a new text document. Just name it: log.txt

upload these to a webhost. It can be free webhost Smile

Now, lets start the code.

So, first we have to make a webclient, so we will do:
Code:
Dim wc As New WebClient

You will get error, so add:
Code:
Imports System.Net
On the very top of your app

Now we will send the command to the php file.
As you can see, there are 2 commands: "write" and "delete", we will use "write" now.

So, the command will look like this:
Code:
http://yourhost.ext/index.php?action=write&data=
after the: "data=" you put in whatever you want Smile

Now, to make this work, we have to do this:
Code:
wc.DownloadString("http://yourhost.ext/index.php?action=write&data=Hello World!")

This will send a command to print "Hello World" into the log file Smile

Now to make it work, close the code with:
Code:
wc.Dispose()

if you don't want the text anymore, use:
Code:
wc.DownloadString("http://yourhost.ext/index.php?action=delete")

Thats all folks Smile
Have a great day!
Staff will never ever ask you for your personal information.
We know everything about you anyway.

Reply





Messages In This Thread
[TUT]Writing into an online file - by 1llusion - 02-21-2011, 10:43 PM