Staredit Newtork
Community
StarCraft
Games
Site
Favourites
Need web based VB help, Just some simple things

Creator: [Dark_Marine]:]
Time: Nov 4 2007, 8:18 am

Post #1     [Dark_Marine]:] Nov 4 2007, 8:18 am

[Avatar]
To Catch an Echo™
 offline contact
So liek, I wanna start writing a site, and I know since im good with VBs, maybe ill be good with VB.

I really REALLY want to know how to accept a variable from a form on page. Simple easy, and Ill have more questions later. Thanks ;D
(user posted image)(user posted image)(user posted image)(user posted image)(user posted image) Yellow army assemble!
Top

Post #2     DT_Battlekruser Nov 4 2007, 11:00 am

[Avatar]
I paid eleven minerals for THIS?
 offline contact
If you're learning a language to write a website, DON'T use VBScript.

Use PHP.
"Three can keep a secret, if two are dead." -Benjamin Franklin

"Had, having, and in quest to have, extreme;
A bliss in proof, and proved, a very woe;
Before, a joy proposed; behind, a dream.
All this the world well knows; yet none knows well
To shun the heaven that leads men to this hell."
-William Shakespeare
Top

Post #3     fatimid08 Nov 4 2007, 6:02 pm

[Avatar]
 offline contact
From ASP, getting a form variable after it is submitted is
somevariable = Request.Form("id of form element")

That's from server-side scripting, you haven't made it clear if you are using client-side VBScript (which you should not use, ever) or server-side ASP VBScript (which is ok as long as you have a host supporting it, else go to PHP).
Top

Post #4     DT_Battlekruser Nov 4 2007, 7:23 pm

[Avatar]
I paid eleven minerals for THIS?
 offline contact
PHP is just much more widely supported that it's better than ASP, even.
"Three can keep a secret, if two are dead." -Benjamin Franklin

"Had, having, and in quest to have, extreme;
A bliss in proof, and proved, a very woe;
Before, a joy proposed; behind, a dream.
All this the world well knows; yet none knows well
To shun the heaven that leads men to this hell."
-William Shakespeare
Top

Post #5     [Dark_Marine]:] Nov 5 2007, 6:30 am

[Avatar]
To Catch an Echo™
 offline contact
I liek VB ;(
(user posted image)(user posted image)(user posted image)(user posted image)(user posted image) Yellow army assemble!
Top

Post #6     Kellimus Nov 5 2007, 10:38 pm

[Avatar]
 offline contact
Quote from Dark_Marine_123I liek VB ;(


PHP is like C/C++

So learn C++ cause its totally way better than VB shit.
(user posted image)
Top

Post #7     [Dark_Marine]:] Nov 6 2007, 5:17 am

[Avatar]
To Catch an Echo™
 offline contact
Im no good at C++ or PHP, but very good at VB, God can someone leave an answer instead of critism?
(user posted image)(user posted image)(user posted image)(user posted image)(user posted image) Yellow army assemble!
Top

Post #8     (U)MindArchon Nov 6 2007, 8:31 am

[Avatar]
 offline contact
)Dark_Marine_123(, the problem with using client-side VB is that it's potentially insecure and very widely unsupported.

It's similar to coding a program that is only usable on Windows 95. You're going to end up pissing a lot of your visitors off. Since PHP and ASP are server side, the type of browser doesn't matter. If you are however using server-side VB (must be extremely rare unless you're running some sort of VPS) that's okay and can look up resources on Google. I doubt very many of us have experience.

Don't ever fall into the trap of using client-side VB since as far as I know only Internet Explorer for Windows supports it. Last time I checked parts of it could be considered malicious, so many versions of Internet Explorer have it disabled anyway. If you have the fundamentals of VB down, you should be able to pick up PHP or ASP easily. Reply if you have any more questions :)
Top

Post #9     DT_Battlekruser Nov 6 2007, 9:23 am

[Avatar]
I paid eleven minerals for THIS?
 offline contact
@MA The other thing to take into account is that, unless I'm mistaken, more servers support PHP than ASP (although most support both -- it's not like writing in something obscure like Python).
"Three can keep a secret, if two are dead." -Benjamin Franklin

"Had, having, and in quest to have, extreme;
A bliss in proof, and proved, a very woe;
Before, a joy proposed; behind, a dream.
All this the world well knows; yet none knows well
To shun the heaven that leads men to this hell."
-William Shakespeare
Top

Post #10     Kellimus Nov 6 2007, 10:01 pm

[Avatar]
 offline contact
Quote from Dark_Marine_123Im no good at C++ or PHP, but very good at VB, God can someone leave an answer instead of critism?


VB is a High-End language, meaning its simplistic.

If you want to write anything that anyone on the internet would like (because it works for them) learn either PHP or ASP.Net, for starters...

Then maybe learn yourself some VB.Net, or maybe even C#.Net...

Here is how you'd "accept a variable from a form" with PHP:
Quote
// Check for a username
if (eregi ("^[[:alnum:]_]{4,20}$", stripslashes(trim($_POST['username']))))
{
$u = escape_data($_POST['username']);
} else {
$u = FALSE;
echo '<p><font color="red" size="+1">Please enter a valid username!</font></p>';
}

<p><b>Username:</b> <input type="text" name="username" size="10" maxlength="20" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /> </p>

That's how you'd accept, and pass a variable in a form (it also is a sticky form)

All this stuff:
Quote// Check for a username
if (eregi ("^[[:alnum:]_]{4,20}$", stripslashes(trim($_POST['username']))))
{
$u = escape_data($_POST['username']);
} else {
$u = FALSE;
echo '<p><font color="red" size="+1">Please enter a valid username!</font></p>';
}
is PHP.

All this stuff:
Quote<p><b>Username:</b> <input type="text" name="username" size="10" maxlength="20" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /> </p>
is HTML mixed with a simple PHP conditional script.

If I knew any ASP, I'd show you that, but I don't...

Let me explain the PHP to you:

if (eregi ("^[[:alnum:]_]{4,20}$", stripslashes(trim($_POST['username'])))) is an "if, else conditional".

Meaning, "if (function eregi ("beginning of string[[class any letter or number]extra character allowed within this conditional]{minimum number of characters needed to meet conditional, maximum number of characters allowed for conditional}end of string", function stripslashes(trim($_POST['username']))))

So if (eregi ("^[[:alnum:]_]{4,20}$", stripslashes(trim($_POST['username'])))), checks to see if a string with any letter or number, including an underscore (_) is passed, and if the condition is met, it will stripslashes (has to deal with Magic Quote stuff) and trim (take out unnecesary white-space) the variable $_POST['username']

We defined "username" inside of our HTML form (notice the bolded area):
Quote<p><b>Username:</b> <input type="text" name="username" size="10" maxlength="20" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /> </p>


$_POST is a global function(?) that catches the "methed post" from your HTML form (if you use the method post that is...)

It'd be best to use post instead of get in your "form action".. Get will have all the variable information in the URL... Its just for security reasons.

So anyways: if your condition is met (the condition is that someone put a username in the "username" input field in your form, and they used any number and letter and/or the _ is included), the variable $u, will have the value: escape_data($_POST['username']);

The $_POST['username'] will be whatever is inserted within the bolded area:
Quote<p><b>Username:</b> <input type="text" name="username" size="10" maxlength="20" value="<?php if (isset($_POST['username'])) echo $_POST['username']; ?>" /> </p>
so if I input Kellimus, it would look something like this: $u = escape_data($_POST['Kellimus']);

If my condition is not met, thats when the "else" would happen.

So if I didn't input a name into the "username" text field, it would return $u as FALSE, then output (in HTML):
Quote<p><font color="red" size="+1">Please enter a valid username!</font></p>


Does that make sense? I know that eregi, and all that stuff is confusing to beginners, but once you use it a while, you'll understand....
This post was edited 3 times, last edit by Kellimus: Nov 6 2007, 10:34 pm.
(user posted image)
Top

Post #11     Syphon[MM] Nov 7 2007, 2:46 am

[Avatar]
 offline contact
Don't be like Kellimus and constantly go in and out of <?php ?>, it's ugly.
Top

Post #12     [Dark_Marine]:] Nov 7 2007, 9:58 am

[Avatar]
To Catch an Echo™
 offline contact
Is the term Completely Lost avaible?
(user posted image)(user posted image)(user posted image)(user posted image)(user posted image) Yellow army assemble!
Top

Post #13     DT_Battlekruser Nov 7 2007, 10:10 am

[Avatar]
I paid eleven minerals for THIS?
 offline contact
Kellimus is just making himself feel special by using a bunch of advanced library functions.

If you use PHP to output an HTML form, eg.

Code
<?php
echo("<form action="this.php" method="POST"><input name="hi"></form>");
?>


then when the page is loaded with a POST query, the data is stored in an array called $_POST

If you want the value of your input field, it's

Code
$_POST['hi']


etc.
"Three can keep a secret, if two are dead." -Benjamin Franklin

"Had, having, and in quest to have, extreme;
A bliss in proof, and proved, a very woe;
Before, a joy proposed; behind, a dream.
All this the world well knows; yet none knows well
To shun the heaven that leads men to this hell."
-William Shakespeare
Top

Post #14     fatimid08 Nov 7 2007, 2:25 pm

[Avatar]
 offline contact
Quote from Dark_Marine_123I really REALLY want to know how to accept a variable from a form on page.


So I'm gonna answer the question.
As I posted previously, in ASP, after a user submits a form, you do:
somevariable = Request.Form("name of form element to retrieve")
on the page it is submitted to.

An example:

Code

The Form:

<form action="formhandler.asp" method="POST">
<input name="email" type="text" />
<input type="submit" />
</form>

The ASP handling code:

Dim Email

Email = Request.Form("email")

then do validation/storage code


That's the ASP VB way to do it.
If you ever decide to use client-side VBScript, then it'll only work on IE, and even then, many people have it turned off.

ASP.Net also uses Request.Form, if you decide to go there, although there are often other ways depending on what you are doing.
Top

Post #15     Kellimus Nov 7 2007, 10:34 pm

[Avatar]
 offline contact
Quote from DT_BattlekruserKellimus is just making himself feel special by using a bunch of advanced library functions.

If you use PHP to output an HTML form, eg.

Code
<?php
echo("<form action="this.php" method="POST"><input name="hi"></form>");
?>


then when the page is loaded with a POST query, the data is stored in an array called $_POST

If you want the value of your input field, it's

Code
$_POST['hi']


etc.


I'm making myself feel special because I'm showing how to program, the way I was taught?

Thanks for the flame, :D
(user posted image)
Top

Post #16     DT_Battlekruser Nov 8 2007, 3:24 am

[Avatar]
I paid eleven minerals for THIS?
 offline contact
He clearly is not an advanced programmer, so throwing things out like eregi() is pretty counterproductive.
"Three can keep a secret, if two are dead." -Benjamin Franklin

"Had, having, and in quest to have, extreme;
A bliss in proof, and proved, a very woe;
Before, a joy proposed; behind, a dream.
All this the world well knows; yet none knows well
To shun the heaven that leads men to this hell."
-William Shakespeare
Top

Post #17     Syphon[MM] Nov 8 2007, 5:19 am

[Avatar]
 offline contact
Quote from KellimusThanks for the flame, :D


Do you know what a flame is? He was criticising something you did, not you.
Top

Post #18     Falkoner Nov 8 2007, 6:26 am

[Avatar]
Taking StarCraft Map Making to the Limit!
 offline contact
For a website, learn HTML, some CSS, and some PHP, and you should be fine, if you want to do more complex stuff, you might want to learn a bit of Javascript, all of these can be Googled, or if you want tutorials just google "<Name of language> tutorial"
Top

Post #19     Kellimus Nov 8 2007, 8:15 pm

[Avatar]
 offline contact
Quote from Syphon
Quote from KellimusThanks for the flame, :D


Do you know what a flame is? He was criticising something you did, not you.


I know what a flame is, I'm trying to point out how everyone here whines about "flame this", "flame that".

If I were to make a snipe comment like that, I'd get warned. But that's okay, thats the Admin's double standards for you :)

Quote from FalkonerFor a website, learn HTML, some CSS, and some PHP, and you should be fine, if you want to do more complex stuff, you might want to learn a bit of Javascript, all of these can be Googled, or if you want tutorials just google "<Name of language> tutorial"


PHP can do more complex things than Javascript..
(user posted image)
Top

Post #20     Falkoner Nov 10 2007, 4:51 am

[Avatar]
Taking StarCraft Map Making to the Limit!
 offline contact
But there's some things Javascript can do that PHP can't :P
Top
0 members in this topic: None
+ 0 guest(s)


[06:14 pm]
[DeVouReR]:] -- thanks
[06:09 pm]
Mini Moose 2707 -- 20x12
[05:56 pm]
[DeVouReR]:] -- ingame screen; how many tiles?
[05:56 pm]
[DeVouReR]:] -- woot, I forgot, who big is a screen? in tiles in SCMdraft?
[05:51 pm]
Phobos[MM] -- Paravin with a period at the end...? lolwtf
[05:46 pm]
Phobos[MM] -- Hmmm.
[05:46 pm]
Phobos[MM] -- I should do something instead of jsut thinking of what to do.
You must log in to shout.

©2003-2008 Staredit Network.
Starcraft & Starcraft II are trademarks of Blizzard Entertainment.
Site Index   |   Terms of Service   |   Privacy Policy   |   Contributions