Re: Set session variable if link is clicked, do not want to use GET

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



you can use POST with some javascript tricks.

lets assume that you are going to you an image file to submit, then just add
a function andd call that function to handle submitting data.

here is an example:

<form name=TestForm action=test.php method=post>
<input type=hidden name=op value=5>
<IMG src=a.gif onclick="SubmitMyForm();'>
</form>

then define the javascript function named as SubmitMyForm
<script language=javascript>
    document.TestForm.submit();
</script>

your form will be subbmitted just fine by this method.


----- Original Message ----- 
From: "Kent" <kent.larsson@xxxxxxxxx>
To: <php-general@xxxxxxxxxxxxx>
Sent: Tuesday, April 05, 2005 3:21 AM
Subject:  Set session variable if link is clicked, do not want to use
GET


> Hi!
>
> I am writing a simple shopping cart system which uses sessions and PHP.
>
> I would like a normal link that says "Add to cart" which the user can
> click and the item is added to the cart.
>
> However, i do not want to use GET for this as it could introduce
> unwanted features if the user bookmarks the page just after clicking
> "Add to cart". So i don't want an URL like:
> http://thisistheurl.com?buy=10 and therefore prefer if this could be
> done using POST.
>
> It would have been easy if i would have used a normal FORM and would
> have had a button called "Add to cart". But i would like it to be in
> url-style or using some <img ..> which i understand that the BUTTON item
> does not support (or am i wrong?).
>
> Any advice would be greatly appreciated.
>
> Best regards, Kent
>
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux