Jump to content

Sending a variable via url parameter


petenaylor

Recommended Posts

Hi all

 

I am in the process of creating a product page where the user can type in three initials into a form and then 'clicks add to basket'.

 

The button doesn't use a form just a url:

 

basket.php?action=add&id=1&qty=1

 

This adds the item into a basket using sessions rather than a database. The question is, how do I add three variables into my form so that they are sent via the URL and into the session?

 

Wil I have to start again with a form?

 

Here's the code:

 

<td class="table-font-grey">Why not make your whip extra special by adding up to three elegantly engraved Kunstler script initials.</td>

            <td width="42" style="border: 1px solid grey;"><input name="initial_1" type="text" size="8" maxlength="1" height="40px" /></td>

            <td width="43" style="border: 1px solid grey;"><input name="initial_2" type="text" size="8" maxlength="1" height="40px" /></td>

            <td width="43" style="border: 1px solid grey;"><input name="initial_3" type="text" size="8" maxlength="1" height="40px" /></td>

          </tr>

          <tr>

            <td height="15"> </td>

            <td width="328" class="table-font"> </td>

            <td width="42" align="center" class="table-font">1</td>

            <td width="43" align="center" class="table-font">2</td>

            <td align="center" class="table-font">3</td>

            </tr>

          <tr>

            <td> </td>

            <td colspan="3" class="table-font"> </td>

            <td align="right" class="table-font"> </td>

          </tr>

        </table>

        <hr />

        <p> </p>

        <table width="494" border="0">

          <tr class="table-font">

            <td width="263" height="24">

           

            <a href="<?php echo "basket.php?action=add&id=1&qty=1" ?>" title="Add <?php echo $product['name'] ?> to Cart">

            <a href="<?php echo WEB_URL."basket.php?action=add&id=1&qty=1" ?>" title="Add <?php echo $product['name'] ?> to Cart">

            <img src="<?php echo WEB_URL."images/product-add-button.gif" ?>" alt="Buy <?php echo $product['name'] ?>" /></a>

           

Many thanks

Pete

 

Link to comment
https://forums.phpfreaks.com/topic/214198-sending-a-variable-via-url-parameter/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.