[英]$_POST is not returning anything in PHP
I have _header.tpl inside inc folder here is full path C:\\WebServerN\\home\\localhost\\www\\e-test.ru\\inc\\templates\\default_header.tpl Inside _header.tpl I added 我在inc文件夹中有_header.tpl,这里是完整路径C:\\ WebServerN \\ home \\ localhost \\ www \\ e-test.ru \\ inc \\ templates \\ default_header.tpl我在_header.tpl中添加了
<td width="85%" align=right class=top_section>
<form action="init.inc.php" method='post'>
<select name="switchlanguage" id="switchlanguage">
<option value="en" >English</option>
<option value="ru" >Русский</option>
<option value="tj" >Точики</option>
</select>
</form>
</td>
In order to make dropdown listbox for language switching. 为了使下拉列表框进行语言切换。 What I want is to get "en", "ru", "tj" if they are chosen.
我想得到的是“ en”,“ ru”,“ tj”(如果已选择)。 I have init.inc.php here is full path C:\\WebServerN\\home\\localhost\\www\\e-test.ru\\inc\\init.inc.php I want to switch code according to chosen value.
我有init.inc.php,这里是完整路径C:\\ WebServerN \\ home \\ localhost \\ www \\ e-test.ru \\ inc \\ init.inc.php我想根据选择的值切换代码。 Here is my code in init.inc.php
这是我在init.inc.php中的代码
if(!isset($_POST['switchlanguage']))
{
include_once($DOCUMENT_LANG.'en.lng.php');
}
else
{
include_once($DOCUMENT_LANG.$_POST['switchlanguage'].'.lng.php');
}
I am new in PHP, I need your help. 我是PHP新手,需要您的帮助。 Please give me some direction or will be better if you provide me some codes.
请给我一些指导,或者如果您提供一些代码,将会更好。 Thanks.
谢谢。
The problem was I did not have submit button. 问题是我没有提交按钮。 In order to get $_POST I need somehow submit the form.
为了获得$ _POST,我需要以某种方式提交表单。 So I could not use button due to design issues.
因此由于设计问题,我无法使用按钮。 I used auto submit.
我使用了自动提交。 Here is my code.
这是我的代码。
<td width="85%" align=right class=top_section>
<form method='post'>
<select name="switchlanguage" onchange="this.form.submit()">
<option value="en" >English</option>
<option value="ru" >Русский</option>
<option value="tj" >Точики</option>
</select>
</form>
</td>
That's it! 而已!
Remove all the semicolon you have given in all the option tag end. 删除所有选项标签末尾给出的所有分号。 So your code should be like the below.
因此,您的代码应如下所示。
<td width="85%" align=right class=top_section>
<form action="init.inc.php" method='post'>
<select name="switchlanguage" id="switchlanguage">
<option value="en" >English</option>
<option value="ru" >Русский</option>
<option value="tj" >Точики</option>
</select>
</form>
</td>
Now check it out. 现在检查一下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.