search
HomeBackend DevelopmentPHP TutorialPHP 表单传递参数与获取参数问题

<html><head><title>Register</title></head><body>	<?php	if (!isset($_POST['register1']) || ( $_POST['register1'] != 'Register'))	{			#echo "test1";	?>	<h1 id="Registration">Registration</h1>	<form method = "post" action = "register.php">		<table>			<tr><td>E-mail address:</td>				<td><input type='text' name = 'email'/></td>			</tr>			<tr><td>First Name:</td>				<td><input type = 'text' name = 'first_name'/></td>			</tr>			<tr><td>Last Name:</td>				<td><input type = 'text' name = 'last_name'/></td>			</tr>			<tr><td>PassWord:</td>				<td><input type = 'password' name = 'password'/></td>			</tr>			<tr>				<td colspan = '2'>					<input type = 'submit' name = 'register1' value = 'Register'/>				</td>			</tr>		</table>	</form>	<?php		}		else		{	?>	E-mail:	<?php 		echo $_POST['email']; 	?>	<br />	Name:	<?php 		echo $_POST['last_name']; 	?>	<br />	Password:	<?php 		echo $_POST['password']; 	?>	<?php		}	?></body></html>


初学 PHP 问个问题 在这里 获取
E-mail:
echo $_POST['email']; 
?>


Name:


Password:

这些信息时 只输出一个没问题 
当我输出多个的时候像这个样子的
E-mail:
echo $_POST['email']; 
?>


Name:
echo $_POST['last_name']; 
?>


Password:
echo $_POST['password']; 
?>
他就出错了 - -!!!
总是出现
An error occurred.

Sorry, the page you are looking for is currently unavailable.
Please try again later.

If you are the system administrator of this resource then you should check the error log for details.

Faithfully yours, nginx.
这个东西 只输出一个时就可以
各位大神请指教 


回复讨论(解决方案)

SF 不留 

<html><head><title>Register</title></head><body>    <?php    if (!isset($_POST['register1']) || ( $_POST['register1'] != 'Register'))    {            #echo "test1";    ?>    <h1 id="Registration">Registration</h1>    <form method = "post" action = "">        <table>            <tr><td>E-mail address:</td>                <td><input type='text' name = 'email'/></td>            </tr>            <tr><td>First Name:</td>                <td><input type = 'text' name = 'first_name'/></td>            </tr>            <tr><td>Last Name:</td>                <td><input type = 'text' name = 'last_name'/></td>            </tr>            <tr><td>PassWord:</td>                <td><input type = 'password' name = 'password'/></td>            </tr>             <tr>                <td colspan = '2'>                    <input type = 'submit' name = 'register1' value = 'Register'/>                </td>            </tr>        </table>    </form>    <?php        }        else        {    ?>    E-mail:    <?php         echo $_POST['email'];     ?>    <br />    Name:    <?php         echo $_POST['first_name'].$_POST['last_name'];     ?>    <br />    Password:    <?php         echo $_POST['password'];     ?>    <?php        }    ?></body></html>

我给你调成这样本地测试时可以了。

<html><head><title>Register</title></head><body>    <?php    if (!isset($_POST['register1']) || ( $_POST['register1'] != 'Register'))    {            #echo "test1";    ?>    <h1 id="Registration">Registration</h1>    <form method = "post" action = "">        <table>            <tr><td>E-mail address:</td>                <td><input type='text' name = 'email'/></td>            </tr>            <tr><td>First Name:</td>                <td><input type = 'text' name = 'first_name'/></td>            </tr>            <tr><td>Last Name:</td>                <td><input type = 'text' name = 'last_name'/></td>            </tr>            <tr><td>PassWord:</td>                <td><input type = 'password' name = 'password'/></td>            </tr>             <tr>                <td colspan = '2'>                    <input type = 'submit' name = 'register1' value = 'Register'/>                </td>            </tr>        </table>    </form>    <?php        }        else        {    ?>    E-mail:    <?php         echo $_POST['email'];     ?>    <br />    Name:    <?php         echo $_POST['first_name'].$_POST['last_name'];     ?>    <br />    Password:    <?php         echo $_POST['password'];     ?>    <?php        }    ?></body></html>

我给你调成这样本地测试时可以了。


弱弱的问下 改了下哪里 我把你这个代码复制下来 还是不可以 ,是不是有什么的放需要配置或者其他的呢? 

   
我给你调成这样本地测试时可以了。


看到你改的了  不过我改一下 还是不行  只输出一个时可以  输出多个时就不行了

<form method = "post" action = "">

给自己提交不写都可以。

<form method = "post" action = "">

给自己提交不写都可以。


也是不行 ,获取一个post值可以只要获取多个就不行了 ,我现在用的是阿里云的服务 配置的lnmp环境 
在想是不是跟那个配置有关系啊?

print_r($_POST);
看看是什么

print_r($_POST);
看看是什么



输入

输出的是
Array ( [email] => test@qq.com [first_name] => test_first [last_name] => test-last [password] => test_password [register1] => Register )
看这个输出应该是对的 - -! 

???,?有??。
你既然能print_r出?。表示可以?取到的。

???,?有??。
你既然能print_r出?。表示可以?取到的。


是的 现在怀疑是不是哪里配置出问题了 又或者其他的  单独取一个是可以的 取多个的时候  就不干活了  

你这个应该是服务器的问题吧,代码获取没有什么问题。

检查一下错误日志看报什么错误。PHP的错误提示功能也打开试试。

你这个应该是服务器的问题吧,代码获取没有什么问题。



检查一下错误日志看报什么错误。PHP的错误提示功能也打开试试。



是的 应该是哪里配置的问题 等回去了再看吧

错误级别  的问题~你的错误级别的什么?

错误级别  的问题~你的错误级别的什么?


没有配置错误级别 ,使用的默认的错误级别?

从nginx中找到这个日志
2014/07/18 20:37:33 [error] 9397#0: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 118.199.7.180, server: localhost, request: "POST /zp/chapter5/register.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost", referrer: "http://localhost/zp/chapter5/register.php"

大神给分析下 是什么问题

从nginx中找到这个日志
2014/07/18 20:37:33 [error] 9397#0: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 118.199.7.180, server: localhost, request: "POST /zp/chapter5/register.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost", referrer: "http://localhost/zp/chapter5/register.php"

大神给分析下 是什么问题


这个报错可以看这里
http://www.php100.com/html/program/nginx/2013/0905/5522.html
测试你的代码是没问题的,看下ngnix的配置吧

试了各种方法 暂时没有找到解决办法 结贴了 

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
What is the best way to send an email using PHP?What is the best way to send an email using PHP?May 08, 2025 am 12:21 AM

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

Best Practices for Dependency Injection in PHPBest Practices for Dependency Injection in PHPMay 08, 2025 am 12:21 AM

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHP performance tuning tips and tricksPHP performance tuning tips and tricksMay 08, 2025 am 12:20 AM

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.

PHP Email Security: Best Practices for Sending EmailsPHP Email Security: Best Practices for Sending EmailsMay 08, 2025 am 12:16 AM

ThebestpracticesforsendingemailssecurelyinPHPinclude:1)UsingsecureconfigurationswithSMTPandSTARTTLSencryption,2)Validatingandsanitizinginputstopreventinjectionattacks,3)EncryptingsensitivedatawithinemailsusingOpenSSL,4)Properlyhandlingemailheaderstoa

How do you optimize PHP applications for performance?How do you optimize PHP applications for performance?May 08, 2025 am 12:08 AM

TooptimizePHPapplicationsforperformance,usecaching,databaseoptimization,opcodecaching,andserverconfiguration.1)ImplementcachingwithAPCutoreducedatafetchtimes.2)Optimizedatabasesbyindexing,balancingreadandwriteoperations.3)EnableOPcachetoavoidrecompil

What is dependency injection in PHP?What is dependency injection in PHP?May 07, 2025 pm 03:09 PM

DependencyinjectioninPHPisadesignpatternthatenhancesflexibility,testability,andmaintainabilitybyprovidingexternaldependenciestoclasses.Itallowsforloosecoupling,easiertestingthroughmocking,andmodulardesign,butrequirescarefulstructuringtoavoidover-inje

Best PHP Performance Optimization TechniquesBest PHP Performance Optimization TechniquesMay 07, 2025 pm 03:05 PM

PHP performance optimization can be achieved through the following steps: 1) use require_once or include_once on the top of the script to reduce the number of file loads; 2) use preprocessing statements and batch processing to reduce the number of database queries; 3) configure OPcache for opcode cache; 4) enable and configure PHP-FPM optimization process management; 5) use CDN to distribute static resources; 6) use Xdebug or Blackfire for code performance analysis; 7) select efficient data structures such as arrays; 8) write modular code for optimization execution.

PHP Performance Optimization: Using Opcode CachingPHP Performance Optimization: Using Opcode CachingMay 07, 2025 pm 02:49 PM

OpcodecachingsignificantlyimprovesPHPperformancebycachingcompiledcode,reducingserverloadandresponsetimes.1)ItstorescompiledPHPcodeinmemory,bypassingparsingandcompiling.2)UseOPcachebysettingparametersinphp.ini,likememoryconsumptionandscriptlimits.3)Ad

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.