2012-03-04 73 views
0

如何將文本框的值分配給變量?如何將文本框的值分配給變量?

這裏是我的形式:

<form id="" method="post" action="photo_upload.php" enctype="multipart/form-data"> 
<table align="center" cellpadding="0" cellspacing="0" border="0" width="650px"> 
    <tr> 
    <td colspan="7"> 
    <input type="text" id="albumName" name="albumName" value="jaghamachi"/> 
    </td> 
    </tr> 
    <tr> 
    <td width="50px" align="center"/> 
    <td align="center" width="100px">Upload Pics::</td> 
    <td align="center" width="50px"/> 
    <td align="center" width="200px"> 
     <input type="file" id="file" name="file"/> 
    </td> 
    <td align="center" width="50px"/> 
    <td align="center" width="100px"> 
     <input type="submit" name="submit" id="submit" value="submit" class="button" style="width: 100px;" /> 
    </td> 
    <td align="center" width="50px"/> 
    <tr> 
    <td height="16px"/> 
    </tr> 
    </table> 
    </form> 
<?php 
// here i want a code similar to string str = Text1.Text like in .net; 
//i want a code smthng like this 
//$value= albumName.value; how to do it?? here albumName is the textbox type in above form 
?> 

怎樣纔可以完成,無需使用JavaScript或jQuery的?

回答

1

你可以這樣說:

$albumName = $_POST['albumName']; 

這裏:

  • $albumName是包含名爲albumName
  • $POST文本框的值的變量名稱的形式方法POST<form method="POST"

注1:對於工作,假設你第一次提交表單。

注2:要提交到同一頁面上,設置action<form>標籤的屬性來清空

0

你能做的就是發佈形式的唯一的事,並從$_POST

+0

他的價值不知道否則不會問問題,OP需要更好的解釋:) – Sarfraz 2012-03-04 10:12:50