Hi
I have a one page website, on the page I would like to send an email via a form that I have created, however all of the example php code that I find relys on running code and redirecting to another page (something I dont want to do) is there a way I could write some php that would send the form to my email address whilst staying on my page and possibly even doing it client side?
Sending Email On One Page
Moderator: General Moderators
Re: Sending Email On One Page
You could use Ajax. Or I suppose you could use cURL. Both are slightly more advanced syntax and I won't try to write a routine for you, but you might want to look for info on both those approaches. It might be a lot easier, though, to just direct back to the same page.
-
mischievous
- Forum Commoner
- Posts: 71
- Joined: Sun Apr 19, 2009 8:59 pm
Re: Sending Email On One Page
Whats the problem with running <?php echo $PHP_SELF;?> on form submit?
Re: Sending Email On One Page
Sure. Actually, that would be the simplest. If there's POST data present, send the email, if there isn't, don't. Easy!mischievous wrote:Whats the problem with running <?php echo $PHP_SELF;?> on form submit?
You can just code the name of the same script as the action= (there's some security controversy about using $_SERVER variables like that). I think even # works.