إعلانيمكن أن تكون علامتك التجارية هناعلامتك التجارية هنافي كل صفحة من Darslab · طلاب وأولياء أمور ومعلمونinfo@darslab.comاسأل عن الأسعارالأسعارinfo@darslab.com
☰ خطة العام · تكنولوجيا المعلومات والاتصالات (بالإنجليزية)

switch, forms and the Add Term page

الأسبوع 13 · الوحدة ٣ «إنشاء صفحات الموقع» (٦) الموضوعان الثاني والثالث: جملة switch؛ صفحة Add_Term.php: تصميم النموذج، GET وPOST، عناصر النموذج، تضمين صفحتي الترويسة والاتصال · 3 دروس
2

Forms: GET or POST?

ICT Secondary 2 Term 1, Unit 3, Topics 2–3: pp. 93–100
GoalExplain what a form is and choose between GET and POST.
New words
form · the part of a page that collects values from the visitor and sends them to the servermethod · how the form sends its data: get or postaction · the page that receives the datacontrol · one input of a form, such as a text box or a button
Explanation

A form lets a visitor send data to the server. The form tag has two main attributes. action names the page that receives the data, for example add_term.php. method says how the data travel. With get, the data are added to the address, for example search_term.php?term=router. This is good for a search, because the address can be saved and shared, but never for anything private. With post, the data are sent inside the request and do not appear in the address; it suits adding or changing data. But post is not a secret by itself: without a protected connection the data can still be read on the way. Limits on how much can be sent are set by the browser and the server, so do not rely on a number. A form that sends a picture file also needs enctype="multipart/form-data". For scale, a server might allow an upload of at most 2 MB (we use 1 MB = 1,024 KB, and 1 KB = 1,024 bytes), but the real limit is the server’s setting.

GETPOST
Where do the data go?into the addressinside the request, not shown
Good forsearching; pages you may saveadding or changing data
For passwords?neveronly with a protected connection
Size limitset by browser and serverset by server settings
Worked examples
Html
1<form method="get" action="search_term.php">
2<input name="term" type="text">
3<input type="submit" value="Search">
4</form>
Output
The page shows a text box and a button labelled Search. After a click with the word router, the address ends with search_term.php?term=router.
A search form with method get. If the visitor types router and clicks the button, the browser asks for search_term.php?term=router, and the typed word is visible in the address.
NeedMethodReason
search for a termGETthe address can be saved and shared
add a new termPOSTit changes data and has long text
sign in with a passwordPOST, with a protected connectionnever in the address, and still not secret by itself
Mona chooses the method for each need and gives the reason.
Class activity

On paper make a table of four forms on a school website (search the library, send a message to the club, enter a mark, ask for a password reminder). Choose GET or POST for each and write a one-line reason. Mark which one needs enctype for a file.

Practice
1
What does the action attribute of a form name?
2
Where do the data of a GET form appear?
3
Is POST secret by itself? Explain.
4
Which extra attribute does a form need to send a picture file?