Results 1 to 10 of 10

Thread: method to handle postback event??

  1. #1
    Join Date
    Jan 2009
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question method to handle postback event??

    hii..

    in asp.net "isPostback()" is used to handle the postback event.. lik tat which method is used in php??

    in my project i wanna execute a set of code only durin the page load alone... 4 tat i need tis method....
    i used a method "isset($_POST)".. but its nt workin properly!!

    can anybody help me???

  2. #2
    Join Date
    Aug 2008
    Location
    Smiths, AL
    Posts
    164
    Thanks
    30
    Thanked 5 Times in 5 Posts

    Default

    From my understanding isPostBack is a ASP.net property which indicates whether a PostBack occurred. For PHP you need to use a boolean which determines if your statement is true or false.

    Try something like this: I am still learning PHP so if this isn't right don't be upset...

    PHP Code:
    if ($answer1 true) {
       print 
    "The answer is true";
    }

    if (
    $answer2 == false) {
       print 
    "enter something here";


  3. The Following User Says Thank You to Dirt_Diver For This Useful Post:

    sweetline priya (01-14-2009)

  4. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    'Postback' is a particularly hideous method ASP.NET has of passing data around between page requests. Basically it involves having Javascript submit a hidden form every time the user clicks a link.

    The equivalent for your purposes is probably to use a session. If you just wanted to handle POST requests, then simply check whether the POST variable you want is available (remember, GET and POST aren't entirely mutually exclusive: it's possible to POST to an URL that has query data tacked onto the end of it).

    PHP Code:
    if ($answer1 true) {
       print 
    "The answer is true";

    Careful — that will always be true. You probably meant == or, better, ===.
    Last edited by Twey; 01-13-2009 at 01:59 PM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. The Following User Says Thank You to Twey For This Useful Post:

    sweetline priya (01-14-2009)

  6. #4
    Join Date
    Jan 2009
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Smile

    thank u 4 ur reply...

    but wat i actually want is.. durin the FIRST page load i want to execute a set of code.. but tis code should nt be executed wen a button in tat page is clicked..

  7. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    So you just want to run some code? That's done simply by putting the code on the page (inside a <?php ... ?> block).
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #6
    Join Date
    Aug 2008
    Location
    Smiths, AL
    Posts
    164
    Thanks
    30
    Thanked 5 Times in 5 Posts

    Default

    You may also want to make sure you spell everything correctly.

  9. #7
    Join Date
    Jan 2009
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Cool

    @Twey..

    if i write the code in <?php .. ?> block, it will be executed everytime when the page is loaded..


    ok friends.. thank you for your replies.. i have made another solution for this problem...

  10. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You mean the first time the user requests the page? Then, as I said earlier, sessions are the way to go:
    Code:
    <?php
      session_start();
    
      if (!@$_SESSION['something_done']) {
        do_something();
        $_SESSION['something_done'] = true;
      }
    ?>
    Last edited by Twey; 01-16-2009 at 02:11 PM. Reason: Suppress a warning.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  11. #9
    Join Date
    Jan 2009
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Smile

    thank you for your immediate reply... i too have done the samething...

  12. #10
    Join Date
    Apr 2008
    Location
    Limoges, France
    Posts
    395
    Thanks
    13
    Thanked 61 Times in 61 Posts

    Default

    Quote Originally Posted by Dirt_Diver View Post
    You may also want to make sure you spell everything correctly.
    English is not everyone's native language.

  13. The Following User Says Thank You to JasonDFR For This Useful Post:

    sweetline priya (01-20-2009)

Bookmarks

Posting Permissions

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