dounai6613 2016-03-03 05:19
浏览 43
已采纳

如何在PHP中使用URL中的值

I am currently making a report error form that has 4 fields:

  1. Job ID $jobid
  2. Part ID part_id
  3. Machine
  4. Note

The user clicks on a table corresponding the their work and are brought to a new page with a url that has variable. At the moment all the fields are empty however I want the fields to be populated automatically except for notes.

Current Model

Link to report error form:

$EM_html = '<a href="/report_error_form.php?JobID='.$jobid.'&Machine=EM&PartID='.$part_id.'">'.$tick.'</a>

Report error form:

<form action="" method="post">
        Job Number: <input type="text" value="<?php print ($jobid) ?>" name="jobNum"><br>
        Part Number: <input type="text" value="<?php print ($part_id) ?>" name="partNum"><br>
        Machine Code: <input type="text" name="machCode"><br>
        Note:<br><textarea rows="5" name="note" cols="30" placeholder="More detail... (Is there a way to recreate the error?)"></textarea><br>
        <input type="submit" name="submit" value="Submit">
</form>

Example URL

http://sra-pstest/report_error_form.php?JobID=KANBAN16-09-04-01&Machine=EM&PartID=124047 How do "extract" the information out of the url (JobID, Machine, PartID) and automatically fill out the form?

  • 写回答

5条回答 默认 最新

  • duanli9001 2016-03-03 05:26
    关注

    Please try this

    <?php
            $jobid    = @$_REQUEST['JobID'];
            $part_id  = @$_REQUEST['PartID'];
            $machCode = @$_REQUEST['Machine'];
     ?>
    
    
        <form action="" method="post">
                    Job Number: <input type="text" value="<?php print ($jobid) ?>" name="jobNum"><br>
                    Part Number: <input type="text" value="<?php print ($part_id) ?>" name="partNum"><br>
                    Machine Code: <input type="text" name="machCode"><br>
                    Note:<br><textarea rows="5" name="note" cols="30" placeholder="More detail... (Is there a way to recreate the error?)"></textarea><br>
                    <input type="submit" name="submit" value="Submit">
        </form>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料