dongroufan6846 2014-03-17 01:06
浏览 24
已采纳

基于用户输入主要特征的PHP GET表单[关闭]

I am looking for a way to direct a PHP form to a specific URL based on the user input. For example:

If user enters AA123 the URL would be http://sample.com/cgi-bin/lookup.cgi?OPT_M=AA_DETAIL&TICKET=AA123

If user enters BB123 the URL would be http://sample.com/cgi-bin/lookup.cgi?OPT_M=BB_DETAIL&TICKET=BB123

Any assistance is greatly appreciated.

Added:

I am able to create 2 separate radio buttons to accomplish this but would really like to do it without selecting the type. I am not sure where to go next. Below is what I have so far:

<form action="http://sample.com/cgi-bin/ticket.cgi" method="get"> <input type="radio" name="OPT_M" value="AA_DETAIL" />AA <input type="radio" name="OPT_M" value="BB_DETAIL" />BB Ticket: <input type="text" name="Ticket" /><br /> <input type="submit" value="Send" /> </form>

  • 写回答

4条回答 默认 最新

  • douzi9211 2014-03-17 01:50
    关注

    You can do something like this.. if you are using PHP

    On top of the page:

    if($_SERVER['REQUEST_METHOD']=="POST"){
        $TICKET = $_GET['Ticket'];
        $OPT_M = substr($TICKET, 0, 2) . '_DETAIL';
        header('Location: http://sample.com/cgi-bin/lookup.cgi?OPT_M=' . $OPT_M . '&TICKET=' . $TICKET);
    }
    

    On your form:

        <form action="#" method="get">
        Ticket: <input type="text" name="Ticket" /><br />
        <input type="submit" value="Send" />
        </form>
    

    Hope this help.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100