404找不到$ _Server ['PHP_SELF']

时间:2013-07-28 11:33:01

标签: php html forms

我与数据库建立连接以将表单发送到数据库但是当我使用提交按钮时,它说:“找不到

在此服务器上找不到请求的URL / php / GIP /'$ _SERVER ['PHP_SELF']'。“

echo '<td><form action=" \' $_SERVER[\'PHP_SELF\'] \' " method="POST" class="Keuze">
        <select  name="Keuze"> 
        <option>0</option> 
        <option>1</option> 
        <option>2</option> 
        <option>3</option> 
        <option>4</option> 
        <option>5</option> 
        </select> 
        <p><input type="submit" name="submit" value="Bestellen"></p> 
        </form></td>';

如何解决这个问题,以便找到它,如果我想使用与此文件不同的文件,我已经开始工作了,我应该怎么做?

2 个答案:

答案 0 :(得分:3)

你的弦乐形成有几个问题。

 action=" \' $_SERVER[\'PHP_SELF\'] \' " 
          ^-----------^---------^---^--- you have escaped the 
 terminating single quotes causing the string to not terminate. 
 also you have escape the single quotes in key association. also
 you have included the variable inside a single quote block causing the 
 variable not to expand. the result is a literal  $_SERVER['PHP_SELF'] ' 
 being displayed.

处理这种情况的正确方法如下

echo '<td><form action="' . $_SERVER['PHP_SELF'] . '" .....

答案 1 :(得分:0)

echo '<td><form action=" '. $_SERVER['PHP_SELF'] .' " method="POST" class="Keuze">
        <select  name="Keuze"> 
        <option>0</option> 
        <option>1</option> 
        <option>2</option> 
        <option>3</option> 
        <option>4</option> 
        <option>5</option> 
        </select> 
        <p><input type="submit" name="submit" value="Bestellen"></p> 
        </form></td>';

你必须加入字符串