-1

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

在此服务器上找不到请求的 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>';

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

4

2 回答 2

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'] . '" .....
于 2013-07-28T11:39:20.467 回答
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>';

你必须加入字符串

于 2013-07-28T11:37:39.103 回答