Capacitacion N° 1 - Conexion BD PHP
-
Upload
johnny-luis-regal-vargas -
Category
Documents
-
view
220 -
download
0
description
Transcript of Capacitacion N° 1 - Conexion BD PHP
Fijo: (054) 231248 RPC: 982533084 / 982533096
Movistar: 952032033 www.facebook.com/GrupoHexagonos
AQP COMPUCENTRO - Calle Paucarpata #126 - Segundo Piso - Oficina 204CercadoArequipa - Perú
CAPACITACION N° 1 – CONEXIÓN BD - PHP
PONENTE : MSc. Ing. Johnny Luis Regal Vargas
1.- Agregar esta instrucción despues de la etiqueta <body>
<form action="conexion.php" method="post">
2.- El programa “conexion.php” va a contener las siguientes instrucciones:
<?php$dbhost='tuservidor'; $dbusername='tuusuario';$dbuserpass='tupassword'; $dbname='tubd';mysql_connect ($dbhost, $dbusername, $dbuserpass);mysql_select_db($dbname) or die(mysql_error());
$user=$_POST['formtext1']; $pass=$_POST['formtext2'];$instruccion= mysql_query("select usuario from usuarios where password='$pass'");$registro = mysql_fetch_array($instruccion);$a=$registro['usuario'];session_start();$_SESSION["s_username"] = $a;if ($user=="" && $pass==""){header ("Location: index.html"); }else{ if ($user == $a){ header("Location: principal.html"); }else{ header("Location: index.html"); }}?>
3.- La Base de datos es: “SISTEMA”.4.- Crear una tabla “USUARIOS” la cual debe contener los siguientes campos:
a) IDUSUARIO INTEGER NOT NULL AUTOINC UNSIGNEDb) USUARIO VARCHAR(45) NOT NULLc) PASSWORD VARCHAR(45) NOT NULL