Passing variable throught hyperlink

Discussion in 'PHP' started by blogfisher, Dec 8, 2008.

  1. #1
    Hi,
    I want to pass my variable value when someone click on hyperlink. However i don't want to pass along with '?' i.e.

    <a href="http://site1.com?val=$num">link1</a>

    Is there any other way ? As i have more than 50 links as below :

    <a href="http://site1.com>Site1</a> - pass value 1 to site1.com
    <a href="http://site2.com>Site2</a> - pass value 2 to site2.com
    <a href="http://site3.com>Site3</a> - pass value 3 to site3.com
    <a href="http://site4.com>Site4</a> - pass value 4 to site4.com
    <a href="http://site5.com>Site5</a> - pass value 5 to site5.com
    and so on...

    Is it possible to pass through post method something like using form... ??
     
    blogfisher, Dec 8, 2008 IP
  2. harrisunderwork

    harrisunderwork Well-Known Member

    Messages:
    1,005
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    135
    #2
    Yup using mod rewrite , it is possible but have to construct regular expression for that. But u can't pass it using post, only get is possible .
     
    harrisunderwork, Dec 8, 2008 IP
  3. octalsystems

    octalsystems Well-Known Member

    Messages:
    352
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    135
    Digital Goods:
    1
    #3
    you can use like this

    <a href="http://site1.com?val=$num" onclick='document.postform.val.value="<?php echo($val);?>";document.postform.submit();return false;'>link1</a>
    <form method='post' name='postform'>
    <input type='hidden' name='val' />
    </form>
     
    octalsystems, Dec 8, 2008 IP