dsgdhtr_43654 2014-06-28 23:38 采纳率: 100%
浏览 35
已采纳

too long

Please, help with this situation: I have simple feedback form with rating buttons by type "radio":

<form action="php/feedback.php" method="post">
<input type="text" class="form-control" id="exampleInput2" placeholder="Name and Surname)" name="q4" required>
<p>Please, rate us!</p>
<label class="radio-inline"><input type="radio"  id="inlineRadio1" value="1" name="q5_1"> 1 </label>
<label class="radio-inline"><input type="radio"  id="inlineRadio2" value="2" name="q5_2"> 2 </label>
<label class="radio-inline"><input type="radio"  id="inlineRadio3" value="3" name="q5_3"> 3 </label>
<label class="radio-inline"><input type="radio"  id="inlineRadio4" value="4" name="q5_4"> 4 </label>
<label class="radio-inline"><input type="radio"  id="inlineRadio5" value="5" name="q5_5"> 5 </label>
</form>

And my php code:

<? 
$adminemail="test@test.mymail"; 
$date=date("d.m.y"); 
$time=date("H:i"); 
$backurl="http://test.mymail"; 
$q4=$_POST['q4']; 
if ($_POST['q5_1']==="1") echo $q5_1=$_POST['q5_1']; 
if ($_POST['q5_2']==="2") echo $q5_1=$_POST['q5_2']; 
if ($_POST['q5_3']==="3") echo $q5_1=$_POST['q5_3']; 
if ($_POST['q5_4']==="4") echo $q5_1=$_POST['q5_4']; 
if ($_POST['q5_5']==="5") echo $q5_1=$_POST['q5_5']; 
{   
$msg=" 
Name: $q4
Rate: $q5_1 $q5_2 $q5_3 $q5_4 $q5_5
"; 
mail("$adminemail", "$date $time Feedback from $q4", "$msg" ,"Content-type:text/plain;  charset=utf-8");
print "<script language='Javascript'><!-- function reload() {location = \"$backurl\"}; setTimeout('reload()', 2000); //--></script> 
<p>Redirecting....</p>";  
exit; 
}
?>

And data from the radio buttons do not enter the message. And I do not know how to make it work. Thanks for your help!

  • 写回答

1条回答 默认 最新

  • douchunji1885 2014-06-29 00:06
    关注

    You need to submit the data to your php page, either with ajax or a simple input tag with type='submit', you also had numerous syntactical errors in your php code

    <?php 
    if(POST_['submit']){ //to make sure data was actually sent from the page
    $adminemail="test@test.mymail"; 
    $date=date("d.m.y"); 
    $time=date("H:i"); 
    $backurl="http://test.mymail"; 
    $q4=$_POST['q4']; 
    if ($_POST['q5_1']=="1"){ echo $q5_1=$_POST['q5_1'];} 
    if ($_POST['q5_2']=="2"){ echo $q5_1=$_POST['q5_2'];}
    if ($_POST['q5_3']=="3"){ echo $q5_1=$_POST['q5_3'];}
    if ($_POST['q5_4']=="4"){ echo $q5_1=$_POST['q5_4'];}
    if ($_POST['q5_5']=="5"){ echo $q5_1=$_POST['q5_5'];} 
     //{ not sure why this was here  
    $msg=" 
    Name: $q4
    Rate: $q5_1 $q5_2 $q5_3 $q5_4 $q5_5
    "; 
    mail("$adminemail", "$date $time Feedback from $q4", "$msg" ,"Content-type:text/plain;  charset=utf-8");
    print "<script language='Javascript'><!-- function reload() {location = \"$backurl\"}; setTimeout('reload()', 2000); //--></script> 
    <p>Redirecting....</p>";  
    exit; 
    //} or this
    } //end of submit post
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

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