dqm83011 2016-05-04 21:40
浏览 86

单选按钮php

Hi guys can you please help me, I was just wondering what to put on the php for my radio buttons this is what I did. I'm not sure if it's right. Also I have an "other" option where you will type in the answer I was wondering if I was right to put it in the $fields ?

HTML

     <label class="radio-inline" style="padding-left:30px;">
                                    <input type="radio" value="retailer" name="optradio" required>
                                    <?PHP print $retailer; ?>Retailer
                                    </label>

                                    <label class="radio-inline">
                                    <input type="radio" value="wholesaler" name="optradio">
                                    <?PHP print $wholesaler; ?>Wholesaler
                                    </label>

                                    <label class="radio-inline">
                                    <input type="radio" value="distributor" name="optradio">
                                    <?PHP print $distributor; ?>Distributor
                                    </label>

                                    <label class="radio-inline">
                                    <input type="radio" value="ebayamazonplay" name="optradio">
                                    <?PHP print $ebayamazonplay; ?>Ebay / Amazon / Play Trader
                                    </label>

                                    <label class="radio-inline">
                                    <input type="radio" value="online" name="optradio">
                                    <?PHP print $online; ?>Online Retailer
                                    </label>

                                    <label class="radio-inline">
                                    <input type="radio" value="other" name="optradio">
                                    <?PHP print $other; ?>Other - Please specify
                                    </label>
                                     <input id="form_other" type="text" name="other" class="form-control" placeholder="Please specify">

PHP

$retailer = 'unchecked';
$wholesaler = 'unchecked';
$distributor = 'unchecked';
$ebayamazonplay = 'unchecked';
$online = 'unchecked';
$other = 'unchecked';

if (isset($_POST['Submit1'])) {

$selected_radio = $_POST['optradio'];

if ($selected_radio = = 'retailer') {

$retailer = 'checked';

}
else if ($selected_radio = = 'wholesaler') {

$wholesaler = 'checked';

}

if ($selected_radio = = 'distributor') {

$distributor = 'checked';

}
else if ($selected_radio = = 'ebayamazonplay') {

$ebayamazonplay = 'checked';

}

if ($selected_radio = = 'online') {

$online = 'checked';

}
else if ($selected_radio = = 'other') {

$other = 'checked';

}

ALSO, what should I put on $from? I understand that I need to put the receiver's email in $to, but why do I have to put where it's from when different people are going to submit the form? Can I just get rid of it? Will it affect something?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
    • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
    • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
    • ¥15 lingo18勾选global solver求解使用的算法
    • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
    • ¥20 测距传感器数据手册i2c
    • ¥15 RPA正常跑,cmd输入cookies跑不出来
    • ¥15 求帮我调试一下freefem代码
    • ¥15 matlab代码解决,怎么运行
    • ¥15 R语言Rstudio突然无法启动