Home  >  Article  >  Backend Development  >  mysql - php cannot get form data

mysql - php cannot get form data

WBOY
WBOYOriginal
2016-12-05 13:44:051347browse

1. In the environment built by wamp, the return value of using post to obtain form submission data is empty
The code is as follows:




    
    

Firstname: Lastname: Age:
alert('Your username is empty!');";
}else{
  var_dump($firstname);
}
?>

Error report: Notice: Undefined index: firstname in E:WebWeb SoftwarewampwwwDEMOtest.php

2. There is nothing wrong with the fact that the php server is Apache and the port number is also 80

3. Tried the get method, but still can’t get the data

mysql - php cannot get form data
mysql - php cannot get form data
mysql - php cannot get form data

I found my own problem: the html file was not opened from the same path as the php file~

Reply content:

1. In the environment built by wamp, the return value of using post to obtain form submission data is empty
The code is as follows:




    
    

Firstname: Lastname: Age:
alert('Your username is empty!');";
}else{
  var_dump($firstname);
}
?>

Error report: Notice: Undefined index: firstname in E:WebWeb SoftwarewampwwwDEMOtest.php

2. There is nothing wrong with the fact that the php server is Apache and the port number is also 80

3. Tried the get method, but still can’t get the data

mysql - php cannot get form data
mysql - php cannot get form data
mysql - php cannot get form data

I found my own problem: the html file was not opened from the same path as the php file~

Determine a few questions!

1. The test1.html and test.php files of this test are both in the same level directory DEMO.
2. Please do not use the file:// path to access your PHP file, ​​so that the PHP file will not be interpreted by the php.exe interpreter installed on your computer.
3. Please use the http:// protocol to access your test1.html, and fill in the correct values ​​to submit the form to test.php.
4. Please pay attention to whether your PHP file starts with or .

Confirm the above points and see if the problem still exists?

Test your code and there is no problem
mysql - php cannot get form data

Firstname: 

改成

Firstname: 

试试 name 和 value 之间少了一个空格吧
                            
            

mysql - php cannot get form data

Seems like there’s no problem?

Error report: Notice: Undefined index: firstname in E:WebWeb SoftwarewampwwwDEMOtest.php

This error is a Notice-level error and can be ignored. It wants to tell you that $firstname is already in use before it has been declared. But if you don't want it to happen, there are many ways. For example, modify php_error in php.ini.

Statement:
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