Home > Backend Development > PHP Tutorial > php select表单提交未定义,该怎么处理

php select表单提交未定义,该怎么处理

WBOY
Release: 2016-06-13 11:56:19
Original
1113 people have browsed it

php select表单提交未定义
index.php

<form method="post" action="lib\ChkLogin.php"><br />    	..............................<br />            <select name="role"><br />            	<option value="student">student</option><br />                <option value="teacher">teacher</option><br />            </select><br />            </td><br />            </tr><br />            <tr><br />            <td><input type="submit" value="ok" /></td><br />            <td><input type="reset" value="no" /></td><br />            </tr><br />        <br />        </table><br />        </form>
Copy after login

ChkLogin.php
<?php<br />$username = $_POST['username'];<br />$passwd = $_POST['passwd'];<br />$role = $_POST['role'];<br />if($username==""||$passwd==""){<br />	echo "<script>";<br />	echo "alert(\"用户名或密码不能为空!\");";<br />	echo "location.href=\"../index.php\";";<br />	echo "</script>";<br />	}<br />        ......................<br />
Copy after login


错误提示:Notice: Undefined index: role in C:\wamp\www\myweb2\lib\ChkLogin.php on line 4

username和password都正常,role过不了,怎么回事啊?

------解决方案--------------------
如果这是全部代码,$_POST['username']和$_POST['passwd']也会报错。
------解决方案--------------------
我只是把 

改成
也就是斜线改一下,我这里可以传过去
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template