Results 1 to 4 of 4

Thread: asp.net Linkbutton = php....

  1. #1

    Thread Starter
    Addicted Member DigitalMyth's Avatar
    Join Date
    Nov 2002
    Location
    England..
    Posts
    169

    asp.net Linkbutton = php....

    Hey,

    I'm looking for a php equal to a Linkbutton in asp.net, I need to set a value in the session BEFORE refreshing to the page that the hypelink points to, so in asp.net you can excute code before refresh but can u do it in PHP. i.e Posting in into the post method.
    Digitalmyth

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: asp.net Linkbutton = php....

    Could you ellaborate. I have no clue what you are talking about

    P.s: The code in your signature has errors (personally foor me this would be better)
    PHP Code:
    $drunk false;

    while (!
    $drunk) {
        
    $cans -= 6;
        
        for (
    $x 0$x 6$x++) {
            
    $cans[$x] > $neck;
        }

    Note the infinite loop
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Addicted Member DigitalMyth's Avatar
    Join Date
    Nov 2002
    Location
    England..
    Posts
    169

    Re: asp.net Linkbutton = php....

    I have Hyperlinks that refresh the page by pointing to itself.

    What i need to do is excute
    PHP Code:
    Session[HashIDBrow] = "C:\Blah\Blah\Blah" 
    before the browser reloads the page. So that the Scripts run from the new session value instead of using the old one.

    If i can help it i don't wish to use query strings. In VB, you have a button_click function that excutes on the button click event. Is there something like that in PHP.
    Digitalmyth

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: asp.net Linkbutton = php....

    I am still not entirely sure what you want. I have found out what the Link button is, thanks to TomGibbons - so if you would like an implementation of this in PHP then it is possible.
    What i need to do is excute
    PHP Code:
    Session[HashIDBrow] = "C:\Blah\Blah\Blah" 
    before the browser reloads the page.
    It is this bit I do not understand, you cannot execute programs on the users file system from a web page. You can execute Javascript code before the page is reloaded, which is how the link button works but not programs on the users file system.

    If its just a case of changing the session ID before the page refreshes then this is what you need to do:
    PHP Code:
    <?php
        
    /* chekc to see if the link button was clicked */
        
    if (isset($_POST['LINK_BUTTON'])) {
            
    link_form_click();
        }
        
        function 
    link_form_click()
        {
            
    /* this is executed when a link is clicked */
            
    $GLOBALS['button_name'] = $_POST['LINK_BUTTON'];
            
    $GLOBALS['session_id'] = @$_POST['SESSION_ID'];

            
    /* you can put code here to process your link button click */
        
    }
    ?>
    <html>
        <head>
            <title>Text Display</title>
            <script type="text/javascript">
            <!--
                function process_link(btnName)
                {
                    document.link_form.LINK_BUTTON.value = btnName;
                    document.link_form.SESSION_ID.value = session_gen();

                    document.link_form.submit();
                    
                }

                function session_gen()
                {
                    /* you should put code here to generate a new session ID
                       I will just use a random number for now */
                    
                    return Math.round(Math.random() * 100);
                }
            //-->
            </script>
        </head>
        <body>
            <form name="link_form" method="post">
                <input type="hidden" name="LINK_BUTTON" value="" />
                <input type="hidden" name="SESSION_ID" value="" />
            </form>
            <?php if(isset($button_name)): ?>
                <p>You clicked <?php echo($button_name?> and your new session ID is: <?php echo($session_id?></p>
            <?php endif; ?>
            <p>
                <a href="javascript: process_link('Link1')">Link 1</a>
                <a href="javascript: process_link('Link2')">Link 2</a>
            </p>
        </body>
    </html>
    Unlike ASP.NET, PHP is not event driven. Its also worth noting that link buttons and this example won't work in non Javascript Browsers.

    You can try it out here: http://adam.codedv.com/examples/link_button.php
    Last edited by visualAd; Mar 17th, 2005 at 05:27 AM.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width