我无法在我的xammp数据库中保存数据

时间:2016-02-15 06:41:20

标签: php database xampp

我在xammp中创建了一个数据库,它的命名登录,它有两个部分用户名和密码,我想输入用户名和密码,它保存到我的数据库但是没有发生这些是我的编码,但当我运行它不成功保存数据!

config.php



 <?php
$db_host="localhost";
$db_user="root";
$db_pass="";
$db_name="biglike";
$db_table="sign in";
   ?>




index.php



     <html>
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>form of sending information</title>
        </head>
        <body>
        <form method="POST" action="">
        <p><input type="text" name="username" size="20">username:</p>
        <p><input type="text" name="password" size="20">password</p>
        <p><input type="submit" value="send" name="Submit"><input type="reset"           value="retry again" name="B2"></p>
        </form>

        <?php
        if(@$_POST['Submit']){
        include_once("config.php");
        $con = mysql_connect($db_host,$db_user,$db_pass) or die("error in connecting     to database");
        $selected=mysql_select_db($db_name, $con) or die("error in selecting   database");
        if($selected){
        $username = $_REQUEST['username'];
        $password = $_REQUEST['password'];
        $ins = "INSERT INTO $db_table (username,password) VALUES     ('$username','$password')";
       $saved=mysql_query($ins );
       if($saved){
       echo "saving information successfully";
       }

      else
     {
      echo "saving information unsuccessfully";
       }

       }
       mysql_close($con);
       }

       ?>

       </body>

       </html>

0 个答案:

没有答案