Sorry if the title is a bit vague. What I mean to say is I have a code like below:
<?php
/* ...generate $to, $subject, $msg, $from variables here */
if(isset($_POST['ccbutton_pressed'])) {
if(mail($to, $subject, $msg, $from)){
echo 'Order Sent';
}else{
echo 'Order Sending Error';
}
}?>
<form method='post' action='SOME_URL_TO_POST_TO' >
<!-- some visible input types -->
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<!-- some hidden input types -->
<input type='hidden' name='hiddenfield1' value='1' />
<input type='hidden' name='hiddenfield2' value='2' />
<input type='submit' value='Submit' />
<input type='hidden' name='ccbutton_pressed' value='1'>
</form>
Is there some way I can send an email upon submission? While taking notes on the following points below:
- prefer to php because it is server side and information is kept private
- 'action' attribute needs to post and may not be changed (I need it to go to another page/different form)
- Open to using Javascript as long as the contents of the email can be hidden somehow (but doubtful)
- I already tried putting a php block that triggered when a hidden field got set in that form but it did not work in this case.
Update: Changed code block to explain more information. This is also not a duplicate because in Send email with PHP from html form on submit with the same script, the 'action' is left blank while I need mine to post to somewhere.
I'd also like to add that I have checked the above article and it doesn't work for me.