php不会将数据插入数据库 [英] php won't insert data into database

查看:116
本文介绍了php不会将数据插入数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我遇到了一些问题与mysql,php和html。

Today i have run into some problems with mysql, php and html.

所以我有一个数据库gebruikers在该数据库中有一个表称为注册表和我使用USBwebserver V8.6主办

So i have a database called "gebruikers" in that database i have a table called "registratie" and i use USBwebserver V8.6 for the hosting

我已经做了一个表单,人们注册他们的网站,我打算, m碰撞是,当我按inschrijven它不会插入数据输入的形式到我的数据库中我看过stackoverflow,但我找不到解决我的问题的答案。

i have made a form for people to register them for the website i am planning to make, but what i'm bumping into is that when i press "inschrijven" it won't insert the data typed in the form into my database i have looked on stackoverflow but i couldn't find the solving answer to my problem.

PHP:

    <?php
session_start();
include_once 'dbconnect.php';
$gebruikersnaam = mysql_real_escape_string($post['gebruikersnaam']);
$wachtwoord = mysql_real_escape_string($post['wachtwoord']);
$voornaam = mysql_real_escape_string($post['voornaam']);
$tussenvoegsel = mysql_real_escape_string($post['tussenvoegsel']);
$achternaam = mysql_real_escape_string($post['achternaam']);
$klas = mysql_real_escape_string($post['klas']);
$telefoon = mysql_real_escape_string($spot['telefoon']);
$geboortedatum = mysql_real_escape_string($post['geboortedatum']);
$email = mysql_real_escape_string($post['email']);
$geslacht = mysql_real_escape_string($post['geslacht']);

if(mysql_query("INSERT INTO gebruikers(gebruikersnaam,) VALUES('$gebruikersnaam')"
?>

HTML:

HTML:

<body>

    <div id=titel>
        <a href=index.html><img src="images/logo.jpg" alt="Homepage"id=logo></a>
    Registratie
    </div>

    <div id=registratie>
        form  method="post">
        Gebruikersnaam:
        <input type="text" name="gebruikersnaam">
        <br>
        <br>
        Wachtwoord:
        <input type="password" name="wachtwoord">
        <br>
        <br>
        Voornaam:
        <input type="text" name="voornaam">
        <br>
        <br>
        Tussenvoegsel:
        <input type="text"name="tussenvoegsel">
        <br>
        <br>
        Achternaam:
        <input type="text" name="achternaam">
        <br>
        <br>
        Klas:
        <input type="text" name="klas">
        <br>
        <br>
        Telefoon:
        <input type="tel" name="telefoon">
        <br>
        <br>
        Geboortedatum:
        <input type="date" name="geboortedatum">
        <br>
        <br>
        Email:
        <input type="email" name="email">
        <br>
        <br>
        Geslacht:
        <br>
        <select>
        <option value="Man">Man</option>
        <option value="Vrouw">Vrouw</option>
        </select>
        <br>
        <br>
        <input type="submit" onclick="alert('Registratie voltooid')" value="Inschrijven">
        </form>

        <a href=index.html id="button">Terug naar hoofdpagina</a>
        </div>

</body>

我真的希望这可以帮助你们。
这是我的DBCONNECT.PHP:

i really hope that this can help you guys out. this is my DBCONNECT.PHP:

    <?php
if(!mysql_connect("localhost", "root", "usbw", "gebruikers"))
{
    die('connection problem.' .mysql_error());
}
if(!mysql_select_db("gebruikers"))
{
    die('No database selected' .mysql_error());
}
include 
?>

我真的希望你们能帮助我,因为我的想法如何我可以解决这个问题,我不知道我的问题在哪里。

i really hope you guys could help me out, because i'm out of ideas how i can fix this problem and i don't know where my problem lies.

注意:有些词是在荷兰语。

NOTE: some words are in dutch.

推荐答案

您不是正确地调用POST变量。

You're not calling the POST variables correctly.

 $gebruikersnaam = mysql_real_escape_string($post['gebruikersnaam']);

应为:

$gebruikersnaam = mysql_real_escape_string($_POST['gebruikersnaam']);

此外,这是一个不好的习惯,抛弃die()函数的小事情像数据库处理,因为这会杀死页面的其余功能。

Also, it's a bad habit to throw die() functions for minor things like database handling since this kills the rest of the page's functionality.

这篇关于php不会将数据插入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆