Bases de Datos - NO SE GUARDAN LOS REGISTROS EN LA BASE DE DATOS DE MYSQL

 
Vista:
sin imagen de perfil

NO SE GUARDAN LOS REGISTROS EN LA BASE DE DATOS DE MYSQL

Publicado por john (1 intervención) el 26/06/2021 08:56:58
Hola como van?

Mi problema es el siguiente:

Tengo un base de datos en mysql la probe y funciona perfectamente en XAMMP (LOCAL) pero cuando subo el sitio a un servidor externo vps(CENTOS 8), luego registro un nuevo usuario, consulto con PHPMYADMIN y los datos no se guardan en la base de datos del servidor externo, verifique el archivo config.php (que este caso es el que proporciona la conexion) el formulario de registro (que es el mismo que tengo en sitio local ) todo parece estar correcto incluso cuando se registrar un usuario se autentica sin problemas pero solo temporalmente porque no guarda los registros de ese usuario.

espero haber explicado con claridad, muchas gracias!



CODIGO DEL ARCHIVO config.php (El mismo utilizado en el servidor LOCAL)
==============================================================
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
session_start();
 
// initializing variables
 
$username = "";
$name = "";
$lastname = "";
$email = "";
$phone = "";
$platform = "";
$account = "";
$country = "";
$errors = array();
 
// connect to the database
$db = mysqli_connect('localhost', 'db_user', '', 'registration',);
 
// REGISTER USER
if (isset($_POST['reg_user'])) {
  // receive all input values from the form
  $username = mysqli_real_escape_string($db, $_POST['username']);
  $name = mysqli_real_escape_string($db, $_POST['name']);
  $lastname = mysqli_real_escape_string($db, $_POST['lastname']);
  $email = mysqli_real_escape_string($db, $_POST['email']);
  $password_1 = mysqli_real_escape_string($db, $_POST['password_1']);
  $password_2 = mysqli_real_escape_string($db, $_POST['password_2']);
  $phone = mysqli_real_escape_string($db, $_POST['phone']);
  $platform = mysqli_real_escape_string($db, $_POST['platform']);
  $account = mysqli_real_escape_string($db, $_POST['account']);
  $country = mysqli_real_escape_string($db, $_POST['country']);
 
  // form validation: ensure that the form is correctly filled ...
  // by adding (array_push()) corresponding error unto $errors array
  if (empty($username)) { array_push($errors, "Username is required"); }
  if (empty($email)) { array_push($errors, "Email is required"); }
  if (empty($password_1)) { array_push($errors, "Password is required"); }
  if ($password_1 != $password_2) {
	array_push($errors, "The two passwords do not match");
  }
 
  // first check the database to make sure
  // a user does not already exist with the same username and/or email
  $user_check_query = "SELECT * FROM users WHERE username='$username' OR email='$email' LIMIT 1";
  $result = mysqli_query($db, $user_check_query);
  $user = mysqli_fetch_assoc($result);
 
  if ($user) { // if user exists
    if ($user['username'] === $username) {
      array_push($errors, "Username already exists");
    }
 
    if ($user['email'] === $email) {
      array_push($errors, "email already exists");
    }
  }
 
  // Finally, register user if there are no errors in the form
  if (count($errors) == 0) {
  	$password = md5($password_1);//encrypt the password before saving in the database
 
  	$query = "INSERT INTO users (username, name, lastname, email, password, phone, platform, account, country)
  			  VALUES('$username', '$name', '$lastname', '$email', '$password', '$phone', '$platform', '$account', '$country')";
  	mysqli_query($db, $query);
  	$_SESSION['username'] = $username;
  	$_SESSION['success'] = "You are now logged in";
  	header('location: index.php');


CODIGO DEL FORMUARIO DE REGISTRO UTILIZADO
-------------------------------------------------------------------------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php include('config.php') ?>
<!DOCTYPE html>
<html>
<head>
  <title>Registro de Usuario</title>
  <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
  <div class="header">
  	<h2>Registro de usuario</h2>
  </div>
 
<form method="post" action="signup.php">
  	<?php include('errors.php'); ?>
  	<div class="input-group">
  	  <label>Usuario</label>
  	  <input type="text" name="username" value="<?php echo $username; ?>">
  	</div>
 
<div class="input-group">
  	  <label>Nombre</label>
  	  <input type="text" name="name" value="">
  	</div>
 
<div class="input-group">
  	  <label>Apellido</label>
  	  <input type="text" name="lastname" value="">
  	</div>
 
<div class="input-group">
  	  <label>Email</label>
  	  <input type="email" name="email" value="<?php echo $email; ?>">
  	</div>
 
<div class="input-group">
  	  <label>Contraseña</label>
  	  <input type="password" name="password_1">
 
<div class="input-group">
  	  <label>Repetir Contraseña</label>
  	  <input type="password" name="password_2">
 
<div class="input-group">
  	  <label>Telefono</label>
  	  <input type="tel" name="phone" value="">
  	</div>
 
<div class="input-group">
  	  <label>Plataforma</label>
  	  <input type="text" name="platform" value="">
  	</div>
 
<div class="input-group">
  	  <label>Tipo de Cuenta</label>
  	  <input type="text" name="account" value="">
  	</div>
 
<div class="input-group">
  	  <label>Pais de Residencia</label>
  	  <input type="text" name="country" value="">
 
  	</div>
  	<div class="input-group">
  	  <button type="submit" class="btn" name="reg_user">Registrar Cuenta</button>
  	</div>
  	<p>
  		Ya tienes una cuenta? <a href="login.php">Iniciar Sesion</a>
  	</p>
  </form>
</body>
</html>

SERVIDOR LOCAL phpmyadmin info WIN10 (XAMMP)
----------------------------------------------------------------
Database server
Server: 127.0.0.1 via TCP/IP
Server type: MySQL
Server connection: SSL is not being used Documentation
Server version: 8.0.21 - MySQL Community Server - GPL
Protocol version: 10
User: root@localhost
Server charset: UTF-8 Unicode (utf8mb4)
Web server
Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/7.3.27
Database client version: libmysql - mysqlnd 5.0.12-dev - 20150407 - $Id: 7cc7cc96e675f6d72e5cf0f267f48e167c2abb23 $
PHP extension: mysqli Documentation curl Documentation mbstring Documentation
PHP version: 7.3.27

SERVIDOR EXTERNO (VPS) phpmyadmin info(LINUX CENTOS 8)
----------------------------------------------------------------------------------------------
Database server
Server: Localhost via UNIX socket
Server type: MySQL
Server connection: SSL is not being used Documentation
Server version: 8.0.21 - Source distribution
Protocol version: 10
User: root@localhost
Server charset: UTF-8 Unicode (utf8mb4)
Web server
Apache/2.4.37 (centos)
Database client version: libmysql - mysqlnd 7.4.20
PHP extension: mysqli Documentation curl Documentation mbstring Documentation
PHP version: 7.4.20
phpMyAdmin
Version information: 5.1.0, latest stable version: 5.1.1
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder