Available Information and Input Form Data
Forms in PHP: Example (1)
extract_names.php
<! DOC TY PE html >
<html >< head >< title > N ame Ex tr ac tion </ title > </ head > < body >
<? php
re qui r e_o nce ' ex tra cti on . php ' ;
if ( is se t ( $ _SE RV ER [ ' RE QUE S T_M ETH O D ' ]) &&
$_ SER VE R [ ' REQ UES T _ME THO D '] == ' POST ' &&
isset ( $ _R EQU EST [ ' url ' ])) {
$ e x tra c ted _ nam e s = ex tra c t_n ame s ( $ _ REQ UES T [ ' url ' ]);
ech o "<div > The na mes o ccu rri ng in <br > " , html spe c ial c har s ( $ _ R EQ U ES T [ ' url ' ]) ,
" <br > are </ div > $ ex trac t ed_ n ame s \ n";
} else {
ech o <<< FOR M
< form m et hod =" post " >
<label > Enter a URL :
< in pu t type =" text " nam e = " url " size = " 100 "
value = " htt p :// cgi . csc . liv . ac . uk /
∼
ul lr ich / COMP 28 4 / t es ts / a1 te st1 . txt " >
</label ><br > < br >
< in pu t type =" submit " val ue = " Extr ac t N am es " >
</form >
FOR M ;
}
?>
</body > </ html >
http://cgi.csc.liv.ac.uk/
~
ullrich/COMP519/examples/extract_names.php
COMP519 Web Programming Lecture 23 Slide L23 – 11