PHP Forms (2)

Source: Internet
Author: User

Learning PHP forms is primarily about how the backend operates after the front end is passed through the submit. Now achieve an effect: Click Submit, the input box information will not be brushed off, refresh the page, the input box information is brushed off (index.php).

<?PHP$NAMEERR=$EMAILERR=$GENDERERR=$WEBSITEERR= ' ';$name=$email=$gender=$comment=$website= "";if($_server["request_method"] = = "POST") {   if(Empty($_post[' Name '])){       $NAMEERR= ' name is required '; }Else{       $name=$_post[' Name ']; }   if(Empty($_post[' Email '])){       $EMAILERR= "Email is required"; }Else{       $email=$_post[' Email ']; }   if(Empty($_post[' website '])){       $website= ""; }Else{       $website=$_post[' website ']; }   if(Empty($_post["Comment"])) {    $comment= ""; } Else {    $comment=$_post["Comment"]; }   if(Empty($_post[' Gender '])){       $GENDERERR= "Gender is required"; }Else{       $gender=$_post[' Gender ']; }}? ><!doctype html>$_server["Php_self"]);? > ">Name: <input type= "text" name= "name" value= "<?php Echo$name?> "> <spanclass= "Error" >* <?phpEcho $NAMEERR;? ></span> <br><br>E-Mail: <input type= "text" name= "email" value= "<?php Echo$email?> "> <spanclass= "Error" >* <?phpEcho $EMAILERR;? ></span> <br><br>Website: <input type= "text" name= "website" value= "<?php Echo$website?> "> <spanclass= "Error" ><?phpEcho $WEBSITEERR;? ></span> <br><br> <label>comment: <textarea name= "Comment" rows= "5" cols= "+" &GT;&LT;? PhpEcho $comment?></textarea> <br><br>Gender: <input type= "Radio" name= "Gender" value= "female" <?phpif(isset($gender) &&$gender= = ' female ')Echo"Checked";?>>Female<input type= "Radio" name= "Gender" value= "male" <?phpif(isset($gender) &&$gender= = ' Male ')Echo"Checked";?>>Male<spanclass= "Error" >* <?phpEcho $GENDERERR;? ></span> <br><br> <input type= "Submit" name= "submit" value= "Submit" > &LT;/FORM&GT;&L T;/body>

PHP Forms (2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.