Skip to main content
Known Participant
September 10, 2009
Question

Called php program doesn't return to calling page

  • September 10, 2009
  • 1 reply
  • 2661 views

I have a page with a form that calls a php program via a "Submit" button (i.e. method="post" action="sendmail.php").  The php program works fine, and sends the email as it's supposed to, but then doesn't return to the calling page.  I want it to simply display a "mail sent" message of some sort (preferrably a message bok with an OK button) - without displaying an entire web page - and then return to the page which called it.  What gets emailed is the information entered into the calling form, and some text notifying the recipient that a pre-employment questionnaire is ready for them to fill out.

I've been working on this for over a week, and havent't been able to find out how to get back when a php program is called.  The fact is that the php wouldn't even have to be in a separate file, except that all the information I've found regarding "action=" indicates that it must.  I tried placing the php code in a function located in the <head> section of the calling page, but "action=functionname()" didn't work.

Can someone pleas help me with this?

This topic has been closed for replies.

1 reply

Participating Frequently
September 10, 2009

>The fact is that the php wouldn't even have to be in a separate file,

>except that all the information I've found regarding "action="

>indicates that it must.

Nah, that's not true at all. You can have a form self post and have the script that processes it on the same page. The technique is to have the script check if the form has been posted. If it has, process the form and then display whatever you want. If it has not, then just display the form. I do this with .asp forms all the time. I can't help with the php code, but I'm sure one of the php guru's will reply shortly with some examples.

Known Participant
September 10, 2009

Well that certainly makes me hopeful, but how do I code the action="" in the HTML <form tag, to self post instead of a URL?  I tried referencing a function there, but it gave me a "Form Not found" message when I ran it.  I thought I could use the "onClick" in the <input, but it still wants a URL in the action-.

Participating Frequently
September 10, 2009

>but how do I code the action="" in the HTML <form tag, to self post instead of a URL?

Actually, action="" is all you need. The form will then post to itself. When the page loads, the php script will need to evaluate the form field states to determine if the form was posted.