Staredit Network > Forums > Technology & Computers > Topic: Need web based VB help
Need web based VB help
Nov 4 2007, 8:18 am
By: Riney  

Nov 4 2007, 8:18 am Riney Post #1

Thigh high affectionado

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



Riney#6948 on Discord.
Riney on Steam (Steam)
@RineyCat on Twitter

-- Updated as of December 2021 --

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



If you're learning a language to write a website, DON'T use VBScript.

Use PHP.




None.

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



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).



None.

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



PHP is just much more widely supported that it's better than ASP, even.



None.

Nov 5 2007, 6:30 am Riney Post #5

Thigh high affectionado

I liek VB ;(



Riney#6948 on Discord.
Riney on Steam (Steam)
@RineyCat on Twitter

-- Updated as of December 2021 --

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



Quote from Dark_Marine_123
I liek VB ;(

PHP is like C/C++

So learn C++ cause its totally way better than VB shit.



None.

Nov 6 2007, 5:17 am Riney Post #7

Thigh high affectionado

Im no good at C++ or PHP, but very good at VB, God can someone leave an answer instead of critism?



Riney#6948 on Discord.
Riney on Steam (Steam)
@RineyCat on Twitter

-- Updated as of December 2021 --

Nov 6 2007, 8:31 am MindArchon Post #8



)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 :)



None.

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



@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).



None.

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



Quote from Dark_Marine_123
Im 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....

Post has been edited 3 time(s), last time on Nov 6 2007, 10:34 pm by Kellimus.



None.

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



Don't be like Kellimus and constantly go in and out of <?php ?>, it's ugly.



None.

Nov 7 2007, 9:58 am Riney Post #12

Thigh high affectionado

Is the term Completely Lost avaible?



Riney#6948 on Discord.
Riney on Steam (Steam)
@RineyCat on Twitter

-- Updated as of December 2021 --

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



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.




None.

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



Quote from Dark_Marine_123
I 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.



None.

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



Quote from DT_Battlekruser
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.

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

Thanks for the flame, :D



None.

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



He clearly is not an advanced programmer, so throwing things out like eregi() is pretty counterproductive.



None.

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



Quote from Kellimus
Thanks for the flame, :D

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



None.

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



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"



None.

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



Quote from Syphon
Quote from Kellimus
Thanks 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 Falkoner
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"

PHP can do more complex things than Javascript..



None.

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



But there's some things Javascript can do that PHP can't :P



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[05:00 pm]
lil-Inferno -- benis
[10:41 am]
v9bettel -- Nice
[01:39 am]
Ultraviolet -- no u elky skeleton guy, I'll use em better
[10:50 pm]
Vrael -- Ultraviolet
Ultraviolet shouted: How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
hey cut it out I'm getting all the minerals
[10:11 pm]
Ultraviolet -- :P
[10:11 pm]
Ultraviolet -- How about you all send me your minerals instead of washing them into the gambling void? I'm saving up for a new name color and/or glow
[2024-4-17. : 11:50 pm]
O)FaRTy1billion[MM] -- nice, now i have more than enough
[2024-4-17. : 11:49 pm]
O)FaRTy1billion[MM] -- if i don't gamble them away first
[2024-4-17. : 11:49 pm]
O)FaRTy1billion[MM] -- o, due to a donation i now have enough minerals to send you minerals
[2024-4-17. : 3:26 am]
O)FaRTy1billion[MM] -- i have to ask for minerals first tho cuz i don't have enough to send
Please log in to shout.


Members Online: Roy, Ultraviolet