Page 1 of 1
php variable Link Button?
Posted: Tue Jan 18, 2011 4:18 pm
by liveman
Hi, I am trying to implement the following code, however it's just not working, as you can see it's a button which goes to a URL after being clicked, the URL should be that of the variable $test. Any help kindly appreciated
<?php
$test = '
http://www.facebook.com/';
Print'
<FORM METHOD="LINK" EVENT="$test">
<INPUT TYPE="submit" VALUE="view Event">
</FORM>'
?>
Re: php variable Link Button?
Posted: Tue Jan 18, 2011 5:09 pm
by social_experiment
Code: Select all
<?php
$test = 'http://www.facebook.com/';
Print'
<FORM METHOD="LINK" EVENT="'. $test. '">
<INPUT TYPE="submit" VALUE="view Event">
</FORM>';
?>
Hth
Re: php variable Link Button?
Posted: Tue Jan 18, 2011 5:12 pm
by anantha
you can add an onclick event....there are number of ways to do this..
Code: Select all
echo '<INPUT TYPE="submit" onclick="window.location='.$test.'" VALUE="view Event">';
Re: php variable Link Button?
Posted: Tue Jan 18, 2011 5:35 pm
by liveman
Hi Social_Experiment & Anantha I have tried both of your solutions and nothing is working. Is what I am trying to do actually possible without using Javascript?
It works find on a html link with the following code:
Code: Select all
Print"
<a href='$test'>view Event</a><br/>";
Thanks for your help so far and FYI I have used both Chrome and Safari to check the results

Re: php variable Link Button?
Posted: Wed Jan 19, 2011 10:28 am
by social_experiment
Code: Select all
<?php
$test = 'http://www.facebook.com/';
Print'
<FORM METHOD="LINK" EVENT="$test">
<INPUT TYPE="submit" VALUE="view Event">
</FORM>'
?>
The problem might be your form code. There is no EVENT attribute that can be used with the form tag. Also, LINK is not a valid value for method, it's either post, get (of which get is deprecated). If you aren't posting information simply use an anchor tag <a>.
Code: Select all
<?php
echo '<a href="'. $test .'">view Event</a>';
?>