Sending Email On One Page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
millsy007
Forum Commoner
Posts: 78
Joined: Wed Jul 02, 2008 7:00 pm

Sending Email On One Page

Post 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?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Sending Email On One Page

Post 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.
mischievous
Forum Commoner
Posts: 71
Joined: Sun Apr 19, 2009 8:59 pm

Re: Sending Email On One Page

Post by mischievous »

Whats the problem with running <?php echo $PHP_SELF;?> on form submit?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Sending Email On One Page

Post 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.
Post Reply