I Recently took a break from life and decided to take another crack at this. I ran into a problem. I decided to stick with html forms to see what it would be like compared to htmllib. To put it bluntly.... I dont know where to stick what, where .
Im confused on how to retrieve data from my forms, and not only how to access them but to display them from the same page are at. (ie: if I register at href = ?register, to end up at href=?register with the results of the form)
Simplified Basics: (removed css styles/dynamic clock, and links to my other pages, page counter, etc)
CGI
New()
Topic(href,href_list[])
var/display
if(href == "S1_Register1")
display += S1_Register1
display += register_form // FORM
usr << browse("[display]")
My quick intro to character registration:
var/S1_Register1 = {"
<BR>
<CENTER>(banner)</CENTER>
<BR>
<CENTER><U>Server 1: Character Registration Step 1 </U></CENTER>
<CENTER>(<A class = "Special" href = ?S1_Entrance2>Back</A>)</CENTER>
"}
and my quick form. dont mind the forced spaces.. -_-; tried to make it look decent. lol.
var/register_form = {"<BR>
<table width = 45% align = center border = 1 cellpadding = 0 cellspacing = 0>
<TR><TD align = right>
<form action = "byond://" method = "get">
<input type="hidden" name="action" value="register_form">
(*) Required Field.<BR>
*Character Name: <font color = (4-16) <input name = "NAME" value = ""><BR>
Email: <input name = "EMAIL" value = ""><BR>
*Password: (4-16) <input name = "PASSWORD" type = "password" value = ""><BR>
*Repeat Password: <input name = "PASSWORD_REPEAT" type = "password" value = ""><BR>
*Gender:
<input type="radio" name="GENDER" value="0"> Male   
<br><input type="radio" name="GENDER" value="1"> Female
<br>*Race:
<input type="radio" name="RACE" value="0"> Werewolf
<br><input type="radio" name="RACE" value="1"> Vampire  
<br><CENTER><input type = "submit" name = "register_form" value = "Submit"</CENTER></BR>
</form>
</TD></TR>
</table>
"}
and now I ask, what next? I am pretty sure I did something wrong somewhere :P How do I check to see if "NAME" has between 4-16 characters, for example? (and display it on the screen whether it was a success)
I understand that from what I can tell, I need to use client/Topic(href,href_list[]), but how? all tuts seem a bit vague (not saying they are not uninformative, they were great thus far).
2 scenario's which have been bugging me for the last few hours.
a) how do I update the page and check if its all been successful or not. (or whether or not they missed a required field)
b) how do I move the field in password and put it into a variable?
I have more problems but I think if I can get those two, I can figure the rest out for the most part :P
... I'm not touching that one. What I will offer up is my own code:
Note that on top of this you can use JavaScript to verify the name & e-mail to make sure they're filled in before the user submits the form. However, JavaScript is client-side and may not work on every computer. What it will do, however, is cut down on bandwidth (no network traffic), is speedy (works as fast as the clients' processor can... very fast) and preserves the original page (and thus the form input).
I personally dislike htmllib because I find it to be harder than the real thing. You might feel inclined to agree to, if you look at the above code and the hordes of HtmlLayout() and ProcessHTML() and other crap htmllib wants you to use. Plus, the code above is raw HTML: you can include your own variables at any time. If you try this within htmllib's HtmlLayout() proc, it will assume it's a variable and will go <font color="red">b</font><font color="blue">e</font><font color="blue">r</font><font color="red">s</font><font color="blue">er</font><font color="red">k</font><font color="blue">er</font> on your page.
-- Data