首页 > 解决方案 > 从 PHP 中的 URL id 跳转到页面部分

问题描述

我正在为一个 QA 论坛工作。我有一个问题并进行了搜索,但没有找到更好的解决方案。在登录系统中,我得到了 redirect_to URL 之类的 -

http://localhost:8081/qa/506/how-to-connect-the-html-page-to-the-mysql-database-using-php#ans123 

这是我登录后将使用的。我知道,我可以使用 <a name="ans123"></a>to jump section 或 by id 。

  1. 我正在从 URL 中获取价值,例如 -

    login.php?redirect_to=http://localhost:8081/qa/506/how-to-connect-the-html-page-to-the-mysql-database-using-php#ans123

    redirect_to=$_GET['redirect_to'];

但它只给了我http://localhost:8081/qa/506/how-to-connect-the-html-page-to-the-mysql-database-using-php

不是

http://localhost:8081/qa/506/how-to-connect-the-html-page-to-the-mysql-database-using-php#ans123 

与 #ans123 。

我想在登录问题页面后将用户跳转到 textarea。

我在底部有一个 textarea,名称为“textarea”

<a name="ans123"> </a>
<form action="#" method="POST">
  <textarea name="anscontent" required></textarea>
  <script>
    CKEDITOR.replace("anscontent", {
      height: 300,
      filebrowserUploadUrl: "upload.php",
    });
  </script>

  <button name="answer_submit">Post your Answer</button>
</form>

还有一件事,我见过一种方法

 http://localhost:8081/qa/506/how-to-connect-the-html-page-to-the-mysql-database-using-php?state=ans-890 . 

如果我打开这个 URL,它会打开 textarea。

  1. 登录后如何跳转到Textarea框区域(底部HTML文本编辑器)
  2. 我该如何编辑答案。如果用户单击编辑按钮或链接,则跳转到文本框并编辑数据。提交编辑后跳转到更新的答案。

标签: phphtml

解决方案


推荐阅读