Question:
how can I send information from a web page to a php page without opening the php page?
juaneco_el_lokeko
2007-07-20 19:21:28 UTC
I need to make a rating system like youtube where I can rate something and sent the information to a database I guess I have to do it through a php page, but how can I send the information without opening in a window?
Three answers:
anonymous
2007-07-21 04:11:13 UTC
You could use php and javascript. If its a rating system, I am guessing that the user has to perform some action on their end and using javascript you could run a mysql insert into database.(You run the action based on the click of a button or the onChange of a field etc etc, not based on submitting the form) You could also just use Javascript alone given that you know how to perform a database insert with it.
Mike
2007-07-21 02:26:52 UTC
Why do you need php?



Just make a form and submit the data. PHP has nothing to do with anything.... php is just a web language were the code is compiled on the fly by the server when a browser requests it.



PHP is unrelated to what you want to do... give more details (such as database type) and I can help more.
a_non_a_miss_2000
2007-07-21 02:58:23 UTC
You want to do some AJAX!



Using something called the XMLHTTPRequest object, you can request data from a different location. Using the same concept, you can send data to a php page behind the scenes.



Set up your php page to receive your "form data". Using the XMLHTTPRequest object, you can have your javascript send a URL encoded with your data to your PHP page. When your PHP has processed the data, have it return a success value to your XMLHTTPRequest object. Depending on the value, you can execute some javascript to tell your user his vote was received.



There's a little more to this than I have time for, but check out the following link:

http://developer.apple.com/internet/webcontent/xmlhttpreq.html



I found the following book, quite useful: AJAX HACKS: Tips & Tools for Creating Responsive Web Sites (O'Reilly)

http://www.oreilly.com/catalog/ajaxhks/



The Data Analyst

http://www.squidoo.com/thedataanalyst


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...