In most cases, we specify another URL address to process the form content to the action attribute, but in some cases, we need to submit the form data to ourselves. In this case, how should we specify the action attribute value?
<? PHP
If (isset ($ _ post ['action']) & $ _ post ['action'] = 'submitted '){
Print '<PRE> ';
Print_r ($ _ post );
Print '<a href = "'. $ _ server ['php _ Self '].'"> Please try again </a> ';
Print '';
}else {
?>
name:
Email:
beer:
warthog guinness
}< BR >?>
the preceding
Code submits the form to itself (note: for versions earlier than php4.1.0, use $ _ http_post_vars to replace the $ _ post variable in the following code ). Here, the server variable $ _ server is used to obtain the URL address of the current page and assign it to the action attribute of the form. A small trick is used here to determine whether a POST request or GET request is received by the server. Add a Hidden variable to the form. when processing the request, we use the isset function to check whether this Hidden variable is set. Then, we can determine whether the request uses the post or get method.