doufen1933 2014-02-14 00:57
浏览 14

从PHP表单提交选中的选项

I'm trying to figure out how to send checked options from a series of checkboxes to a text file that keeps track of what has been selected. The most I have right now is this.

<html>
<?php
//Get contents from zmzonSongs.txt file, put into array.
$songList = explode("
", file_get_contents('zmzonSongs.txt'));

print "Welcome to Zmzon.  Select songs below to add to your library.";
//Print contents as checklist.
foreach($songList as $songs){
    echo "<br/><input type='checkbox' name='songList[]' value='$songs' />"$songs<br>";
}

?>

</html>

I need to send the values of everything that has been checked to a file like myLibrary.txt after the user hits a submit button, but every time I try adding a submit button using the echo command, my entire page stops working and comes up blank. I'm completely lost.

  • 写回答

3条回答 默认 最新

  • douchiwan1503 2014-02-14 00:59
    关注

    You have an extra quote:

    echo "<br/><input type='checkbox' name='songList[]' value='$songs' />"$songs<br>";
    

    should be

    echo "<br/><input type='checkbox' name='songList[]' value='$songs' />$songs<br>";
    

    or

    echo "<br/><input type='checkbox' name='songList[]' value='$songs' />".$songs."<br>";
    
    评论

报告相同问题?

悬赏问题

  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示