使用XAMPP将SQL数据库连接到Chrome扩展程序时遇到问题

时间:2019-02-04 17:15:03

标签: php html sql-server google-chrome-extension xampp

我正在尝试使用Google Chrome扩展程序中的(XAMPP-phpmyadmin)连接到我的SQL数据库。 我收到以下错误:-

(找不到您的文件,它可能已被移动或删除。 ERR_FILE_NOT_FOUND)

我将代码从(insert.php更改为data.php),但是我的数据没有存储在数据库中。当我在扩展程序中单击“提交”按钮时,我得到了我的PHP脚本,即data.php作为弹出窗口。

 (data.php)

 <pre>
 <?php
 $database="uppercase";

 $name=$_POST['name'];

 mysql_connect(localhost);
 @mysql_select_db($database) ;

 $query = "INSERT INTO urltable VALUES ('','$name')";
 mysql_query($query);

 mysql_close();

 ?>
 </pre>



 (popup.html)

 <!DOCTYPE html>
 <html>
 <head>
    <title>Hello World</title>
    <script src="jquery-3.3.1.min">
    </script>

 <script src="popup.js">
 </script>
 </head>
 <body>

    <form action="insert.php" method="post">
        First Name: <input type="text" name="name">
        <input type="Submit">
    </form>

  </body>

  </html> 


 (manifest.json)
  {
 "manifest_version": 2,

 "name": "My Launcher",
 "description": "Quick launch lol Media",
 "version": "1.0.0",
 "icons": { "128": "icon_128.png" },
 "browser_action": {
  "default_icon": "icon.png",
  "default_popup": "popup.html"
 },
 "permissions": [
  "tabs","http://localhost/*"
 ],
 "background": {
    "scripts": ["popup.js"],
    "persistent": false
 }
 }

我基本上是在接受用户的输入,然后尝试将其发送到数据库中的表“ urltable”。

1 个答案:

答案 0 :(得分:0)

 <!DOCTYPE html>
     <html>
     <head>
        <title>Hello World</title>
        <script src="jquery-3.3.1.min">
        </script>

     <script src="popup.js">
     </script>
     </head>
     <body>

        <form action="insert.php" method="post">
            First Name: <input type="text" name="name">
            <input type="Submit">
        </form>
      </body>
   </html> 

在“表单”操作中,该操作链接仍为:“ insert.php”将其更改为(data.php)。

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

您正在尝试将POST请求发送到不存在的页面。