2014-01-22 44 views
0

所以這裏就是我試圖做生成自定義網址, 比方說有我的網址如何使用文本字段在PHP

http://myurl.com/watch?v=**XYZ**&caption=**ABC**&link=**http://google.com** 

我想以粗體顯示的文本從用戶例如輸入:

**v**= textfield1 
    **caption**= textfield2 
    **link**= textfield3 

提交按鈕

點擊提交應產生「點擊這裏」,這將應該打開生成新窗口的URL文本之後。

http://myurl.com/watch?v=**XYZ**&caption=**ABC**&link=**http://google.com** 

回答

0

最好的選擇是使用JavaScript。

您可以將文本框中的值提交(檢查here)並創建您的網址。 在您將汽車重定向到您的頁面後使用window.location

0

Ι創建了一個您希望的頁面。

的index.php

<html> 
<head> 
    <title>My Page</title> 

<script type="text/javascript"> 

function takevalues() 
{ 
var value1 = document.getElementById('textfield1').value; 
var value2 = document.getElementById('textfield2').value; 
var value3 = document.getElementById('textfield3').value; 

window.location = "http://myurl.com?value1="+value1+"&value2="+value2+"&value3="+value3; 
} 
</script> 
</head> 
<body> 
    <form name="myform" action="javascript:takevalues()" method="POST"> 
     <div align="center"> 
     <br><br> 
     <input type="text" size="25" id ="textfield1"> <br> 
     <input type="text" size="25" id ="textfield2"> <br> 
     <input type="text" size="25" id ="textfield3"> <br> 
     <br><br> 
     <input type="submit" size="value" id ="Submit"> 
     </div> 
    </form> 
</body> 
</html> 
相關問題