国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Form processing for beginners in PHP

PHP Forms and User Input

The $_GET and $_POST variables in PHP are used to retrieve information in the form, such as user input.

PHP Form Processing

One very important thing to note is that when processing HTML forms, PHP can automatically make form elements from the HTML page available to PHP scripts.

Example

The following example contains an HTML form with two input boxes and a submit button.

form.html file code is as follows:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>php中文網(wǎng)(php.cn)</title>
</head>
<body>
    <form method="post" action="welcome.php">
	姓名:<input type="text" name="name"></br></br>
	年齡:<input type="text" name="age"></br></br>
	<input type="submit" value="提交">
    </form>
</body>
</html>

When the user fills out the above form and clicks the submit button, the form data will be sent to the PHP file named "welcome.php" :

welcome.php file is as follows

<?php    
	header("Content-type: text/html; charset=utf-8");
    //本文件名是welcome.php  
    $name=$_POST['name'];
    $age = $_POST['age'];
      
    echo "歡迎".$name."!</br>";    
    echo "您的年齡是:".$age."歲!";    
    //本段代碼是結(jié)合上段代碼一起使用的,建議在本地新建倆個(gè)文件,form.html  提交到 welcome.php    
?>

?

Continuing Learning
||
<html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <form action="welcome.php" method="post"> 名字: <input type="text" name="fname"></br></br> 年齡: <input type="text" name="age"></br></br> <input type="submit" value="提交"> </form> </body> </html>
submitReset Code