¿Dónde debería poner un if para que me redirigiera a una u otra?
Os pongo mi index.php y mi check-login.php
Mi index.php
Código
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="description" content=""> <meta name="author" content=""> <title>Diafebus</title> <!-- Bootstrap core CSS --> <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <!-- Custom fonts for this template --> <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css"> <link href='https://fonts.googleapis.com/css?family=Kaushan+Script' rel='stylesheet' type='text/css'> <link href='https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic,700italic' rel='stylesheet' type='text/css'> <link href='https://fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700' rel='stylesheet' type='text/css'> <!-- Custom styles for this template --> <link href="css/agency.min.css" rel="stylesheet"> </head> <body id="page-top"> <!-- Navigation --> <nav class="navbar navbar-expand-lg navbar-dark fixed-top" id="mainNav"> <div class="container"> <a class="navbar-brand js-scroll-trigger" href="#page-top">Diafebus</a> <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation"> Menu <i class="fas fa-bars"></i> </button> <div class="collapse navbar-collapse" id="navbarResponsive"> <ul class="navbar-nav text-uppercase ml-auto"> <li class="nav-item"> <a class="nav-link js-scroll-trigger" href="#services">Servicios</a> </li> <li class="nav-item"> <a class="nav-link js-scroll-trigger" href="#portfolio">Portfolio</a> </li> <li class="nav-item"> <a class="nav-link js-scroll-trigger" href="#about">Sobre Nosotros</a> </li> <li class="nav-item"> <a class="nav-link js-scroll-trigger" href="#team">Equipo</a> </li> <li class="nav-item"> <a class="nav-link js-scroll-trigger" href="#contact">Contacta con Nosotros</a> </li> </ul> </div> </div> </nav> <header class="masthead"> <div class="container"> <div class="intro-text"> <div class="intro-lead-in">Bienvenid@s a Dik</div> <div class="intro-heading text-uppercase">Consult </div> <a class="btn btn-primary btn-xl text-uppercase js-scroll-trigger" href="#services">Mira más</a> </div> </div> </header> <!-- Services --> <section class="page-section" id="services"> <div class="container"> <div class="row"> <div class="col-lg-12 text-center"> <h2 class="section-heading text-uppercase">Accede a tu cuenta</h2> <h3 class="section-subheading text-muted">Estaremos encantados de ayudarte.</h3> </div> </div> <div class="CENTER-BLOCK"> <div class="card"> <div class="loginBox"> <img src="images/php-mysql-logo.png" class="img-responsive" alt="PHP MySQL logos"> <h2>Login</h2> <form action="check-login.php" method="post"> <div class="form-group"> <input type="email" class="form-control input-lg" name="email" placeholder="Email" required> </div> <div class="form-group"> <input type="password" class="form-control input-lg" name="password" placeholder="Password" required> </div> <button type="submit" class="btn btn-success btn-block">Login</button> </form> <!-- Collapse a form when user click Lost your password? link--> <p><a href="#showForm" data-toggle="collapse" aria-expanded="false" aria-controls="collapse">Lost your password?</a></p> <div class="collapse" id="showForm"> <div class='well'> <form action="password-recovery.php" method="post"> <div class="form-group"> <input type="email" class="form-control" name="email" placeholder="Enter the email associated with the password." required> </div> <button type="submit" class="btn btn-dark">Recover Password</button> </form> </div> </div> <hr><p>New to PHP Login? <a href="index.php" title="Create an account">Create an account</a>.</p> </div><!-- /.loginBox --> </div><!-- /.card --> </div> </div> </section> <!-- Portfolio Grid --> <section class="bg-light page-section" id="portfolio"> <div class="container"> <div class="row"> <div class="col-lg-12 text-center"> <h2 class="section-heading text-uppercase">Portfolio</h2> <h3 class="section-subheading text-muted">Lorem ipsum dolor sit amet consectetur.</h3> </div> </div> <div class="row"> <div class="col-md-4 col-sm-6 portfolio-item"> <a class="portfolio-link" data-toggle="modal" href="#portfolioModal1"> <div class="portfolio-hover"> <div class="portfolio-hover-content"> <i class="fas fa-plus fa-3x"></i> </div> </div> <img class="img-fluid" src="img/portfolio/01-thumbnail.jpg" alt=""> </a> <div class="portfolio-caption"> <h4>Threads</h4> <p class="text-muted">Illustration</p> </div> </div> <div class="col-md-4 col-sm-6 portfolio-item"> <a class="portfolio-link" data-toggle="modal" href="#portfolioModal2"> <div class="portfolio-hover"> <div class="portfolio-hover-content"> <i class="fas fa-plus fa-3x"></i> </div> </div> <img class="img-fluid" src="img/portfolio/02-thumbnail.jpg" alt=""> </a> </div> <div class="container"> <div class="row"> <div class="col-sm-12"> <h1>Login</h1> <p>Venga resgístrate.</p> </div> </div> <div class="row"> <div class="col-sm-12 col-md-6 col-lg-6"> <h3>Crea una Cuenta</h3><hr /> <form method="post" action="create-account.php" method="POST"> <div class="form-group"> <input type="text" class="form-control" name="name" placeholder="Escribe tu nombre" required> </div> <div class="form-group"> <input type="email" class="form-control" name="email" aria-describedby="emailHelp" placeholder="Escribe tu email" required> </div> <div class="form-group"> <input type="password" class="form-control" name="password" placeholder="Crea un Password" required> </div> <button type="submit" class="btn btn-success btn-block">Crea mi cuenta</button> </form> </div> <div class="col-sm-12 col-md-6 col-lg-6"> <h3>Login</h3><hr /> <p>Ya tienes una cuenta? <a href="login.php" title="Login Here">Login here!</a></p> </div> </div> </div> </section> <!-- About --> <section class="page-section" id="about"> <div class="container"> <div class="row"> <div class="col-lg-12 text-center"> <h2 class="section-heading text-uppercase">About</h2> <h3 class="section-subheading text-muted">Lorem ipsum dolor sit amet consectetur.</h3> </div> </div> <div class="row"> <div class="col-lg-12"> <ul class="timeline"> <li> <div class="timeline-image"> <img class="rounded-circle img-fluid" src="img/about/1.jpg" alt=""> </div> <div class="timeline-panel"> <div class="timeline-heading"> <h4>2009-2011</h4> <h4 class="subheading">Our Humble Beginnings</h4> </div> <div class="timeline-body"> <p class="text-muted">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt ut voluptatum eius sapiente, totam reiciendis temporibus qui quibusdam, recusandae sit vero unde, sed, incidunt et ea quo dolore laudantium consectetur!</p> </div> </div> </li> <li class="timeline-inverted"> <div class="timeline-image"> <img class="rounded-circle img-fluid" src="img/about/2.jpg" alt=""> </div> <div class="timeline-panel"> <div class="timeline-heading"> <h4>March 2011</h4> <h4 class="subheading">An Agency is Born</h4> </div> <div class="timeline-body"> <p class="text-muted">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt ut voluptatum eius sapiente, totam reiciendis temporibus qui quibusdam, recusandae sit vero unde, sed, incidunt et ea quo dolore laudantium consectetur!</p> </div> </div> </li> <li> <div class="timeline-image"> <img class="rounded-circle img-fluid" src="img/about/3.jpg" alt=""> </div> <div class="timeline-panel"> <div class="timeline-heading"> <h4>December 2012</h4> <h4 class="subheading">Transition to Full Service</h4> </div> <div class="timeline-body"> <p class="text-muted">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt ut voluptatum eius sapiente, totam reiciendis temporibus qui quibusdam, recusandae sit vero unde, sed, incidunt et ea quo dolore laudantium consectetur!</p> </div> </div> </li> <li class="timeline-inverted"> <div class="timeline-image"> <img class="rounded-circle img-fluid" src="img/about/4.jpg" alt=""> </div> <div class="timeline-panel"> <div class="timeline-heading"> <h4>July 2014</h4> <h4 class="subheading">Phase Two Expansion</h4> </div> <div class="timeline-body"> <p class="text-muted">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt ut voluptatum eius sapiente, totam reiciendis temporibus qui quibusdam, recusandae sit vero unde, sed, incidunt et ea quo dolore laudantium consectetur!</p> </div> </div> </li> <li class="timeline-inverted"> <div class="timeline-image"> <h4>Be Part <br>Of Our <br>Story!</h4> </div> </li> </ul> </div> </div> </div> </section> <!-- Team --> <section class="bg-light page-section" id="team"> <div class="container"> <div class="row"> <div class="col-lg-12 text-center"> <h2 class="section-heading text-uppercase">Our Amazing Team</h2> <h3 class="section-subheading text-muted">Lorem ipsum dolor sit amet consectetur.</h3> </div> </div> <div class="row"> <div class="col-sm-4"> <div class="team-member"> <img class="mx-auto rounded-circle" src="img/team/1.jpg" alt=""> <h4>Kay Garland</h4> <p class="text-muted">Lead Designer</p> <ul class="list-inline social-buttons"> <li class="list-inline-item"> <a href="#"> <i class="fab fa-twitter"></i> </a> </li> <li class="list-inline-item"> <a href="#"> <i class="fab fa-facebook-f"></i> </a> </li> <li class="list-inline-item"> <a href="#"> <i class="fab fa-linkedin-in"></i> </a> </li> </ul> </div> </div> <div class="col-sm-4"> <div class="team-member"> <img class="mx-auto rounded-circle" src="img/team/2.jpg" alt=""> <h4>Larry Parker</h4> <p class="text-muted">Lead Marketer</p> <ul class="list-inline social-buttons"> <li class="list-inline-item"> <a href="#"> <i class="fab fa-twitter"></i> </a> </li> <li class="list-inline-item"> <a href="#"> <i class="fab fa-facebook-f"></i> </a> </li> <li class="list-inline-item"> <a href="#"> <i class="fab fa-linkedin-in"></i> </a> </li> </ul> </div> </div> <div class="col-sm-4"> <div class="team-member"> <img class="mx-auto rounded-circle" src="img/team/3.jpg" alt=""> <h4>Diana Pertersen</h4> <p class="text-muted">Lead Developer</p> <ul class="list-inline social-buttons"> <li class="list-inline-item"> <a href="#"> <i class="fab fa-twitter"></i> </a> </li> <li class="list-inline-item"> <a href="#"> <i class="fab fa-facebook-f"></i> </a> </li> <li class="list-inline-item"> <a href="#"> <i class="fab fa-linkedin-in"></i> </a> </li> </ul> </div> </div> </div> <div class="row"> <div class="col-lg-8 mx-auto text-center"> <p class="large text-muted">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aut eaque, laboriosam veritatis, quos non quis ad perspiciatis, totam corporis ea, alias ut unde.</p> </div> </div> </div> </section> <!-- Clients --> <section class="py-5"> <div class="container"> <div class="row"> <div class="col-md-3 col-sm-6"> <a href="#"> <img class="img-fluid d-block mx-auto" src="img/logos/envato.jpg" alt=""> </a> </div> <div class="col-md-3 col-sm-6"> <a href="#"> <img class="img-fluid d-block mx-auto" src="img/logos/designmodo.jpg" alt=""> </a> </div> <div class="col-md-3 col-sm-6"> <a href="#"> <img class="img-fluid d-block mx-auto" src="img/logos/themeforest.jpg" alt=""> </a> </div> <div class="col-md-3 col-sm-6"> <a href="#"> <img class="img-fluid d-block mx-auto" src="img/logos/creative-market.jpg" alt=""> </a> </div> </div> </div> </section> <!-- Contact --> <section class="page-section" id="contact"> <div class="container"> <div class="row"> <div class="col-lg-12 text-center"> <h2 class="section-heading text-uppercase">Contact Us</h2> <h3 class="section-subheading text-muted">Lorem ipsum dolor sit amet consectetur.</h3> </div> </div> <div class="row"> <div class="col-lg-12"> <form id="contactForm" name="sentMessage" novalidate="novalidate"> <div class="row"> <div class="col-md-6"> <div class="form-group"> <input class="form-control" id="name" type="text" placeholder="Your Name *" required="required" data-validation-required-message="Please enter your name."> <p class="help-block text-danger"></p> </div> <div class="form-group"> <input class="form-control" id="email" type="email" placeholder="Your Email *" required="required" data-validation-required-message="Please enter your email address."> <p class="help-block text-danger"></p> </div> <div class="form-group"> <input class="form-control" id="phone" type="tel" placeholder="Your Phone *" required="required" data-validation-required-message="Please enter your phone number."> <p class="help-block text-danger"></p> </div> </div> <div class="col-md-6"> <div class="form-group"> <textarea class="form-control" id="message" placeholder="Your Message *" required="required" data-validation-required-message="Please enter a message."></textarea> <p class="help-block text-danger"></p> </div> </div> <div class="clearfix"></div> <div class="col-lg-12 text-center"> <div id="success"></div> <button id="sendMessageButton" class="btn btn-primary btn-xl text-uppercase" type="submit">Send Message</button> </div> </div> </form> </div> </div> </div> </section> <!-- Footer --> <footer class="footer"> <div class="container"> <div class="row"> <div class="col-md-4"> <span class="copyright">Copyright © Your Website 2019</span> </div> <div class="col-md-4"> <ul class="list-inline social-buttons"> <li class="list-inline-item"> <a href="#"> <i class="fab fa-twitter"></i> </a> </li> <li class="list-inline-item"> <a href="#"> <i class="fab fa-facebook-f"></i> </a> </li> <li class="list-inline-item"> <a href="#"> <i class="fab fa-linkedin-in"></i> </a> </li> </ul> </div> <div class="col-md-4"> <ul class="list-inline quicklinks"> <li class="list-inline-item"> <a href="#">Privacy Policy</a> </li> <li class="list-inline-item"> <a href="#">Terms of Use</a> </li> </ul> </div> </div> </div> </footer> <!-- Portfolio Modals --> <!-- Modal 1 --> <div class="portfolio-modal modal fade" id="portfolioModal1" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="close-modal" data-dismiss="modal"> <div class="lr"> <div class="rl"></div> </div> </div> <div class="container"> <div class="row"> <div class="col-lg-8 mx-auto"> <div class="modal-body"> <!-- Project Details Go Here --> <h2 class="text-uppercase">Project Name</h2> <p class="item-intro text-muted">Lorem ipsum dolor sit amet consectetur.</p> <img class="img-fluid d-block mx-auto" src="img/portfolio/01-full.jpg" alt=""> <p>Use this area to describe your project. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Est blanditiis dolorem culpa incidunt minus dignissimos deserunt repellat aperiam quasi sunt officia expedita beatae cupiditate, maiores repudiandae, nostrum, reiciendis facere nemo!</p> <ul class="list-inline"> <li>Date: January 2017</li> <li>Client: Threads</li> <li>Category: Illustration</li> </ul> <button class="btn btn-primary" data-dismiss="modal" type="button"> <i class="fas fa-times"></i> Close Project</button> </div> </div> </div> </div> </div> </div> </div> <!-- Bootstrap core javascript --> <script src="vendor/jquery/jquery.min.js"></script> <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script> <!-- Plugin javascript --> <script src="vendor/jquery-easing/jquery.easing.min.js"></script> <!-- Contact form javascript --> <script src="js/jqBootstrapValidation.js"></script> <script src="js/contact_me.js"></script> <!-- Custom scripts for this template --> <script src="js/agency.min.js"></script> </body> </html>
check-ligin.php
Código
<?php ?> <!DOCTYPE html> <html lang="en"> <meta charset="utf-8"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="description" content=""> <meta name="author" content=""> <title>Diafebus</title> <!-- Bootstrap core CSS --> <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <!-- Custom fonts for this template --> <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css"> <link href='https://fonts.googleapis.com/css?family=Kaushan+Script' rel='stylesheet' type='text/css'> <link href='https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic,700italic' rel='stylesheet' type='text/css'> <link href='https://fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700' rel='stylesheet' type='text/css'> <!-- Custom styles for this template --> <link href="css/agency.min.css" rel="stylesheet"> </head> <body id="page-top"> <!-- Navigation --> <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top"> <div class="container"> <a class="navbar-brand" href="index.php"> <img src="images/imagen.jpg" width="150" height="60" alt=""> </a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="navbarResponsive"> <ul class="navbar-nav ml-auto"> <li class="nav-item active"> <a class="nav-link" href="#">Home <span class="sr-only">(current)</span> </a> </li> <li class="nav-item"> <a class="nav-link" href="logout.php">Desconectarse</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Services</a> </li> <li class="nav-item"> <a class="nav-link" href="#">Contact</a> </li> </ul> </div> </div> </nav> <!-- Page Content --> <section class="bg-light page-section" id="team"> <div class="container"> <div class="container text-center"> <?php // Connection info. file include 'conn.php'; // Connection variables // Check connection if (!$conn) { } // data sent from form login.html $email = $_POST['email']; $password = $_POST['password']; // Query sent to database // Variable $row hold the result of the query // Variable $hash hold the password hash on database $hash = $row['password']; /* password_Verify() function verify if the password entered by the user match the password hash on the database. If everything is OK the session is created for one minute. Change 1 on $_SESSION[start] to 5 for a 5 minutes session. */ if (password_verify($_POST['password'], $hash)) { $_SESSION['loggedin'] = true; $_SESSION['name'] = $row['name']; $_SESSION['email'] = $row['email']; $_SESSION['expire'] = $_SESSION['start'] + ( 60* 60) ; echo "<div><strong>Welcome!</strong> $row[name] <p><a class='btn btn-primary active btn-lg' href='ingresos.php' role='button' style='width:250px; height:100px; margin: 10px'>Insertar Ingresos</a> } else { echo "<div class='alert alert-danger mt-4' role='alert'>Email or Password are incorrects! <p><a href='login.php'><strong>Please try again!</strong></a></p></div>"; } ?> </div> <div> <p>Welcome: <?php echo $_SESSION['email']; ?></p> </div> </div> </div> </div> </section> <footer class="footer"> <div class="container"> <div class="row"> <div class="col-md-4"> <span class="copyright">Copyright © Your Website 2019</span> </div> <div class="col-md-4"> <ul class="list-inline social-buttons"> <li class="list-inline-item"> <a href="#"> <i class="fab fa-twitter"></i> </a> </li> <li class="list-inline-item"> <a href="#"> <i class="fab fa-facebook-f"></i> </a> </li> <li class="list-inline-item"> <a href="#"> <i class="fab fa-linkedin-in"></i> </a> </li> </ul> </div> <div class="col-md-4"> <ul class="list-inline quicklinks"> <li class="list-inline-item"> <a href="#">Privacy Policy</a> </li> <li class="list-inline-item"> <a href="#">Terms of Use</a> </li> </ul> </div> </div> </div> </footer> <!-- Bootstrap core javascript --> <script src="vendor/jquery/jquery.min.js"></script> <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script> <!-- Plugin javascript --> <script src="vendor/jquery-easing/jquery.easing.min.js"></script> <!-- Contact form javascript --> <script src="js/jqBootstrapValidation.js"></script> <script src="js/contact_me.js"></script> <!-- Custom scripts for this template --> <script src="js/agency.min.js"></script> </body> </html>