【问题标题】:PHP urlencode functionsPHP urlencode 函数
【发布时间】:2018-05-15 11:45:24
【问题描述】:

我无法使用函数urlencode 制作基于“topicnaam”的“url”列

我想要什么:我想要我的 url 由 topicnaam 制作。但是 topicnaam 需要一个 urlencode,所以它们在 'url' 中没有空格和其他符号

I tried to use the urlencode() function.

This is my table structure

我的<form> 代码和更新函数

<?php
  if(isset($_POST['react_btn'])){
   unset($q1);
   $q1['topicnaam'] = $app->check_string($_POST['topicnaam']);
   $q1['board_id'] = $app->check_string($_POST['boardid']);
   $q1['klant_id'] = $app->check_string($_POST['klantid']);
   $q1['ledenpagina_id'] = $app->check_string($_POST['ledenpaginaid']);
   $q1['omschrijving'] = $app->check_string($_POST['topicomschrijving']);
   $app->insert_query('topics', $q1, 'id');
   }  

  ?> 
   <form action="" method="post">
     <div class="form-group">
      <label for="comment">Topicnaam:</label>
      <textarea class="form-control resizenone" name="topicnaam" rows="1" id="comment" required></textarea>
       <input type="hidden" name="klantid" value="<?php echo $_SESSION["klant_id"] ?>">
       <input type="hidden" name="boardid" value="<?php echo $actiefboardid ?>">
       <input type="hidden" name="ledenpaginaid" value="<?php echo $_SESSION["ledenpagina_id"]; ?>">
       <label for="comment">Topic omschrijving:</label>
       <textarea class="form-control resizenone" name="topicomschrijving" rows="3" id="comment required"></textarea>
       <button type="submit" name="react_btn" class="btn btn-primary">Voeg topic toe</button>
       </div>              
   </form>

【问题讨论】:

    标签: php html mysql url encode


    【解决方案1】:

    在这里找到

    if(isset($_POST['react_btn'])){
        $base_URL = 'https://yousitename.com/'
    
        unset($q1);
        $q1['topicnaam'] = $app->check_string($_POST['topicnaam']);
        $q1['board_id'] = $app->check_string($_POST['boardid']);
        $q1['klant_id'] = $app->check_string($_POST['klantid']);
        $q1['ledenpagina_id'] = $app->check_string($_POST['ledenpaginaid']);
        $q1['omschrijving'] = $app->check_string($_POST['topicomschrijving']);
        $q1['url'] = $base_URL.urlencode($q1['topicnaam']);
        $app->insert_query('topics', $q1, 'id');
    }  
    

    【讨论】:

    • 感谢这位朋友!有效。我不得不稍微调整一下代码,但我得到了它的工作。
    猜你喜欢
    • 1970-01-01
    • 2014-10-16
    • 2010-09-25
    • 2020-02-13
    • 2016-03-18
    • 2011-10-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多