简体   繁体   English

提交按钮不起作用。 我有一个 mysql 数据库,我正在尝试制作 php 表格

[英]submit button is not working. i have a mysql database and i am trying to make a php form

when i hit the submit button, nothing happens.当我点击提交按钮时,没有任何反应。 perhaps the database is not connected.也许数据库没有连接。 i am trying to make a form using php and html.我正在尝试使用 php 和 html 制作表格。 i am using xampp, i wrote the code in notepad++ and i saved form.php in htdocs.我正在使用 xampp,我在 notepad++ 中编写了代码,并在 htdocs 中保存了 form.php。 i don't know what is wrong.我不知道出了什么问题。 maybe the names i used for the variables.也许我用于变量的名称。

this is the html code:这是 html 代码:

    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Untitled Document</title>
    </head>

    <body>
        <form method="post" action="C:\xampp\htdocs\form.php">
    Nume de utilizator : <input type="text" name="nume_de_utilizator" placeholder="Enter Your Name" >
    Email : <input type="text" name="email" placeholder="Enter Your Email">
    Parola: <input type="password" name="parola">
    <input type="submit" value="submit" >
    </form>
    </body>
    </html>

this is form.php

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "autentificare";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
  die("Connection failed: " . mysqli_connect_error());
}
$nume_de_utilizator = mysqli_real_escape_string($conn, $_POST['nume_de_utilizator']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$parola = mysqli_real_escape_string($conn, $_POST['parola']);

// Attempt insert query execution
$sql = "INSERT INTO utilizatori (nume_de_utilizator, email, parola) VALUES ('$nume_de_utilizator', '$email', '$parola')";
if(mysqli_query($conn, $sql))
     printf("%d Row inserted.\n", mysqli_affected_rows($con));
else
{ echo "ERROR: Could not able to execute $sql. " . mysqli_error($conn);}


// Close connection
mysqli_close($conn);
?>

and this is the "autentificare", the database my database这是“autentificare”,我的数据库

Try to see the "online link" eg: " http://localhost:8080/form.php "尝试查看“在线链接”,例如:“ http://localhost:8080/form.php
Do a simple echo msg - file to check and after replace做一个简单的echo msg - 文件检查和替换后
action="C:\xampp\htdocs\form.php" with action=http_link action="C:\xampp\htdocs\form.php"action=http_link

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM