Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.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 将web表单连接到MySQL数据库_Php_Html_Sql_Sql Server_Forms - Fatal编程技术网

Php 将web表单连接到MySQL数据库

Php 将web表单连接到MySQL数据库,php,html,sql,sql-server,forms,Php,Html,Sql,Sql Server,Forms,使用MySQL数据库,我将用户添加到数据库中,如以下测试数据: INSERT INTO `database_users`.`Members` (`ID`, `Username`, `Password`, `First Name`, `Last Name`, `Email Address`, `Telephone Number`, `Address Line 1`, `Address Line 2`, `Town/City`, `Postcode`, `Mailing-list`, `Ter

使用MySQL数据库,我将用户添加到数据库中,如以下测试数据:

INSERT INTO `database_users`.`Members` (`ID`, `Username`, `Password`,
 `First Name`, `Last Name`, `Email Address`, `Telephone Number`,
 `Address Line 1`, `Address Line 2`, `Town/City`, `Postcode`,
 `Mailing-list`, `Terms`) VALUES (NULL, 'Test', '', '', '', '', '', '',
 NULL, '', '', NULL, '');"
我的HTML表单如下所示:

<input type="submit" value="Join!">
    <div class="col-lg-6">
        <input type="text" placeholder="Town/City" id="Town/City">
    </div>
    <div class="col-lg-6">
        <input type="text" placeholder="Postcode" id="Postcode">
    </div>
</input>


我期待在我的网站上提交表格,并将数据上传到我的MySQL数据库。有人能告诉我表单中缺少了什么吗?

您的sql查询似乎不错,但如果您不知道如何使用PHP,您将经常被阻止

最好的方法是学习基本的PHP,了解如何实现注册页面,并询问stackoverflow在开发过程中是否存在问题

您的表单不正确:您需要一个
输入,并在其上定义方法(post或get)和操作(数据所在的文件)

基本上,您的代码必须如下所示:

HTML(form.HTML)


PHP(save.PHP)


从一个工作示例开始,该示例一步一步地向您展示如何做。。。你可以在网上找到很多教程。你是如何连接你的php和sql数据库的?是的,我使用我在网上找到的php模板连接了我的php和sql数据库(该模板要求提供数据库名称和密码等)。我只是想找人把什么添加到我的表单(即,在哪里添加我的数据库ID)只需做一个谷歌搜索注册和PHP的源代码。你会得到很多结果和可靠的材料,包括免费的源代码。在来这里之前,你需要在线搜索。Stackoverflow应该是您在力所能及的范围内尝试一切(包括在线搜索)的最后手段。非常感谢!这真的很有帮助!我刚刚发现自己陷入了一种陈规,而这正是我所寻求的建议。非常感谢!不客气!如果你认为这是你需要的答案,你可以投票支持我的帖子:-)我试过这么做,但是没有足够的“声誉”,我会尽快回来的!
<form method="POST" action="save.php">
    <input type="text" name="pseudo">
    <input type="submit">
</form>
<?php
    if(isset($_POST['pseudo'])){ // Test if the variable exists
        $pseudo = $_POST['pseudo'];
        // Your SQL query here which save the pseudo. Don't forget to test your variables.
    }
    else {
        echo "pseudo is required";
    }
?>