Jump to content

[SOLVED] Sending email using mail() without a form?


stickynote427

Recommended Posts

I have a how-to page on my site. To access these how-tos, they are entered in to the URL as GET parameters (...?howto=whatever). I have it set up so that if the how-to does not exist (it is checked from an array), the message, "The how-to you requested does not exist. Feel free to suggest it to us." is echoed.

 

I want "suggest it to us" to be a link (NOT a button) that will execute a PHP mail() somehow. Is there any way I can use a link instead of a button to submit a form using mail()? If not, should I just use CSS styles to style the button to look a bit less like a button?

 

Thanks.

Blake

Alright, thanks.

 

Now I have another problem, though.

 

Will it be possible to set the form's ACTION to $_SERVER['PHP_SELF'] and still use the link? I'm trying to check to see if the form has been submitted by using isset($_POST['submitLink']), but I don't think it's working - because the link is not an input field, its name (submitLink) is not submitted along with the form.

 

Here's the code I have:

 

if ($howtoExists!=1 && !isset($_POST['submitLink'])) { ?>
The how-to you requested does not exist. Feel free to <form style="display:inline;" name="howtoSuggestion" method="post" action="<?=$_SERVER['PHP_SELF'];?>?page=how-to&howto=<?=$_GET['howto'];?>"><input type="hidden" name="suggested" value="<?=$_GET['howto'];?>"><a href="javascript:document.forms[0].submit();" name="submitLink">suggest it to us</a></form><br /><br />
<?php
}
if (isset($_POST['submitLink'])) {
mail("myEmailIsHere","How-to Suggestion: ".$_POST['suggested'],"Someone from ".$_SERVER['REMOTE_ADDR']." requested that the following how-to be added to the site: ".$_POST['suggested']);
echo "Thank you. Your suggested how-to has been submitted.";
}
//...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.