December 5
Gli utenti compilare i moduli delle pagine Web per una serie di motivi: per scaricare il software, per la registrazione per i siti web e per l'acquisto di prodotti. Una cosa che queste forme hanno in comune è che essi raccolgono i dati ed elaborare in qualche modo. Ci sono molte lingue che possono essere utilizzati per modificare i dati di un modulo Web. Questi linguaggi accettano i dati degli utenti ed elaborarlo scrivendo a una pagina Web, un database o in un file.
1 Aprire un editor di testo e creare una pagina Web con una forma scritta in HTML. Questa forma ha due campi di input: uno per il primo nome dell'utente e l'altro per il cognome dell'utente. Aggiungere un pulsante di invio di sotto dei due campi di input. Nome del file process_php.html e salvarlo in un server Web.
<Html>
<Body>
<Form>
Nome: <input name = tipo "first_name" = "text">
Cognome: <input name = tipo "last name" = "text">
<Input type = "submit">
</ Form>
</ Body>
</ Html>
2 Utilizzare l'editor di testo per creare un nuovo file chiamato process_php.php. Questo file verrà chiamato quando l'utente compila e invia il modulo in process_php.html. Lo script accetta i valori del nome e degli ultimi campi Nome e li stampa in formato HTML. Salvare process_php.php al server Web.
<? Php
$ First_name = $ _POST [ 'first_name'];
$ Last_name = $ _POST [ 'cognome'];
echo "Il primo nome è". $ First_name;
echo "L'ultimo nome è". $ Last_name;
?>
3 Modifica process_php.html. Assegnare l'azione sul modulo per process_php.php. Utilizzare l'attributo metodo per specificare che dovrebbe essere presentato con il metodo POST e salvare il file.
<Html>
<Body>
<Form action = metodo "process_php.php" = "post">
Nome: <input name = tipo "first_name" = "text">
Cognome: <input name = tipo "last name" = "text">
<Input type = "submit">
</ Form>
</ Body>
</ Html>
4 Utilizzando un browser Web per accedere dal server Web, process_php.html aperto. Compila il form e clicca su "Invia" per elaborare i dati.
5 Aprire un editor di testo e creare una pagina Web con una forma scritta in HTML. Questa forma ha due campi di input: una per nome della via per l'utente e uno per il codice di avviamento postale dell'utente. Aggiungere un pulsante di invio di sotto dei due campi di input. Nome del file process_perl.html e salvarlo in un server Web.
<Html>
<Body>
<Form>
Via: <input name = tipo "STREET_NAME" = "text">
CAP: <input name = tipo "zip_code" = "text">
<Input type = "submit">
</ Form>
</ Body>
</ Html>
6 Utilizzare l'editor di testo per creare un nuovo file chiamato process_perl.pl. Questo file verrà chiamato quando l'utente compila e invia il modulo in process_perl.html. Lo script prende i valori dalla nome della strada ei campi CAP e li stampa in formato HTML. La prima riga dello script è il percorso di Perl sul server Web. Salvare process_perl.pl a un server Web.
! path_to_perl
if ($ ENV { 'REQUEST_METHOD'} eq 'post') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@kvs = split (/ & /, $ buffer);
foreach $ Kvs (@kvs) {
(Nome $, $ value) = split (/ = /, $ kvs);
$ Form {$ nome} = $ value;
}
}
print "Content-Type: text / html \ n \ n";
print "<html> <head> <title> </ title> </ head>";
print "<body>";
print $ form {STREET_NAME};
print $ form {zip_code};
print "</ body> </ html>";
7 Modifica process_perl.html. Assegnare l'azione sul modulo per process_perl.pl utilizzare l'attributo metodo per specificare che dovrebbe essere presentata utilizzando il metodo POST e salvare il file.
<Html>
<Body>
<Form action = metodo "process_perl.pl" = "post">
Via: <input name = tipo "STREET_NAME" = "text">
CAP: <input name = tipo "zip_code" = "text">
<Input type = "submit">
</ Form>
</ Body>
</ Html>
8 Utilizzando un browser Web per accedere dal server, process_perl.html. Compila il form e clicca su "Invia" per elaborare i dati.
9 Aprire un editor di testo e creare una pagina Web con una forma scritta in HTML. Questa forma ha due campi di input: uno per l'età dell'utente e una per città dell'utente. Aggiungere un pulsante di invio di sotto dei due campi di input. Nome del file process_asp.html e salvarlo in un server Web.
<Html>
<Body>
<Form>
Età: <input name = tipo "età" = "text">
Città: <input name = tipo "città" = "text">
<Input type = "submit">
</ Form>
</ Body>
</ Html>
10 Aprire un editor di testo e creare un nuovo file chiamato process_asp.asp. Questo file verrà chiamato quando l'utente compila e invia il modulo scritto in process_asp.html. Lo script accede ai valori di età ei campi della città da process_asp.html e li stampa in formato HTML. Salvare process_asp.asp a un server Web.
<%
età Dim, città
età = Request.Form ( "l'età")
city = Request.Form ( "città")
Response.Write ( "Age:" & età)
Response.Write ( "Città:" & città)
%>
11 Modifica process_asp.html. Assegnare l'azione sul modulo per process_asp.asp. Utilizzare l'attributo metodo per specificare che dovrebbe essere presentata utilizzando il metodo POST e salvare il file.
<Html>
<Body>
<Form action = metodo "process_asp.asp" = "post">
Età: <input name = tipo "età" = "text">
Città: <input name = tipo "città" = "text">
<Input type = "submit" />
</ Form>
</ Body>
</ Html>
12 Utilizzando un browser Web per accedere dal server Web, process_asp.html aperto. Compila il form e clicca su "Invia" per elaborare i dati.