大家好,我尝试在 php 中做一个 Authenticate 表单。
首先我创建一个表单
<form id="frmlogin" name="frmlogin" method="post" action="validarUsuario.php">
<table align="center" width="200px">
<tr>
<td colspan="2" align="center"><h3>Iniciar sesión</h3></td>
</tr>
<tr>
<td>Usuario</td>
<td>
<input type="text" name='usuario' id="usuario" maxlength="50">
</td>
</tr>
<tr>
<td>Password</td>
<td>
<input type="password" name='password' id="password" maxlength="50">
</td>
</tr>
<tr>
<td colspan="2" align="right">
<input type="submit" name="enviar" value="Enviar" >
</td>
</tr>
<?php
我调用了validarUsuario,所以我包含了require_once '../Classes/validarUsuario.php';
在 validarUsuario.php 我有这个代码
include("conectar_bd.php");
conectar_bd();
$usr = $_POST['usuario'];
$pw = $_POST['password'];
//Obtengo la version encriptada del password
$pw_enc = md5($pw);
$sql = "SELECT * FROM ubc_admin_user
WHERE username = '".$usr."'
AND password = '".$pw_enc."' ";
$result =mysql_query($sql,$conexio);
$uid = "";
但我收到此错误
Notice: Undefined index: usuario in /Users/yp/Sites/.../Classes/validarUsuario.php on line 14 Call Stack: 0.0018 646416 1. {main}() /Users/yp/Sites/.../download/index.php:0 0.0020 654048 2. require_once('/Users/yp/Sites/.../validarUsuario.php') /Users/yp/Sites/.../index.php:38 Notice: Undefined index: password in /Users/yp/Sites/...validarUsuario.php on line 15 Call Stack: 0.0018 646416 1. {main}() /Users/../index.php:0 0.0020 654048 2. require_once('/Users/yp/Sites/.../validarUsuario.php') /Users/yp/Sites/../index.php:38
任何的想法!