Previous Thread
Next Thread
Print Thread
Rate Thread
#19368 09/26/05 06:05 PM
Joined: Sep 2005
Posts: 102
T
Testing Offline OP
UGN Member
OP Offline
UGN Member
T
Joined: Sep 2005
Posts: 102
Ok, so in my quest to be "MR PHP" I just finished the chapter on form validation. The chapter was easy and makes plenty of sense. All pretty straight forward. however while surfing around finding info on forms it appears to be a huge subject.

Apparently there are all friggin kind of forms to make and a million different ways to do it. Are forms an entire section worth focusing on within HTML. I can use dreamweaver and yes edit basic code manually but im no way an html guru. So I guess I should ask instead how large is the issue of forms?

#19369 09/26/05 07:26 PM
Joined: Dec 2002
Posts: 3,255
Likes: 3
UGN Elite
Offline
UGN Elite
Joined: Dec 2002
Posts: 3,255
Likes: 3
Forms are easy. HTML forms are easy enough. Basicaly it is like this

Now I do not know what you know verses do not know so I will cover it all.

POST vs GET

Get - variables are in the URL going to the script processing forum.

Post - variables are not chown in the URL However variables migh be easily passed still using the URL, be sure to guard against this.


Code
  
<form action="http://URL_to_you_form_processing_script.php" Method="POST">

<!--
drop down menu
//-->
     <select name="my_first_var">
          <option value="option 1">option 1</option>
          <option value="option 2">option 2<option>
     </select>


<!--
text input
//-->
Login:

<input type="text" name="login">




<!--
password input
//-->
Password:
<input type="password" name="psswd">



<!--
text area (large amounts of test like the BBS input fields here)
//-->
<textarea name="my_text_area"></textarea>




<!--
submit button
//-->
<input type="submit" name="my submit button">
Once submited the variables will be sent to

http://URL_to_you_form_processing_script.php

all the name="" will be your variables

See below

Code
$my_first_var =// this will be either "option 1" or "option 2"

$login = //whatever the user typed in for a login name.

$password = //whatever the user typed in for a password

$my_text_area = //lots and lots of text the user typed in
Now you can mix this with Javascript, vb script, DHTML and all sorts of stuff. I recomend to start stick with basic forms. They will work with all browsers, people understand how to use them, and it will help you get a better grasp on the PHP side. Trust me, when starting any script keep it simple at first till you have the PHP portions perfect, then tweek your HTML/XML/XHTML/CSS/Javascript/VB script.

All the html and other crap is for dissplay. It is just a way to put a dress and makeup on your data. You want to focus on using the data first. Focus on the PHP and use the basic HTML crap for now. Once you get PHP perfected, the HTML will take care of itself as you look to broaden your apps capabilites and style.


Once you have the data I recomend replacing some charaters..

Code
 
//replace < with  &#60;
$my_text_area = str_replace("<", "&#60;", "$my_text_area");

/*
the above code will read through everything the 
user submited in the textarea up top using the var
 "$my_text_area"  It will find each "<" and 
replace it with &#60; which will dissplay "<" in 
html but will break and tag based code the user 
tryed to submit.
*/


//replace " with   &#34;
$my_text_area = str_replace("\"", "&#34;", "$my_text_area");

/*
quotes can cause script problems.  There is 
something called magic quotes in PHP but we do not
 know if everyone has this enabled so we play it 
safe and make our script universal.  You have to 
escape quotes to use them.  We escape charaters 
with the "\" backslash.  For example the "$" is 
used to denote a variable.  So to echo it out to 
the browser...
*/

echo "\$29.95"; // will dissplay "$29.95";



//replace % with &#37;
$my_text_area = str_replace("%", "&#37;", "$my_text_area");


//replace @ with &#64;
$my_text_area = str_replace("@", "&#64;", "$my_text_area");



//replace @ with &#123;
$my_text_area = str_replace("{", "&#123;", "$my_text_area");
  

#19370 09/26/05 08:03 PM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
Learner, you need to learn XHTML validation damnit...

BAD:
Code

<hr>
<input type="text" name="name">
GOOD:
Code

<hr />
<input type="text" name="name" />
Any tag that OPENS must CLOSE...


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#19371 09/26/05 08:05 PM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
Oh, and if you want a good form check out the "contact us" page on the main UGN Security site.


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#19372 09/26/05 08:15 PM
Joined: Dec 2002
Posts: 3,255
Likes: 3
UGN Elite
Offline
UGN Elite
Joined: Dec 2002
Posts: 3,255
Likes: 3
I did not use XHTML, I used HTML as it works, requires less thought and will work from "EVERY browser"

#19373 09/26/05 08:29 PM
Joined: Feb 2002
Posts: 7,203
Likes: 11
Community Owner
Offline
Community Owner
Joined: Feb 2002
Posts: 7,203
Likes: 11
Show me a browser that does not support XHTML and I'll show you an old piece of [censored] that shouldn't be used...

Besides, XHTML is so easy it's stupid, I mean the only real differance of "Valid XHTML" compared to "Valid HTML" is that "every tag that opens must close"... Common sense in the first place no?


Donate to UGN Security here.
UGN Security, Back of the Web, and VNC Web Services Owner
#19374 09/27/05 03:57 AM
Joined: Dec 2002
Posts: 3,255
Likes: 3
UGN Elite
Offline
UGN Elite
Joined: Dec 2002
Posts: 3,255
Likes: 3
When learning a new language I find it is easiest to take away all bells and whistle from other languages and focus on the one I am learning. HTML is easier as it is more forgiving. The man is asking about forms... XHTML is easy to pick up, but when giving demos, I use HTML as it is like I say, more forgiving.

Put in a doctype tage have a few tags without the "/" and you might think your PHP is [censored] if you are new. We can sit here and argue XHTML vs HTML VS XML vs MSXML vs Who_give_a_fuck_ML. The fact is XHTML and HTML are pretty much the same [censored].

The tags are the same accept you have more slashes with XHTML. The end result is displaying your data in a neat tidy fashion. So Testing/Loan choose HTML or XHTML or whatever. The examples above still work with forms.


For a good tut on forms...

http://webmonkey.wired.com/webmonkey/99/30/index4a.html

That will have you up and running in no time. It does not talk about PHP, but covers HTML forms very nicely. If you want to drive yourself crazy as gizmo would have you do with slash fever just make sure every tag has a closing tag. If there is not closing tag the slash goes at the end of the opening tag.

Code
  //HTML


<br/> //XHTML
And Gizmo... We were using Netscape 4.7 up till last year at Verizon. No XHTML support, there are compaines who have not upgraded thier software.

#19375 09/28/05 12:36 AM
Joined: Sep 2005
Posts: 102
T
Testing Offline OP
UGN Member
OP Offline
UGN Member
T
Joined: Sep 2005
Posts: 102
Sintax/Learner Thanks for the link. I pretty much have forms down now. All in all its much more basic then I thought. Don't get me wrong,, I'm sure there are some pretty radical looking forms out there but in the end it seems they all follow the same rules.

Thanks again for the link.


Link Copied to Clipboard
Member Spotlight
Phatal
Phatal
Houston, TX
Posts: 298
Joined: April 2004
Forum Statistics
Forums41
Topics33,840
Posts68,858
Average Daily Posts1
Members2,176
Most Online3,253
Jan 13th, 2020
Latest Postings
Where and how do you torrent?
by danni75 - 03/01/24 05:58 AM
Animation,
by JohanKaariainen - 08/15/19 01:18 AM
Blackbeard.....
by Gremelin - 10/03/18 07:02 PM
my old account still exists!
by Crime - 08/10/18 02:47 PM
Okay WTF?
by HenryMiring - 09/27/17 01:45 AM
The History Thread...
by Gremelin - 08/11/17 12:11 PM
My friend NEEDS your HELP!
by Lena01 - 07/21/17 12:06 AM
I'm having fun with this guy.
by gabithompson730 - 07/20/17 01:50 AM
I want to upgrade my phone
by gabithompson730 - 07/20/17 01:49 AM
Doom 3
by Cyrez - 09/11/14 08:58 PM
Amazon Gift Card Generator/KeyGen?te
by Gecko666 - 08/22/14 09:21 AM
AIM scene 99-03
by lavos - 09/02/13 08:06 AM
Planetside 2
by Crime - 03/04/13 07:10 AM
Beta Testers Wanted
by Crime - 03/04/13 06:55 AM
Hello Everyone
by Gremelin - 02/12/12 06:01 PM
Tracfone ESN Generator
by Zanvin Green - 01/18/12 01:31 PM
Python 3 issue
by Testing - 12/17/11 09:28 PM
tracfone airtime
by Drache86 - 07/30/11 03:37 AM
Backdoors and the Infinite
by ZeroCoolStar - 07/10/11 03:52 AM
HackThisZIne #12 Releaseed!
by Pipat2 - 04/28/11 09:20 PM
gang wars? l33t-wars?
by Gremelin - 04/28/11 05:56 AM
Consolidate Forums
by diggin2deep - 04/21/11 10:02 AM
LAN Hacking Noob
by Gremelin - 03/12/11 12:42 AM
Top Posters
UGN Security 41,392
Gremelin 7,203
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Top Likes Received
Ghost 2
Cyrez 1
Girlie 1
unreal 1
Crime 1
Powered by UBB.threads™ PHP Forum Software 7.7.5