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!
Hello everybody,
I'd like to ask for help. I'm trying to achieve a very basic feature, display dialog box and redirect to the same page after sending form to mail. I found many ways on the web of course but for some reason I'm not able to make them work. Here we go:
This solution for a change won't display any box but nicely redirects. I've spent hours on this today and feeling as a complete idiot because I'm pretty sure it is very easy. Just not for me apparently...
Thanks for ideas.
Hello Mirge and thanks. Unfortunately your example doesn't work even copy/pasted, I receive parse error on the first line. I'm not much into coding, just trying to fix something I saw as very basic at first.....
Ren wrote:Hello Mirge and thanks. Unfortunately your example doesn't work even copy/pasted, I receive parse error on the first line. I'm not much into coding, just trying to fix something I saw as very basic at first.....
It's not PHP, it's javascript... don't put it within PHP tags. Put it wherever you want your alert to pop up and redirect to take place, within HTML code.. not within PHP.
If they are submitting a form, and you want to have a redirect afterward... skip the dialog box and just redirect them using header("Location: http://www.whateverURLhere.com/"); (Note: nothing may be output before this!!)
Yes, I know this works but I need let them know the form was processed, otherwise when blank form shows again user will be left unsure if the data were sent or not..I see this every day here and there, simple form on a website to send a comment or something. You just fill the form, click send button, receive message box 'data was sent' and see the empty form again. Easy and elegant. And I am not able to implement or find the proper code for it, dunno why. Instead of it I have some external file to which I am redirected and I can't get back to my page. The forms out there I can see usually do not even leave their own page.....
Ren wrote:Yes, I know this works but I need let them know the form was processed, otherwise when blank form shows again user will be left unsure if the data were sent or not..I see this every day here and there, simple form on a website to send a comment or something. You just fill the form, click send button, receive message box 'data was sent' and see the empty form again. Easy and elegant. And I am not able to implement or find the proper code for it, dunno why. Instead of it I have some external file to which I am redirected and I can't get back to my page. The forms out there I can see usually do not even leave their own page.....
Well you can use AJAX to submit the form "behind the scenes"... or you could use a session or cookie to store your "success message" so that when the page reloads it displays the message, then removes the cookie/session data. Plenty of ways to tackle it, but I'm not going to write it for you... you need to learn HOW to do it .
Of course, I wouldn't ask you for classes.. I normally do web graphics/design and just FF and IE differences drives me crazy enough to try do any coding. This is exception because I hoped it will be very easy (display box and go to the next page, it even SOUNDS easy....) but apparently I was wrong and I'm not going to study AJAX for that. Anyway, thanks for your time and help.
Ren wrote:Of course, I wouldn't ask you for classes.. I normally do web graphics/design and just FF and IE differences drives me crazy enough to try do any coding. This is exception because I hoped it will be very easy (display box and go to the next page, it even SOUNDS easy....) but apparently I was wrong and I'm not going to study AJAX for that. Anyway, thanks for your time and help.