【问题标题】:can i connect my html with database without using php,is it possible? [duplicate]我可以在不使用 php 的情况下将我的 html 与数据库连接吗,可以吗? [复制]
【发布时间】:2017-02-27 12:21:25
【问题描述】:

<html>
 <head>
      <title> Futja e te dhenave nepermjet nje forme </title>
            <style type = "text/css">
         body  { background-color: #cfd0f9 }
         h2    { font-family: arial, sans-serif;
                 color: blue }
        h3     {font-color: yellow}

          .error {color: #FF0000;}
</style>
   </head>
<body>

<h1><center>please enter data</center></h1>

<p> <span class="error">* please fill these fields.</span> </p>
<form method="post" action="insert.php">

  <strong> Emri:&nbsp &nbsp &nbsp &nbsp &nbsp </strong> <input type="text" name="fname" />
   <span class="error">* <?php echo $fnameErr;?></span>
   <br>

   <strong> Mbiemri:&nbsp &nbsp </strong> <input type="text" name="lname" />
   <span class="error">* <?php echo $dtlErr;?></span>
   <br>


<input type="submit" name= "shto" value="Add"/>

</form>

</body>
</html>

我们的班主任提供了一个关于如何将 html 页面与数据库连接的项目。

但是我正在到处搜索教程,但是我在哪里看到他们在 php 的帮助下连接 html? 那么,我可以在不使用数据库中的 php 的情况下连接 html 页面吗?如何?

【问题讨论】:

  • HTML 是专门的标记语言,usimg html 可以通过 css 和 javascript 呈现您的网站。您无法使用 HTML 连接到 mysql。
  • 不,你不能。你需要一个像php这样的后端工具
  • html 是一个前端工具(一切都在客户端执行),如果您可以在客户端连接到数据库,那么您的数据库就会变得易受攻击。这就是为什么你需要一个像php这样的后端工具来连接到服务器端的db
  • 您可以通过阅读本文找到完整的答案。 stackoverflow.com/questions/5012335/…
  • 您可以通过阅读本文找到完整的答案。 stackoverflow.com/questions/5012335/…

标签: php html database wamp


【解决方案1】:

抱歉,如果没有设置后端环境,您将无法连接到数据库。 XAMPP 是一个广为人知的包,它为您提供 PHP、MySQL 和 Apache Web 服务器,让您可以使用关系数据库创建网页。只需 1 次安装,即可为您提供全栈网站所需的一切。安装后,会有一个名为 htdocs 的目录,您可以在其中为您的项目创建一个文件夹并在本地 Web 服务器中测试您的代码。

请理解 HTML 和 CSS 只是用于创建网页 UI 的语言。如果您想要需要处理数据的动态网页,则必须将 JavaScript 用于客户端计算和 PHP/MySQL 用于数据库访问。

XAMPP Website

【讨论】:

    【解决方案2】:

    据我所知,使用 PHP 是将数据库连接到我们的 html 文件并在编辑器中访问 mysql 函数的一种方法。因为当使用 localhost/phpmyadmin 时,我们使用的扩展文件是 .php

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-13
      • 1970-01-01
      • 2016-11-07
      • 1970-01-01
      • 2020-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多