What i am trying to do is to make a like that sends some info to next page so that PHP could use query for the deta sent.

OK here is how the hyper link looks like and i want it to send some variable to next page:

<a href="index.php" onClick="window.open('./Someting.php', 'newwindow', 'height=720,width=520,toolbar=no,menubar=no,scroolbar=no,resizable=no,location=no,directories=no,status=no'); return false;">
      Item Description Click Here

any help on how would i send and variable containg the item # to next page... :cool:

Recommended Answers

All 6 Replies

you need to use the GET method to define variables and send them to another page via a URL. For example:

<a href="next_page.php?first_variable=5&second_variable=3" onClick="window.open('http://www.yourdomain.com/next_page.php?first_variable=5&second_variable=3', '', 'height=720,width=520,toolbar=no,menubar=no,scroolbar=no,resizable=no,location=no,directories=no,status=no'); return false;">Item Description Click Here</a>

Your variable assignments come after the ? in the URL and are separated by &'s....

Then, on next_page.php, invoke the following code:

$first_variable = $_GET['first_variable'];
$second_variable = $_GET['second_variable'];

Now you have access to your information via the variables $first_variable and $second_variable. You can use the variables in your database query now.

read this tutorial that i wrote. It uses PHP/MySQL/HTML-Forms to pass data to another page to run queries on it.

You could probably read through that and get the general idea of how to use forms and such.

Well that explains it. Thanks I fineally was able to send data to another page.

Member Avatar for Electrohead

If you are dealing with passwords, you should use the POST method rather than GET, as it will prevent it from displaying in the address bar..

However, for searches or other non-secret inputs you can just use GET
Hope it helps :cheesy:

Which is the better method? GET or POST?

I particularly like POST because you don't see information being passed in the address...

Which is the better method? GET or POST?

I particularly like POST because you don't see information being passed in the address...

thats a hard question because it depends on the information being passed and the ammount of it.

I prefer post because that is what i learned with. but i have much possitive feedback from get too. but for those that wish to build a form to pass things such as passwords, POST is the way to go because it is not passed through the addressbar.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.