In this tutorial I will be teaching you how to make a Suggestion section for your program, giving your members the chance to post "suggestions" to a txt file on your host.
What you Need:
- Visual Basic 2008
- Web Host
- FTP Client, or Web hosts Cpanel
- Attached File or read below.
Step 1
First lets get the Files out of the way. There are 2 files needed.
- get_data.php
- suggestions.txt
Now you can follow Step 1B, and Step1C or download the attachment.
Step 1B
Open up NotePad and paste the following code inside of it.
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Suggestion Box</TITLE>
</HEAD>
<BODY LINK="#0000FF" VLINK="#800080">
<?php
$Name = htmlspecialchars($_GET['Name']);
$Subject = htmlspecialchars($_GET['Subject']);
$Message = htmlspecialchars($_GET['Message']);
$ip = $_SERVER['REMOTE_ADDR'];
$ref = $_SERVER['HTTP_REFERER'];
$dtime = date('r');
if($ref == ""){
$ref = "None";
}
if($Name == ""){
$Name = "Anonymous";
}
?>
Hello <?php echo $Name ?>.
thank you for visiting.
<?php
$entry_line = "$dtime - IP: $ip \nName: $Name \nSubject: $Subject \nMessage: $Message\n\n\n";
$fp = fopen("Suggestions.txt", "a");
fputs($fp, $entry_line);
fclose($fp);
?>
</BODY>
</HTML>
Save the file as "get_data.php" file type as All Files

Im not here to teach you PHP, so I wont explain what I just put together.
Step 1C
Right click your Desktop, go to New, then click Text Document.

Rename the document to Suggestions
Step 2
Now that you have the 2 files needed, eathor it be from you downloading the attachment or following Step1B, and Step1C, We need to upload it to our web server. If you dont know how to do this, and you own a Web Host, read Step 5 of this
Tutorial. An Addition to uploading them, you need to CHMOD them, now do to this for FileZilla right click both items in FileZilla, go to Permissions, and change the number you see to
"777"

Now, find the location where you uploaded get_data.php, it should be normally
http://websitename.com/get_data.php. For me its
http://ugleh.comTutorials/Suggestion/get_data.php, Now that you have the link, remember it or write it down somewhere.
Step 3
YAY, onto the Visual Basic Design. what we need now is for you to add a new form to our existing or new project, to do this go to
Project > Add Windows Form. When the prompt comes up, press Add. You should now see a form named Form2. Here we need to add 3 textboxes, 3 labels, and 1 button. Here is how I made mine.

For a box textbox like I have, click the TextBox, look for the arrow thing on the top right, click it and click the MultiLine tab, as shown in the picture. You can now stretch it wide.
once done make sure TextBox1 goes with Name, TextBox2 goes with Subject, TextBox3 goes with Message. Now with that done.
Step 4
Finally the coding.
Double Click the form itself and above everything put
Code:
Imports System.Net
Imports System.IO
Looks like this
Step 4B
Go back to the Form2 Design, and click on the Button. Add the following code in the button click event.
Code:
If TextBox1.Text = "" Then
MsgBox("You must fill out every field")
ElseIf TextBox2.Text = "" Then
MsgBox("You must fill out every field")
ElseIf TextBox3.Text = "" Then
MsgBox("You must fill out every field")
Else
Dim Request As HttpWebRequest
Dim Response As HttpWebResponse
Dim Streem As Stream
Request = WebRequest.Create("http://ugleh.com/Tutorials/Suggestion/get_data.php?Name=" + TextBox1.Text + "&Subject=" + TextBox3.Text + "&Message=" + TextBox2.Text)
Response = Request.GetResponse
Streem = Response.GetResponseStream
Dim sr = New StreamReader(Streem)
Dim strResponse As String = sr.ReadToEnd
Response.Close()
Me.Close()
End If
Look for the Bold orange text in the above code, now change that URL with the URL I told you to save earlier.
Step 5
Opening the Suggestion Box, simple. Go to Form1 and add a new button. Name it whatever you want to get people to click it to make a suggestion.
Click the button to get to the coding, and simply add
DEBUGGING
Click Debug, and the Form1 should come up. Click the button to allow Suggestion form to come up, test it out with random stuff
Then go to
http:/
rwebsite.com/suggestion.txt, or whereever you Suggestion text file is located.
Mine is located
http://ugleh.com/Tutorials/Suggestion/Suggestions.txt
I hope you learned something new
Attachment below comes with
- get_data.php
- Suggestions.txt
- Suggestion Box.exe (the program I made in this tutorial)