943,639 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 355
  • PHP RSS
Jul 13th, 2009
0

PHP and AJAX

Expand Post »
I have an html page. when you click a button, an AJAX function will call a php page (like register.php). That page contains a form.
the URL is index.html and doesn't change to register.php because I called the PHP page through AJAX
Now that problem is: when I click the submit, I loose the html page and redirected to the register.php (the form handler is on the same page register.php).
I want the results and error messages to be displayed on the same page (index.html).

I hope the explanation was clear enough to be understood.
Thanks for the help
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
codemaker is offline Offline
20 posts
since Nov 2004
Jul 13th, 2009
0

Re: PHP and AJAX

Hi...

Ok, i got your problem. Since you would have put action in your form tag as register.php, so this is bound to go to the register.php page. Instead you can do one thing:

Set the results/error messages in the SESSIONS variable. Now call index.html page and on body onload event, call another page through ajax that reads the session messages and displays them.

Check out if this helps.
Reputation Points: 11
Solved Threads: 12
Junior Poster in Training
sikka_varun is offline Offline
94 posts
since Dec 2008
Jul 13th, 2009
0

Re: PHP and AJAX

Thanks alot for the quick reply.
I was thinking of this solution but I had problems:-
1- Where should I put the code of handling the form, in the index.html page or in the register.php page?
2- If I put index.html in the action (action="index.html") and click the submit of the form, I loose the form and get only the index.html

I usually use SESSIONS when I want to pass variable between two pages or two scripts but in this case, how can I make the HTML and the PHP pages presist when I click the submit button?

Thanks
Reputation Points: 10
Solved Threads: 0
Newbie Poster
codemaker is offline Offline
20 posts
since Nov 2004
Jul 13th, 2009
0

Re: PHP and AJAX

Hey guys
Any ideas?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
codemaker is offline Offline
20 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: How we can fetch value on same page in PHP???
Next Thread in PHP Forum Timeline: Writing to Div from a Image Link





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC