View Full Version : method to handle postback event??
sweetline priya
01-13-2009, 07:09 AM
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???
Dirt_Diver
01-13-2009, 11:57 AM
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...
if ($answer1 = true) {
print "The answer is true";
}
if ($answer2 == false) {
print "enter something here";
}
'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).
if ($answer1 = true) {
print "The answer is true";
}Careful — that will always be true. You probably meant == or, better, ===.
sweetline priya
01-13-2009, 03:37 PM
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..
So you just want to run some code? That's done simply by putting the code on the page (inside a <?php ... ?> block).
Dirt_Diver
01-14-2009, 02:47 AM
You may also want to make sure you spell everything correctly.
sweetline priya
01-14-2009, 04:15 PM
@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... :)
You mean the first time the user requests the page? Then, as I said earlier, sessions are the way to go:
<?php
session_start();
if (!@$_SESSION['something_done']) {
do_something();
$_SESSION['something_done'] = true;
}
?>
sweetline priya
01-14-2009, 04:42 PM
thank you for your immediate reply... i too have done the samething...
JasonDFR
01-16-2009, 07:08 AM
You may also want to make sure you spell everything correctly.
English is not everyone's native language.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.