Home > Backend Development > PHP Tutorial > Interaction between PHP and Web pages

Interaction between PHP and Web pages

不言
Release: 2023-04-02 12:22:02
Original
2978 people have browsed it

This article mainly introduces the interaction between PHP and Web pages. It has a certain reference value. Now I share it with everyone. Friends in need can refer to it

1.form form default situation The way to submit data is the get method.

2. The predefined variables used by PHP scripts to process form data are $_GET, $_POST (case sensitive)

Code example (Pay special attention to adding the array when adding the checkbox attribute name)

##simpleTest.html

<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Insert title here</title></head><body><form action="simpleForm.php" method="post">
    用户名:<input type="text" name="username"><br>
    密码:<input type="text" name="password"><br>
    <!-- 复选框 -->
     学过的编程语言是:<br>
    <input type="checkbox" name="language[]" value="PHP">php    
    <input type="checkbox" name="language[]" value="java">java    
    <input type="checkbox" name="language[]" value="C#">C#    
    <input type="checkbox" name="language[]" value="C++">C++<br>
    <input type="submit" value="提交" ></form></body></html>
Copy after login

simpleFoem. php

<?php
if(!empty($_POST["username"])){    
if($_POST["username"]=="zhangsan"&&$_POST["password"]=="123"){        
echo "欢迎您:".$_POST["username"]."<br/>";        
echo "学过的编程语言:";        
foreach ($_POST["language"] as $value){            
echo  $value;
            
        }
        
    }else {        
    echo "用户名密码错误";
    }
}    
?>
Copy after login

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

Analysis of PHP’s AOP ideas

Introduction to installing xhprof for performance analysis in PHP 7.1

The above is the detailed content of Interaction between PHP and Web pages. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template