How do I assign the value of a textbox to a variab

2019-09-14 22:52发布

How do I assign the value of a textbox to a variable?

Here is my form:

<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
?>

How can it be done, without using javascript or jquery?

标签: php textbox
2条回答
Juvenile、少年°
2楼-- · 2019-09-14 22:54

You can do it like this:

$albumName = $_POST['albumName'];

Here:

  • $albumName is the variable name containing value of text box named albumName
  • $POST is the form method POST eg <form method="POST"

Note 1: For that to work, it is assumed that you submit the form first.

Note 2: To submit to same page, set action attribute of <form> tag to empty

查看更多
唯我独甜
3楼-- · 2019-09-14 23:03

The only thing you can do is posting the form, and the the value from $_POST

查看更多
登录 后发表回答