douling8087 2010-04-10 18:29
浏览 16

将索引号的值传递给不同的php文件

i am a php beginner and have a question for you please.

i have a text file with list of first and last names like this:

john,smith
sam,lewis
david,davidson
mike,anderson

in my sort.php file, it sorts that name list by first name in ascending order with index number, which will display like this:

1. david,davidson
2. john,smith
3. mike,anderson
4. sam,lewis

also, in that sort.php file, there's a form for input type=text where you can type index number and a button to delete that index number entered in that text field:

<form action="deletename.php" method="post">
  <table>
    <tr valign="top"> 
      <td>Delete: <input type="text" size="2" name="indexnumber" />
      </td>
      <td> 
        <div align="left"> 
          <input type="submit" name="delete" value="Delete" />
        </div>
      </td>
    </tr>
  </table>
</form>

now the question...is there anything i can do in that form to send the value of that index number i entered in the text field? in other word...if i enter 3, what can i do to that form to send the value "mike,anderson" to deletename.php?

thanks in advance.

  • 写回答

2条回答 默认 最新

  • douwo8358 2010-04-10 18:39
    关注

    When using forms you can specify how the variables are sent to your script using either GET or POST, this is definied in your <form> tag. You have choosen to use a POST method (sensible). POST method hides the information from the user where as GET method uses the website's URL to pass variables, eg /deleteme.php?indexnumber=2

    The values will then becomes readable on deletename.php (because thats where your submitting your form to) by accessing the $_POST array. If you entered 2 in your form you can read the value like so.

    echo $_POST['indexnumber'];
    /* OUTPUT */
    2
    

    Using this id, it will be up to you to find out which index number this id matches with. If you were using a database, this would be alot efficient and easier to maintain. I suspect you need to read some tutorials on PHP before going any further.

    评论

报告相同问题?

悬赏问题

  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致