Dreamweaver - Problema con página login

 
Vista:

Problema con página login

Publicado por cati (1 intervención) el 18/07/2018 15:03:09
Hola:

He hecho una página con Dreamweaver que tiene una zona de acceso privado para que el administrador del sitio pueda añadir contenidos que se ven en la parte pública. La pruebo en local y todo funciona bien. Sin embargo, tras haber pasado todo a MySQLi (y haber comprobado que funciona en local), haber actualizado los datos de las conexiones con la bbdd remota (se conecta bien) y haberla subirla al servidor, me encuentro con un problema. Mi archivo de acceso se llama: MCC_aeb.php.

Aparecen estos 2 mensajes de error que hacen referencia a mi servidor local

Warning: mysqli_query() expects parameter 1 to be mysqli, null given in /homepages/27/d741383808/htdocs/admin/MCC_aeb.php on line 64

Warning: mysqli_error() expects parameter 1 to be mysqli, null given in /homepages/27/d741383808/htdocs/admin/MCC_aeb.php on line 64

¡Pero los archivos están en el servidor remoto!

Pego a continuación el código de conexión a la bbdd (se llama remota.php):

1
2
3
4
5
6
7
8
9
10
11
12
13
<?php
$host_name_remota = 'mihostname';
$database_remota = 'mibbdd';
$user_name_remota = 'miusuario';
$password_remota = 'mipassword';
$connect = mysqli_connect($host_name_remota, $user_name_remota, $password_remota, $database_remota);
 
if (mysqli_connect_errno()) {
    die('<p>Error al conectar con servidor MySQL: '.mysqli_connect_error().'</p>');
} else {
    echo '<p>Se ha establecido la conexión al servidor MySQL con éxito.</p >';
}
?>

Ahora copio el código del archivo en el que está el formulario de acceso:

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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }
 
  if (PHP_VERSION >= 7) {     // SI la versión de PHP es mayor o igual a 7.
    global $remota;        // Hago global la variable 
  }
 
 // global $remota;
//$theValue = function_exists("mysqli_real_escape_string") ? mysqli_real_escape_string($remota, $theValue) : mysqli_escape_string($remota,$theValue);
  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}
?>
<?php
// *** Validate request to login to this site.
if (!isset($_SESSION)) {
  session_start();
}
 
$loginFormAction = $_SERVER['PHP_SELF'];
if (isset($_GET['accesscheck'])) {
  $_SESSION['PrevUrl'] = $_GET['accesscheck'];
}
 
if (isset($_POST['mail'])) {
  $loginUsername=$_POST['mail'];
  $password=$_POST['csign'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "edicion.php";
  $MM_redirectLoginFailed = "MCC_error.php";
  $MM_redirecttoReferrer = false;
 
 
  $LoginRS__query=sprintf("SELECT u_email, u_password FROM usuarios WHERE u_email=%s AND u_password=%s",
    GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
 
  $LoginRS = mysqli_query($remota, $LoginRS__query) or die(mysqli_error($remota));
  $loginFoundUser = mysqli_num_rows($LoginRS);
  if ($loginFoundUser) {
     $loginStrGroup = "";
 
	if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
    //declare two session variables and assign them
    $_SESSION['MM_Username'] = $loginUsername;
    $_SESSION['MM_UserGroup'] = $loginStrGroup;
 
    if (isset($_SESSION['PrevUrl']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
<?php require_once('../Connections/remota.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 
<title>MCC_aeb</title>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
<style type="text/css">
@import url("../estilos/MCC_desktop_02.css")screen and (min-width:1024px);
 
@import url("../estilos/MCC_tablet_02.css")screen and (min-width:768px) and (max-width:1023px);
 
 
@import url("../estilos/MCC_movil_02.css")screen and
(max-width:767px);
 
 
.centrado-porcentual {
    position: absolute;
    left: 50%;
    top: 50%;
	width:400px;
	height:auto;
    transform: translate(-50%, -50%);
    -webkit-transform: translate(-50%, -50%);
}
.centrado-porcentual img{
	padding-left:25px;
	padding-bottom:50px;
}
table{
	margin-top: 50px 0;
	widith:400px;
}
td{
	padding:20px 10px;
}
input{
	font-size:1.1em;
}
.espaciar_btn{
	margin: 0 20px;
}
</style>
</head>
<body>
	<div class="centrado-porcentual">
	<img src="../imgs/Logo_MCC_RGB.jpg"  alt="Logo" style="margin:0 auto ;" />
		<div style="padding:20px; margin-top:30px auto; border:#9CB65F dotted 1px; text-align:center;">
		<form id="Acceso" name="Acceso" method="POST" action="<?php echo $loginFormAction; ?>">
 
		<table width="400" border="0" cellspacing="0" cellpadding="6">
	<tr>
		<td width="133" align="right" valign="top">Correo electrónico</td>
		<td width="243" align="left" valign="top">
			<label for="mail"></label>
			<input name="mail" type="text" id="mail" size="20" />
		</td>
	</tr>
	<tr>
		<td align="right" valign="top">Contraseña</td>
		<td align="left" valign="top">
			<label for="csign"></label>
			<input name="csign" type="password" id="csign" size="15" />
		</td>
	</tr>
	<tr>
		<td colspan="2" align="center" valign="top">
		<input name="Acceder" type="submit" value="Acceder" class="espaciar_btn" />  <input name="Restablecer" type="reset" value="Restablecer" class="espaciar_btn"/>
		</td>
		</tr>
</table>
</form>
		</div>
</div>
</body>
 
</html>
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