doubi1910 2015-08-08 05:20
浏览 81
已采纳

我无法将表单信息插入到我的数据库中,我一直收到404错误

Hello I am having some trouble inserting my form information onto my database. I am recieving the connected to database echo however when click on submit i get a 404 error. Any help would be greatly appreciated. Thank you in advance!

<?php
    $host="localhost";
    $dbuser="root";
    $pass="******";
    $dbname="learn";
    $con = mysqli_connect ($host, $dbuser, $pass, $dbname);
    if (mysqli_connect_errno ())
    {
        die ("Connection Failed!" . mysqli_connect_error());
    }
    else
    {
    echo "Connected to database {$dbname} ";
    }

            if(isset($_POST['submit']))
        {
        $fname=$_POST ['fname'];
        $lname=$_POST ['lname'];
        $email=$_POST ['email'];
        $pswrd=$_POST ['pswrd'];

            $sql = $con->query ("INSERT INTO users ( fname, lname, email, pswrd,)
                     VALUES ( ' {$fname} ' , ' {$lname} ' , ' {$email} ' , ' {$pswrd} ' , ')" );
        }
?>

<!DOCTYPE html>
<html lang="en-US">
<head>
    <title>Signup</title>
    <meta charset="utf-8">
    <meta name="description" content="description of webpage">
    <meta name="keywords" content="keywords go here">
    <meta name="author" content="me">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/signup.css">
    <link rel="index" href="index.php">
    <link rel="icon" href="img/favicon.png" sizes="16x16" type="image/png">
</head>
<body>

    <div class="header">
        <div id="logo">
                <a href="index.php"><img src="img/logo.png" alt="logo" title="learnlogo"/></a>
        </div>
    </div>

        <div id="signupform">
            <form action="submit" method="post"><br>
                <input type="text" name="fname" placeholder="First name">
                <input type="text" name="lname" placeholder="Last name"><br><br>
                <input type="text" name="email" placeholder="Email address">
                <input type="password" name="pswrd" placeholder="Password"><br><br>
                <input type"submit" value="Submit">
            </form>
        </div>
<?php
    include ("inc/footer.php");
?>
  • 写回答

3条回答 默认 最新

  • duanba8173 2015-08-08 05:28
    关注

    remove action="submit" from your <form> tag. The action="{URL}" attribute "specifies where to send the form-data when a form is submitted" - you don't need it when sending back to the same url.

    e.g. change:

    <form action="submit" method="post"><br>
    

    to:

    <form method="post"><br>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?