开发者

open url from button using php

I need to make a button that:

  1. Send to php script variable pressed=true when its pressed
  2. open new tab with开发者_如何学运维 an adress

How can I do it without using java-script?


PHP can't cause events to happen in the client browser, you will need javascript for that. The button would have to submit the data to the PHP script, and then the script would display whatever output you like.

You could do this however

<FORM ACTION="phpscript.php" METHOD="POST" TARGET="_BLANK">
<BUTTON TYPE="submit" VALUE="1" name="pressed">Click</BUTTON>
</FORM>

This will open a new window(tab in FireFox at least)and you will have passed the value to your PHP script.

In your PHP script you check the value, and use a header to specify a new address:

if($_POST['pressed'] == 1 )
    header("Location: http://www.whatever.com");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜