Error with session, it doesn't work

Javier Benito Santoni

When i was adding the session (this is my first time) I have done something wrong because it doesn't work properly

Here is the code of comprobar_provisional.php

 <?php
session_start()
$user = "Javier";
$password = "HolaJavier";
include 'inc/header.php';
include 'inc/funciones.php';
?>

<?php
$nombre = $_POST["nombre"];
$contraseña = $_POST["pass"];
if ($nombre != $user) {
    echo "El usuario es incorrecto";
}
elseif ($contraseña != $password) {
    echo "La contraseña no es correcta";
} 
else {
$_SESSION['Logueado'] == TRUE;
echo "<center><h1>". $user. ": Bienvenido al Panel de Control</h1></center>";
   echo '<form action="logout.php" method="post">
<input type="submit" value="salir"></form>';
   echo '<center>
<h4>Añadir Imagen</h4><hr>
<form method="POST" action="accion.php">
<div class="form-group">
Nombre: <input type="text" name="titulo"></input>
Link a Imagen: <input type="text" name="link"></input>
<input type="submit" name="enviar" value="Enviar"></input>
</div>
</form>
<center><hr><h3> ID + IMAGEN</h3>';
$x = 1;
      while($x<=36 AND list($circuit_id, $circuit) = each($circuits)){
        echo circuitos($circuit_id, $circuit);}
echo '
<h4>Eliminar Imagen</h4><hr>
<form method="POST" action="accion2.php">
Escribe ID <input type="text" name="id"></input>
<input type="submit" name="enviar2" value="Enviar"></input>';}
?>
<?
include '../inc/footer.php';
?> 

Here is the code of accion.php

 <?php
    session_start();
    if($_SESSION['Logueado'] == TRUE) {
include 'inc/header.php';

$id = $_POST['id'];
$titulo = $_POST['titulo'];
$link = $_POST['link'];
$servername = "localhost";
$username = "ab";
$password = "123456";
$dbname = "ab";
    $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
    // set the PDO error mode to exception
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

    $sql = "INSERT INTO circuito (nombre, image)
    VALUES ('$titulo', '$link')";
    // use exec() because no results are returned
    $conn->exec($sql);
    echo "Nueva imágen añadida correctamete.";
    echo '<br><a href="javascript:history.back()">
    <style type="text/css">   
    a:link   
    {   
    text-decoration:none;
    color:black
    }</style>
               <input type="button" value="Regresar"></input></a>';

$conn = null;

include '../inc/footer.php';
} else {
    echo "You didnt do login";
    }
?> 

When i do this doin login it show:You didnt do login.

jsfan

Your code has the line

$_SESSION['Logueado'] == TRUE;

which is a comparison. What you meant to write is

$_SESSION['Logueado'] = TRUE;

which is an assignment.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Session doesn't work

From Dev

Session doesn't work as expected

From Dev

Laravel Redis Session Driver doesn't work

From Dev

Laravel 5 - session doesn't work

From Dev

PHP Session Variables doesn't work

From Dev

Session Flag doesn't work in Javascript

From Dev

PHP Session Variables doesn't work

From Dev

Session flashdata doesn´t work on form submit

From Dev

php session doesn't work in cli

From Dev

Setting $_SESSION variable but something doesn't work

From Dev

expire in express-session doesn't work

From Dev

Hibernate @BatchSize doesn't work as expected after session.flush

From Dev

ASP.NET MVC Session Timeout doesn't work

From Dev

Session sharing between contexts doesn't work on Tomcat 7

From Dev

use SELECT and SESSION to check login user doesn't work

From Dev

PHP session is either empty or doesn't work correctly

From Dev

WSO2IS: SSO session timeout doesn't work

From Dev

Making subsequent POST request in session doesn't work - web scraping

From Dev

Why does session[:] doesn't work in grape - rails?

From Dev

jQuery REST Session doesn't work, but works in POSTMan

From Dev

Confusing the session codeigniter function, the page logout() function doesn't work

From Dev

PHP Array_merge involving $_SESSION doesn't work

From Dev

Session based login doesn't work on remote server

From Dev

Why doesn't SIGSTOP work inside screen session?

From Dev

SDN 4 Session.query doesn't work for @QueryResult

From Dev

session_destroy() doesn't work with PHP >7.0 on server

From Dev

Parsley custom error message doesn't work

From Dev

Bootstrap - alert-error doesn't work

From Dev

Error with Kendo for ASP MVC doesn't work

Related Related

HotTag

Archive