Php 要使用html表单字段将页面url存储到mysql吗

Php 要使用html表单字段将页面url存储到mysql吗,php,html,mysql,Php,Html,Mysql,我有两个php文件index.php和insert.php。我正在使用表单插入一些数据,但我还想使用html表单将index.php url存储到mysql中。因为我有很多像index.php这样的页面,它们正在调用insert.php。实际上,当某个页面调用insert.php时,它应该使用表单获取该页面的url,以便我可以将该url存储到数据库中。代码如下所示 <?php $con=mysqli_connect("localhost","root","","commentdb");

我有两个
php
文件
index.php
insert.php
。我正在使用表单插入一些数据,但我还想使用html表单将
index.php url
存储到
mysql
中。因为我有很多像
index.php
这样的页面,它们正在调用
insert.php
。实际上,当某个页面调用
insert.php
时,它应该使用表单获取该页面的
url
,以便我可以将该
url
存储到数据库中。代码如下所示

<?php

$con=mysqli_connect("localhost","root","","commentdb");
// Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

// Everything is working fine but not taking the url
$sql="INSERT INTO comment (id, name, email,comment,url)
VALUES
(null, '$_POST[name]','$_POST[email]','$_POST[comment]', $_POST[url])";

if (!mysqli_query($con,$sql))
  {
  die('Error: ' . mysqli_error($con));
  }
echo "1 record added";

mysqli_close($con);

?>

您需要回显函数中的值-

value="<?php echo getURL();?>" />
value=”“/>

value=“”
value=“”
您尝试过这个吗?正如u\u mulder试图说的,您的函数正在返回值,但您只是在调用函数。不,你在哪里回显返回值。为什么不直接回显
?是的,我回显它,它在当前页面中回显,但我不想回显。我想使用一些表单元素将其存储在db中。非常感谢,先生!我非常感谢你。
value="<?php echo getURL();?>" />