|
-
Mar 14th, 2005, 03:24 PM
#1
Thread Starter
Addicted Member
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.
-
Mar 16th, 2005, 05:36 AM
#2
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
-
Mar 16th, 2005, 10:39 AM
#3
Thread Starter
Addicted Member
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.
-
Mar 17th, 2005, 05:23 AM
#4
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|