2013-07-13 37 views

回答

0

這是服務器端腳本作業。您可以看看一些MVC框架和url參數

0

如果您使用.net,則可以使用PHP symfony或codeignitor,然後創建一個新的MVC項目。

但是如果你只需要像

www.mysite.com/mypage.php?something=value 

變更網址,以

www.mysite.com/value 

您可以在Apache中做mod rewrite,或者如果你正在使用.NET,然後在您的全球使用RegisterRoutes。 asax.cs

+0

所以,如果我們沒有使用什麼.NET也不PHP重寫?另一種選擇是什麼? –

+0

@CassidyWilliams你在用什麼? – HMR

+0

@CassidyWilliams我假設你知道關於POST,GET,PUT和DELETE請求,我們正在討論如何實現SEO友好的url,就像在這個網站上使用的那樣,或者像'www.myblog.com/camping_in_guilin'而不是' www.myblog.com/article.php?articleid = 22' – HMR

1

您可以使用onSubmit並通過javascript更改表格的action屬性,然後返回true。代碼看起來是這樣的:

HTML從鏈接頁面:

<form id="createRoom"> 
    <input id="sessionInput" placeholder="Name the conversation" autofocus="autofocus"> 
    <button type="submit">Let’s go!</button> 
</form> 

JS代碼:

document.getElementById("crateRoom").onsubmit = function(){ 
    var url = encodeURIComponent(document.getElementById("sessionInput").value); 
    document.getElementById("crateRoom").action = "/" + url; 
    return true; 
} 
0

可以使用形式的GET方法;例如:

<form action="index.php" method="get"> 
Page: <input type="text" name="page"> 
<input type="submit" value="Submit"> 
</form> 

提交後會去index.php?page=yourEnteredPage

0

使用form您可以將數據提交到在的爲action屬性給出一個location/url,例如

<form method="POST" action="http://example.com"> 
    <input name="first_name" type="text" value="" /> 
    <!-- Form elements --> 
    <input type="submit" name="mySubmitButton" value="Submit"> 
</form> 

這種形式將表單數據提交給action URL時,提交會按下並在derver數據可以檢索使用

$first_name = $_POST['first_name';]; 

等等。方法POST用於提交數組中的表單,因此您可以使用$_POST['formfieldname']檢索數據,如果使用method="GET",則可以從$_GET變量中獲取提交的數據,例如$fname=$_GET['first_name']GET提交數據時有限制(可安全使用最多2000個字符IE's limit),並且對於瀏覽器的address bar可見並且不用於登錄(密碼),並且POST可以發送比GET更多的數據,並且對地址欄也不可見。 You may read this.

0
+0

請注意,[只有鏈接的答案](http://meta.stackoverflow.com/tags/link-only-answers/info)不鼓勵,所以答案應該成爲尋找解決方案的終點(而另一個引用停留時間往往會隨着時間推移而變得陳舊)。請考慮在此添加獨立的摘要,並將鏈接保留爲參考。 – kleopatra