weixin_33701294 2019-11-27 09:09 采纳率: 0%
浏览 46

如何从html访问php?

I am sorry if this is a repeating question, but I can't find anyone who might have the same question as me yet. I am new in html and php, and I am trying to learn more by practising, basically creating a registration form and keep all the data in the MySQL database, by using xampp. I have created a registration form and saved it as a .html file format, but how can I use php to send the user input from html to the MySQL database? I have seen a lot of examples on Google, but most of them are using php file format, for example instead of registration.html, they use registration.php. I really do appreciate your help. Thank you very much StackOverflow community members.

P/S: I use Visual Studio Code to do this

  • 写回答

2条回答 默认 最新

  • weixin_33736048 2019-11-27 09:21
    关注

    Step 1: write this code in your html file

    in form action redirect it to the php file

    <!DOCTYPE html>
    <html>
    <head>
        <title>form</title>
    </head>
    <body>
        <form method="post" action="st.php">
            <input type="text" name="text">
            <input type="submit" name="submit_btn">
        </form>
    </body>
    </html>
    

    Step 2 create st.php file and call the action

    <?php
        if(isset($_POST['submit_btn'])){
            //your code
           header('Location:yourHTMLFile.html?status=success');//redirect to your html with status
        }
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 怎么把多于硬盘空间放到根目录下
  • ¥15 Matlab问题解答有两个问题
  • ¥50 Oracle Kubernetes服务器集群主节点无法访问,工作节点可以访问
  • ¥15 LCD12864中文显示
  • ¥15 在使用CH341SER.EXE时不小心把所有驱动文件删除了怎么解决
  • ¥15 gsoap生成onvif框架
  • ¥15 有关sql server business intellige安装,包括SSDT、SSMS。
  • ¥15 stm32的can接口不能收发数据
  • ¥15 目标检测算法移植到arm开发板
  • ¥15 利用JD51设计温度报警系统