搜尋
首頁後端開發php教程PHP 表单传递参数与获取参数问题

<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的配置吧

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

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
如何使PHP應用程序更快如何使PHP應用程序更快May 12, 2025 am 12:12 AM

tomakephpapplicationsfaster,關注台詞:1)useopcodeCachingLikeLikeLikeLikeLikePachetoStorePreciledScompiledScriptbyTecode.2)MinimimiedAtabaseSqueriSegrieSqueriSegeriSybysequeryCachingandeffeftExting.3)Leveragephp7 leveragephp7 leveragephp7 leveragephpphp7功能forbettercodeefficy.4)

PHP性能優化清單:立即提高速度PHP性能優化清單:立即提高速度May 12, 2025 am 12:07 AM

到ImprovephPapplicationspeed,關注台詞:1)啟用opcodeCachingwithapCutoredUcescriptexecutiontime.2)實現databasequerycachingingusingpdotominiminimizedatabasehits.3)usehttp/2tomultiplexrequlexrequestsandreduceconnection.4 limitesclection.4.4

PHP依賴注入:提高代碼可檢驗性PHP依賴注入:提高代碼可檢驗性May 12, 2025 am 12:03 AM

依赖注入(DI)通过显式传递依赖关系,显著提升了PHP代码的可测试性。1)DI解耦类与具体实现,使测试和维护更灵活。2)三种类型中,构造函数注入明确表达依赖,保持状态一致。3)使用DI容器管理复杂依赖,提升代码质量和开发效率。

PHP性能優化:數據庫查詢優化PHP性能優化:數據庫查詢優化May 12, 2025 am 12:02 AM

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi

簡單指南:帶有PHP腳本的電子郵件發送簡單指南:帶有PHP腳本的電子郵件發送May 12, 2025 am 12:02 AM

phpisusedforsenderemailsduetoitsbuilt-inmail()函數andsupportivelibrariesLikePhpMailerAndSwiftMailer.1)usethemail()functionForbasiceMails,butithasimails.2)butithasimail.2)

PHP性能:識別和修復瓶頸PHP性能:識別和修復瓶頸May 11, 2025 am 12:13 AM

PHP性能瓶颈可以通过以下步骤解决:1)使用Xdebug或Blackfire进行性能分析,找出问题所在;2)优化数据库查询并使用缓存,如APCu;3)使用array_filter等高效函数优化数组操作;4)配置OPcache进行字节码缓存;5)优化前端,如减少HTTP请求和优化图片;6)持续监控和优化性能。通过这些方法,可以显著提升PHP应用的性能。

PHP的依賴注入:快速摘要PHP的依賴注入:快速摘要May 11, 2025 am 12:09 AM

依賴性注射(DI)InphpisadesignPatternthatManages和ReducesClassDeptions,增強量強制性,可驗證性和MATIALWINABIOS.ItallowSpasspassingDepentenciesLikEdenciesLikedAbaseConnectionStoclasseconnectionStoclasseSasasasasareTers,interitationAseTestingEaseTestingEaseTestingEaseTestingEasingAndScalability。

提高PHP性能:緩存策略和技術提高PHP性能:緩存策略和技術May 11, 2025 am 12:08 AM

cachingimprovesphpermenceByStorcyResultSofComputationsorqucrouctationsorquctationsorquickretrieval,reducingServerLoadAndenHancingResponsetimes.feftectivestrategiesinclude:1)opcodecaching,whereStoresCompiledSinmememorytssinmemorytoskipcompliation; 2)datacaching datacachingsingMemccachingmcachingmcachings

See all articles

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

WebStorm Mac版

WebStorm Mac版

好用的JavaScript開發工具

Dreamweaver Mac版

Dreamweaver Mac版

視覺化網頁開發工具