简体   繁体   中英

report page sending to email


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

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];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM