Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,459 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,844 people online right now. Registration is fast and FREE... Join Now!




Passing parameters to PHP script

 
Reply to this topicStart new topic

Passing parameters to PHP script

cygnusX
4 Aug, 2008 - 03:54 AM
Post #1

D.I.C Head
**

Joined: 19 May, 2007
Posts: 159



Thanked: 2 times
My Contributions
I'm retrieving data from a database with AJAX/PHP.How to pass some parameter to the PHP script?

CODE
xmlHttp.open("POST","products.php?parameter=bla",true);
xmlHttp.send(null);

PHP code
CODE
if(isset($_POST['parameter']))
{
    while($products = mysql_fetch_array($result))
   {
      //do something
   }
}

As far as i know that's the right way to do this - xmlHttp.open("POST","something.php?parameter=parameterValue",true).Isn't?When i open the page in the browser and send the request to the server nothing happens,i mean the code in the 'if' block is not executed.The rest of my code in the PHP script works fine so i think that isset($_POST['parameter'])) is the problem.

This post has been edited by cygnusX: 4 Aug, 2008 - 03:55 AM
User is offlineProfile CardPM
+Quote Post

BetaWar
RE: Passing Parameters To PHP Script
4 Aug, 2008 - 03:36 PM
Post #2

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 2,023



Thanked: 81 times
Dream Kudos: 1175
My Contributions
WHen using the post method you have to change the way you are sending Ajax queries tot he server. You need to do something more like so:

CODE
xmlHttp.open("POST","products.php",true);
xmlHttp.send("parameter=bla");


That way it is posting the variables instead of sending them through the "GET" method.

Hope that helps.
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 03:53PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month