Click here to Skip to main content
15,354,423 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: MVC control libraries Pin
#realJSOP20-Dec-20 3:51
mva#realJSOP20-Dec-20 3:51 
QuestionDebugging two ASP.NET projects with Chrome - Failed to launch debug adapter Pin
glen20516-Dec-20 21:55
Memberglen20516-Dec-20 21:55 
AnswerRe: Debugging two ASP.NET projects with Chrome - Failed to launch debug adapter Pin
F-ES Sitecore17-Dec-20 22:51
professionalF-ES Sitecore17-Dec-20 22:51 
QuestionPHP4.3 Mod, coloring table rows Pin
jkirkerx1-Dec-20 9:29
professionaljkirkerx1-Dec-20 9:29 
AnswerRe: PHP4.3 Mod, coloring table rows [solved] Pin
jkirkerx1-Dec-20 9:34
professionaljkirkerx1-Dec-20 9:34 
AnswerRe: PHP4.3 Mod, coloring table rows Pin
Richard Deeming1-Dec-20 21:55
mveRichard Deeming1-Dec-20 21:55 
GeneralRe: PHP4.3 Mod, coloring table rows Pin
jkirkerx2-Dec-20 8:30
professionaljkirkerx2-Dec-20 8:30 
QuestionHow to insert roles in php and mysql? Pin
Nicolas Veloso16-Nov-20 6:04
MemberNicolas Veloso16-Nov-20 6:04 
Hello good, I have a query, what happens is that I want to enter user roles in my code but I don't know how to do it, I have the registration and login form already created, I just need to add the reference that I already mentioned above:

register_user_be.php:

PHP
<?php

include 'conexion_be.php';

$nombre_completo = $_POST['nombre_completo'];
$correo = $_POST['correo'];
$usuario = $_POST['usuario'];
$contrasena = $_POST['contrasena'];
$contrasena = hash('sha512', $contrasena);

$query = "INSERT INTO usuarios(nombre_completo, correo, usuario, contrasena)
VALUES('$nombre_completo', '$correo', '$usuario', '$contrasena')";

//Verificar que el correo no se repita en la bd


$verificar_correo = mysqli_query($conexion, "SELECT * FROM usuarios WHERE correo='$correo' ");
if (mysqli_num_rows($verificar_correo) > 0) {
echo '
<script>
alert("Este correo ya está registrado");
window.location = "../index.php";
</script>
';
exit();
}

//Verificar que el nombre de usuario no se repita en la bd


$verificar_usuario = mysqli_query($conexion, "SELECT * FROM usuarios WHERE usuario='$usuario' ");
if (mysqli_num_rows($verificar_usuario) > 0) {
echo '
<script>
alert("Este usuario ya está registrado");
window.location = "../index.php";
</script>
';
exit();
}

$ejecutar = mysqli_query($conexion, $query);
if ($ejecutar) {
echo '<script>
alert("Usuario registrado correctamente");
window.location = "../index.php";
</script>';
}else{
echo '<script>
alert("Inténtalo de nuevo, usuario no registrado");
window.location = "../index.php";
</script>';
}

mysqli_close($conexion);

?>

login_usuario_be.php:

PHP
<?php

session_start();

include 'conexion_be.php';

$correo = $_POST['correo'];
$contrasena = $_POST['contrasena'];
$contrasena = hash('sha512', $contrasena);

$validar_login = mysqli_query($conexion, "SELECT * FROM usuarios where correo='$correo' and contrasena='$contrasena'");

if (mysqli_num_rows($validar_login) > 0) {
$_SESSION['usuario'] = $correo;
header("location: ../inicio.php");
exit;
}else{
echo '
<script>
alert("El usuario no existe, por favor verifique los datos introducidos");
window.location = "../index.php";
</script>
';
exit;
}

?>


index.php:

PHP
<?php

session_start();

if (isset($_SESSION['usuario'])) {
header("location: inicio.php");
}

?>


HTML
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Iniciar Sesión</title>
<link rel="stylesheet" type="text/css" href="assets/css/estilos.css">
</head>
<body>
<main>
<div class="contenedor__todo">
<div class="caja__trasera">
<div class="caja__trasera-login">
<h3>¿Ya tienes una cuenta?</h3>
<p>Inicia sesión para entrar a la página</p>
<button id="btn__iniciar-sesion">Iniciar sesión</button>
</div>
<div class="caja__trasera-register">
<h3>¿Aún no tienes una cuenta?</h3>
<p>Regístrate para que puedas iniciar sesión</p>
<button id="btn__registrarse">Regístrate</button>
</div>
</div>
<!--Formulario de registro y login-->
<div class="contenedor__login-register">
<!--Login-->
<form action="php/login_usuario_be.php" method="POST" class="formulario__login">
<h2>Iniciar sesión</h2>
<input type="text" placeholder="Correo electrónico" name="correo">
<input type="password" placeholder="Contraseña" name="contrasena">
<button>Entrar</button>
</form>
<!--Registro-->
<form action="php/registro_usuario_be.php" method="POST" class="formulario__register">
<h2>Regístrarse</h2>
<input type="text" placeholder="Nombre Completo" name="nombre_completo">
<input type="text" placeholder="Correo Electrónico" name="correo">

 

<input type="text" placeholder="Usuario" name="usuario">
<input type="password" placeholder="Contraseña" name="contrasena">
<button>Regístrarse</button>
</form>
</div>
</div>
</main>
<script src="assets/js/script.js"></script>
</body>
</html


modified 17-Nov-20 3:47am.

SuggestionRe: How to insert roles in php and mysql? Pin
Richard Deeming16-Nov-20 21:51
mveRichard Deeming16-Nov-20 21:51 
QuestionBlazor SPA Pin
Super Lloyd16-Nov-20 1:26
MemberSuper Lloyd16-Nov-20 1:26 
QuestionDesign questions about asp.net core website and asp.net core webapi Pin
instantmaker13-Nov-20 9:04
Memberinstantmaker13-Nov-20 9:04 
AnswerRe: Design questions about asp.net core website and asp.net core webapi Pin
Afzaal Ahmad Zeeshan14-Nov-20 1:50
mveAfzaal Ahmad Zeeshan14-Nov-20 1:50 
GeneralRe: Design questions about asp.net core website and asp.net core webapi Pin
instantmaker14-Nov-20 2:49
Memberinstantmaker14-Nov-20 2:49 
GeneralRe: Design questions about asp.net core website and asp.net core webapi Pin
Afzaal Ahmad Zeeshan14-Nov-20 3:17
mveAfzaal Ahmad Zeeshan14-Nov-20 3:17 
GeneralRe: Design questions about asp.net core website and asp.net core webapi Pin
instantmaker16-Nov-20 13:03
Memberinstantmaker16-Nov-20 13:03 
AnswerRe: Design questions about asp.net core website and asp.net core webapi Pin
Leif Simon Goodwin22-Dec-20 7:17
MemberLeif Simon Goodwin22-Dec-20 7:17 
GeneralRe: Design questions about asp.net core website and asp.net core webapi Pin
instantmaker22-Dec-20 7:34
Memberinstantmaker22-Dec-20 7:34 
GeneralRe: Design questions about asp.net core website and asp.net core webapi Pin
Leif Simon Goodwin22-Dec-20 9:07
MemberLeif Simon Goodwin22-Dec-20 9:07 
GeneralRe: Design questions about asp.net core website and asp.net core webapi Pin
instantmaker22-Dec-20 10:39
Memberinstantmaker22-Dec-20 10:39 
QuestionDesign question with asp.net core and asp.net core api Pin
instantmaker13-Nov-20 6:18
Memberinstantmaker13-Nov-20 6:18 
QuestionI keep getting a “Call to undefined function..” error displaying Pin
IAmSirAskAlot9-Nov-20 18:25
MemberIAmSirAskAlot9-Nov-20 18:25 
QuestionWeb API Deserialization Problem Pin
Kevin Marois9-Nov-20 8:04
professionalKevin Marois9-Nov-20 8:04 
AnswerRe: Web API Deserialization Problem Pin
Richard Deeming9-Nov-20 22:20
mveRichard Deeming9-Nov-20 22:20 
GeneralRe: Web API Deserialization Problem Pin
Kevin Marois10-Nov-20 7:18
professionalKevin Marois10-Nov-20 7:18 
GeneralRe: Web API Deserialization Problem Pin
Richard Deeming10-Nov-20 21:41
mveRichard Deeming10-Nov-20 21:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.