How does php submit form data using the <a > tag?

A novice at the back end is working on a note-taking website and has just learned the basics of php for half a month. Now he has learned that the interaction between php and html needs to be done by submitting the data in the < form > form. According to the review and the description in the book, it is found that only button and input tags can submit data by setting the name attribute. Sometimes it is necessary to click on the a tag to submit the form for typesetting reasons, and it is found that the traditional processing method cannot be solved. The query found that you can jump with the help of js, but when you click on the a tag, you can"t use if (isset ($_ POST ["html element name"]) to determine whether the web page is clicked or not.
I would like to ask if you have a solution that allows a tag to be handled like button and input.
Thank you for asking questions using segmentFault for the first time.

< hr >

original processing method:
html:

<form action="userdata.php" method="post">
    <div class="top">        
        

Green Notbook

<button name="userdata"></button>

</div> </form>

php:

if(isset($_POST["userdata"])){
    $userid=$_SESSION["userid"];
    $username=$_SESSION["username"];
    $data="select email,createTime from user where id="$userid"";
    $result=mysqli_query($link,$data);
?>  

find the solution:

<form id="testform" method="post">
    <div class="biji">
        <a onclick="testphp()"></a>
        <a href="-sharp"><img src="img/3.PNG"width="35px" height="30px"></a>        
    </div>     
</form>
function testphp(){
    var testform=document.getElementById("testform");
    testform.action="note_change_search.php";
    testform.submit();
}

in this way, you can only jump to a php file.

Mar.03,2021

<a href="javascript:document:search_form.submit();"></a>

search_from form ID


use js instead of php to judge

Menu