Hey, I'm trying to make a submit button that sends a mail to me where the info of the mail will be the url it was sent from, or title. I have this so far, but it sends a blank mail: <?php if($_POST['submit'] == 'go!'){ //form was submitted $to = "mail@example.com"; $subject = "hehey"; $email = "mail2@example.com"; $message = the_title(); $headers = "From: mail2@example.com"; $sent = mail($to, $subject, $message, $headers) ; echo 'Thanks for submitting the form'; die(); } echo '<form method="POST"> <input type="submit" name="submit" value="go!"> </form>'; if($error){ echo '<div class="error">' .$error .'</div>'; } ?> PHP: I'm using wordpress, and this is in a theme functions file, within the loop, so i figured "the_title()" would work. Hope this makes sense thanks
Figured it out, get_the_title() worked, now i only want to find a way to not have to use die(); since then comment form and sidebars wont show after the button is clicked
Try else instead of die: if($_POST['submit'] == 'go!'){ //form was submitted $to = "mail@example.com"; $subject = "hehey"; $email = "mail2@example.com"; $message = get_the_title(); $headers = "From: "; $sent = mail($to, $subject, $message, $headers) ; echo 'Thanks for submitting the form'; } else { echo '<form method="POST"> <input type="submit" name="submit" value="go!"> </form>'; if($error){ echo '<div class="error">' .$error .'</div>'; } } ?>