y the
i mit button,
When the user makes a selection and clicks the ESS
z ith no Spa
ser combine these elements in this order with no SP
|
, elements: |
. * tf |
oe word action nttp://localhos |
e URL in quotes after the :
| hese e following characters
. hi
A question mark (2) denoting that "
Constitute a query string:Web Programming Wing mi
; al sign, and the match;
ntrol name, an equal sig! ING val
A form con ug
(course=bca)
mpersand (&) and the next NAME-VALUE pair (Submitese
ny times as the server querystring-length limit allows.
a Ee) cated TT | Ee aa
[the browser thus constructs the URL string: —
|
| _etp://localhost/ course php?course =bca&Submit=Select |
~The get method of form handling offers one big advantage
ucts an actual new and differentiable URL. ues
this page. The result of forms Using
The g
the post method: It constr
string. Users can now bookmark
the post method is not bookmarkable.
The get method is not suitable for logins because the username ang
password are fully visible onscreen as well as potentially stored in the cen
browser's memory as a visited page.
Every get submission is recorded in the Web server log, data se
included.
Because the get method assigns data to a server environment variable,
the length of the URLis limited.
The post method
Post is the preferred method of form submission today, such as adding
information to a database. The form data set is included in the body of the
form when it is forwarded to the processing agent (in this case, PHP). No
visible change to the URL will result according to the different data
submitted,
The post method has these advantages:
° It is more secure than get because user-entered information ®
never visible in the URL query string, in the server logs,
precautions, such as always using the password HTMLinputN
for Passwords, are taken) onscreen.
There is a much larger limit on the amount of data thet con
Passed (a couple of kilobytes rather than a couple of hat
characters),anming using PHP
ot
“ nod has these disadvantages;
c
ot pe results at a given moment canny
* she results should be expired by the
eZ It if the user employs the Bac
resu! k
ot be bookmarked,
‘browser, ;
utton t
method can be incompatible with very
& that an error wilh
ms evisit the page
which strip the form data as a security menturay firewall setups,
3eigd9
exficfd hg.
pyp$ REQUEST Method
REQUEST is a super global variable which is widel
ne idely used to collect
several predefined variables in PHP are “superglobals”, which means
that they are always accessible, regardless of scope - and you can access
them from any function, class or file without having to do anything special.
the PHP superglobal variables are:
1. $GLOBALS 6. $_FILES
2 $_SERVER 7. $_ENV
3, $ REQUEST 8. $_COOKIE
4, $ POST 9. $_SESSION
5. $ GET
The $_ REQUEST variable is a variable with the contents of $_GET and
$PosT and $_COOKIE variables.
Syntax
’
echosubstr(“Hello world”, 7).
i
The length to be returned from the start
th to be returned from the end of the
gth is less thanWeb Programming Using py
Pp
_
te ae
| “echo “
oe ” fe
(Hello world”,-1):"
";
Ilo world”,-10).”
";
echosubstr("Hello world’ -8)."
";
echosubstr(“Hello world”,-4).”
";
ae
ative numb
echosubste'
echosubstr(“Hel
| j/nee
OUTPUT
d
ello world
lo world
orld
d
ello world
lo world
orld
explode()
Used to convert strings into an array variable
Syntax
explode ( $delimiter , $string )
delimiter : The boundary string
Sst ‘welcome to the world of php programming.”;
Print_r (explode(“ “Sstr));
>
This will produce following result “
Array {[0]=> welcome (1)
(d= pea =>to [2] => the [3] => world[4]=> of [7
10. stremp()
Itis used to compare two
stri i the?
eranesereenial ings. If this function returns 0,orig USNS tle
pes
tax
Vempi string sttiNB2)
— stig
getr2='hal’s
| scnostremp(Sstrd, $str2);,
2 a
output
0
ys. trim()
ttused to remove the whitespaces and other characters
syntax
trim(string,charlist)
string : It is used to specifies string to check
charlist : It specifies which character to remove
”;
echo trim($str,’php”);
b
OUTPUT
Php programming t
Programming |
2 acest |
case
Make the first character of a string value UPWeb Progranimiing Usin
180
tefirst) ng value lower case
13.
Make the fil
>
OUTPUT
rESPECT :
include and require functions in php
nctions that are used to put the contents of
file containing PHP source code into another PHP file. These function are
include() and Require(). These functions are ‘the'same if but they have one
difference. The difference is that the include() function produces warning,
but the script will continue execution, while the require() function produces
awarning and fatal error i.e. the script will not continue execution. These
are used to put the data of a file into another PHP file before
In PHP, there are two fui
two function:
it is executed by the server.
include() Function
Theinclude() function is used to put data of one PHP file into another |,
PHP file. If errors occur then theinclude() function produces a warning but
does not stop the execution of the script i.e. the script will continue to
execute.