Page 1 of 1

Sending Email On One Page

Posted: Wed Apr 22, 2009 5:17 pm
by millsy007
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?

Re: Sending Email On One Page

Posted: Wed Apr 22, 2009 6:34 pm
by califdon
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.

Re: Sending Email On One Page

Posted: Wed Apr 22, 2009 9:02 pm
by mischievous
Whats the problem with running <?php echo $PHP_SELF;?> on form submit?

Re: Sending Email On One Page

Posted: Wed Apr 22, 2009 10:00 pm
by califdon
mischievous wrote:Whats the problem with running <?php echo $PHP_SELF;?> on form submit?
Sure. Actually, that would be the simplest. If there's POST data present, send the email, if there isn't, don't. Easy!

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.