If it is the tag value in html, how do I get it in php?
html:
<select>
<code> <option name="new_class_info" value="recommend">推荐</option> </code>
php:
$sql="INSERT INTO info_look (new_class) values ('$_POST[new_class_info]')";
I posted a post yesterday, thanking everyone for your help. There is another question that I didn’t think of at the time, which is that what I want to get in $_POST[new_class_info] is the value. How should I write it here? If it is written as [new_class_info.value] , doesn’t “.” in php mean +? Please answer
ps: Some friends reminded me that user input variables cannot be directly inserted into sql. Because I am a beginner and have not considered security issues here, so currently I only need to pass in the value to make my database record. Thank you everyone
Reply content:
html:
<select>
<code> <option name="new_class_info" value="recommend">推荐</option> </code>
php:
$sql="INSERT INTO info_look (new_class) values ('$_POST[new_class_info]')";
I posted a post yesterday, thanking everyone for your help. There is another question that I didn’t think of at the time, which is that what I want to get in $_POST[new_class_info] is the value. How should I write it here? If it is written as [new_class_info.value] , doesn’t “.” in php mean +? Please answer
ps: Some friends reminded me that user input variables cannot be directly inserted into sql. Because I am a beginner and have not considered security issues here, so currently I only need to pass in the value to make my database record. Thank you everyone
Your name
attribute should be set on the select
element. When the form is submitted, the form elements will be submitted as name-value pairs. For the select
element, the value of the name
attribute of select
is used as the name, and the value of the value
attribute of the selected option
element is used as the value.
For example
<select name="foo"> <option value="bar1"> <option value="bar2"> </select>
If you select the first option to submit, the name-value pair of foo=bar1
will be submitted.
If you use the post method to submit, you can use the $_POST
array to access it in php. For example, the form above will have the $_POST['foo']
member, and the value is 'bar1'
.
The poster above has already said it very well. I don’t know if the poster understands it. Let me add a few more words. The poster said <select>
This is included under the tag <form>
(form), < form>
The action attribute is defined to indicate where the form is to be submitted, which is your PHP. When submitting, the contents of the form form key-value pairs and are passed to your PHP. The key is the name attribute of the tag, and the value is the value attribute. So the POST passed to PHP is similar to this [' new_class_info' => 'recommend']
, so you only need to get the new_class_info item of this array. For example: $_POST['new_class_info']

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c
