簡體   English   中英

無法將我的數據插入數據庫 phpmyadmin

[英]can't insert my data to database phpmyadmin

我的代碼有問題 我嘗試使用 php 制作注冊表單,但我無法將數據插入數據庫這是我的代碼

registration_form.php 注冊表單

 <body>
 <form method="post" action="register.php">
 <table border="0">

 <tr><td>username: </td><td><input type="text" name="username" /></td></tr>

 <tr><td>Password: </td><td><input type="password" name="password" /></td></tr>

 <tr><td>Confirm Password: </td><td><input type="password" name="confirm_password" /></td></tr>

 <tr><td></td><td><input type="submit" value="submit" /></td></tr>

 </table>
 </form>
 </body>
 </html>

寄存器.php

 $con=mysql_connect("localhost","root","");
 /* Now, we select the database */
 mysql_select_db("login&register");

 /* Now we will store the values submitted by form in variable */
 $username=$_POST['username'];
 $pass=$_POST['password'];
 /* we are now encrypting password while using md5() function */
 $password=md5($pass);
 $confirm_password=$_POST['confirm_password'];

 /* Now we will check if username is already in use or not */
 $queryuser=mysql_query("SELECT * FROM register WHERE username='$username' ");
 $checkuser=mysql_num_rows($queryuser);
 if($checkuser != 0)
 { echo "Sorry, ".$username." is already been taken."; }
 else {

 /* now we will check if password and confirm password matched */
 if($pass != $confirm_password)
 { echo "Password and confirm password fields were not matched"; }
 else {

 /* Now we will write a query to insert user details into database */
 $insert_user=mysql_query("INSERT INTO register (username, password) VALUES ('$username',     '$password')");

 if($insert_user)
 { echo "Registration Succesfull"; }
 else
 { echo "error in registration".mysql_error(); }

 /* closing the if else statements */
 }}

 mysql_close($con);
 ?>

當我單擊提交按鈕時出現錯誤消息

 Object not found!

 The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

 If you think this is a server error, please contact the webmaster.

 Error 404

 localhost
 08/08/12 23:46:37
 Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1

請幫我解決這個問題謝謝

<form method="post" action="register.php">

您的 PHP 文件似乎稱為registration.php

您的表單操作是register.php但您的 php 文件稱為registration.php ,將您的表單操作更改為registration.php

您正在嘗試訪問您的表單中的register.php而不是registration.php

這看起來不像是數據庫問題。 而是找不到 register.php。 您已將文件保存為 registration.php。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM