Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PHP上显示HTML表单值_Php_Html_Forms - Fatal编程技术网

在PHP上显示HTML表单值

在PHP上显示HTML表单值,php,html,forms,Php,Html,Forms,这是test.html <!DOCTYPE html> <html> <body> <form method="POST" action="test.php"> <table> <tr> <th>content_id</th> <th>title</th> <th>image</th> </tr> <tr> <t

这是test.html

<!DOCTYPE html>
<html>
<body>
<form method="POST" action="test.php">
<table>

<tr>
 <th>content_id</th>
 <th>title</th>
 <th>image</th>
</tr>

<tr>
 <td><input type="text" name="content_id" size="26"></td>
 <td><input type="text" name="title" size="26"></td>
 <td><input type="text" name="image" size="26"></td>
</tr>

</table>
<input type="button" id="cancel" name="cancel" value="Cancel"> <a href="index.php"/></a>
<button type="submit" id="submit" value="Submit">Submit</button>
</form>
</body>
</html>

内容标识
标题
形象
提交
这是test.php

<?php 
error_reporting(E_ALL);ini_set('display_errors','1');

echo $_POST["content_id"];
echo $_POST["title"];
echo $_POST["image"];
?>

我想将表单的值传递给PHP并显示它,但它却显示了这一点

编辑:我为这个含糊不清的问题道歉,谢谢大家的帮助

  • 由于语法无效,出现错误(500)。不能混合使用文本和命令

  • 有两种向PHP发送数据的方法<代码>获取和
    发布
    GET
    在URL参数中发送信息,
    POST
    在标题中发送数据。您必须使用适当的PHP方法来获取每种格式的数据。如果将HTML表单中的方法设置为
    POST
    ,则应在PHP中使用
    \u POST

  • 
    
  • 将来,您应该查看
    错误日志
    ,或者启用错误报告,以便可以看到PHP运行时的实际结果。有关详细信息,请参见

  • 500错误是因为Welcome不是可执行的PHP代码。将其置于
    标记之外

    您的表单方法正在使用GET,您的test.php应该是:

    <?php
     echo $_POST["content_id"];
     echo $_POST["title"];
     echo $_POST["image"];
    ?>
    
    
    
    您的表单将丢失其结束标记和提交按钮:

    <form method="POST" action="test.php">
        <table>
        <tr>
         <th>content_id</th>
         <th>title</th>
         <th>image</th>
        </tr>
    
        <tr>
         <td><input type="text" name="content_id" size="26"></td>
         <td><input type="text" name="title" size="26"></td>
         <td><input type="text" name="image" size="26"></td>
        </tr>
        </table>
        <button type="submit">Submit</button>
    </form>
    
    
    内容标识
    标题
    形象
    提交
    
    以下是表单截图:
    下面是php脚本结果:

    您必须将其托管在LAMP服务器上。在echo之前删除Welcome。方法=在表单上发布并更改$\u GET to$_POST@vicatcu这不是问题。您正在混合文本/html和php。将代码更改为这样:
    欢迎
    @vicatcu我在MAMP服务器上托管。尝试应用您提到的内容,但收到了相同的错误。@KodosJohnson如果(!$this->conn){$this->conn=@mysqli_connect($ip,$user,$password);},我忽略了这个conn字符串,如果我删除整个php头,conn是否仍然有效?请注意,谢谢。我已相应更新并在原始QN中显示我的错误。是的,我理解。我尝试过使用GET和POST(Form&PHP),但是没有用。谢谢。我已经相应地进行了更新,并在原始QN中显示了我的错误。PHP中没有
    标记…?@cale\b我正在遵循Derek Brown的解决方案。您好,很抱歉造成混淆!我已经相应地进行了更新,并在原始QN中显示了我的错误。如果您使用的是POST,您的URL将不会显示表单的内容,它将仅为:only。您好,我已经完全更新了我的代码。请再看一次,谢谢。