douwenpin0428 2011-08-09 14:33
浏览 20
已采纳

报告页面发送到电子邮件


Ive got a form set up where users can report posts. The page allows them to enter the message id and the choose from a number of radio buttons to which the post had breached and then submit the report

How can i get it so that once the user has entered a message id and clicked a radio button to which the post apply to and click submit, all the data is sent to an email address to where i can review from there?

Also i want it to check if a message id and atleast one radio button has been clicked before submitting and if not displaying a error messages stating they must do this

Thanks

  • 写回答

1条回答 默认 最新

  • dpmwy80068 2011-08-09 14:36
    关注

    Use the mail() function (as long as your server is configured with an MTA, otherwise you'll need to use a PHP SMTP client, which is much messier).

    Edit: had missed your requirement for form validation. That should really be a separate question, but while you can check in JavaScript you will need a fallback validation in PHP otherwise people can bypass your checks. So, something like:

    if(count($_POST['checkboxes']) < 1) /* some error*/
    

    should be what you need. Just be sure the checkboxes have [] on the end of the name (something like name="checkboxes[]") -- otherwise you need to do something hairy like:

    if($_POST['box1'] || $_POST['box2']) ...
    

    or

    $valid = false;
    foreach(array('box1', 'box2', ...) as $f) $valid = $valid || $_POST[$f];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面
  • ¥50 NT4.0系统 STOP:0X0000007B
  • ¥15 想问一下stata17中这段代码哪里有问题呀
  • ¥15 flink cdc无法实时同步mysql数据