2013-10-15 37 views
0

我本來用$ _GET方法:

'<a href = "editNews.php?starts='.$starts.'&ends='.$ends.'&$event='.$event.' data-role="button" data-icon="edit"></a>' 

使用該作品,但我已經被告知,使用$ _ POST方法更好,混亂,只是少首選的選擇。

所以我不知道我怎麼會實現與上述同樣的事情,但使用$ _ POST方法。

+0

只是隱藏字段和set方法添加一個形式'POST' – Carlangueitor

回答

0

您可以提交使用方法後一種形式或使用Ajax請求。 jQuery中,這將是這樣的:

$("#myLinkId#").on('click',function() { 
    $.ajax({url:'phpFile.php',type:'post',data:{...you data here...}}); 
}); 
0

你需要把它變成一個形式或使用jQuery觸發點擊一個Ajax調用。這裏有一個表單的例子:

<form action="editNews.php" method="post"> 
    <input type="hidden" name="starts" value="<php echo $starts?>"> 
    <input type="hidden" name="end" value="<php echo $end?>"> 
    <input type="hidden" name="event" value="<php echo $event?>"> 
    <input type="submit" name="submit" value="Your Link" data-icon="edit"> 
</form> 
+0

這是你會跟你的替換''鏈接的例子... –

0

要通過PHP發送數據到另一個頁面/形式,你可以這樣做:

原形態:

<form method='post' action='new-page.php'> 
    inputs here, etc. 
    submit button here 
</form> 

所以這個意志,在點擊提交,發送給new-page.php,其中包含PHP變量$_POST中的所有表單數據,這是一個數組。

可以通過引用與輸入的名稱數組訪問的數據,例如,說你有:

<input type='text' name='NAME' />

您可以參考這個數據上new-page.php$_POST['NAME']

我希望這可以幫助你!