automatically create new pages with php and mysqli

前端 未结 2 1165
醉酒成梦
醉酒成梦 2021-01-16 06:28

still getting my feet wet with php and mysqli, have so much to learn, but at this point this question is one of my most important priorities.

I did some research abo

2条回答
  •  天涯浪人
    2021-01-16 06:41

    If I'm understanding you correctly, I believe you're waiting to create pages from the database Dynamically. You can use a get variable in the request http://yoursite.com/page.php?group=1. Then in your code update your query to do:

    $query = "SELECT word FROM demo WHERE group=".$_GET['group'];
    

    That query is insecure, as any user could inject raw mysql into the $_GET['group'] variable.

    $group = mysqli_real_escape_string($conn, $_GET['group']);
    $query = "SELECT word FROM demo WHERE `group`='$group'";
    

    This is much safer.

提交回复
热议问题