Home > Net >  PRESTASHOP - Link to redirect after login
PRESTASHOP - Link to redirect after login

Time:05-17

hello

I need to make a link that sends to the login page. As soon as the person has logged in, he/she should be redirected to another page (of his/her account for example).

I was using this link before: https://arnauddevilleneuve.shop/connexion?back=https://arnauddevilleneuve.shop/fr/module/allinone_rewards/sponsorship but it doesn't work anymore.

Did you have any ideas ? Thanks in advance, if you need more precision, ask me !

CodePudding user response:

I don't know any prestashop but here's a normal PHP code solution.

Login page: <button type="submit" >Login</button>

PHP file:

<?php
session_start();
if(!isset($_POST['email'])){
    header('Location:../index.php');
}
$e=$_POST['email'];
$p=$_POST['pass'];

include('dbdata.php');

$con=new mysqli($dbservername,$dbusername,$dbpassword,$dbname);

$sql="SELECT * FROM users WHERE email='$e' AND password='$p'";

$result=$con->query($sql);
if($result->num_rows>0){
    $con->close();
    $_SESSION['user']=$e;
    header('Location:../home.php');
}else{
    header("Location:../index.php?invalid");
}
$con->close();
?>

in here home.php is the page user is redirected to after login. index.php is the login page. Hope this works

CodePudding user response:

So i found a solution using the back= parameter :

{if $logged}
  <script type="text/javascript">
      $('#reduclink').on('click', function(ev){
        window.open("https://arnauddevilleneuve.shop/connexion?back=https://arnauddevilleneuve.shop/fr/reduction","Reductions", "width=1000, height=700"); 
    });
  </script>

  {else}
    <script type="text/javascript">
      $('#reduclink').on('click', function(ev){ 
        window.open("https://arnauddevilleneuve.shop/fr/reduction","Reductions", "width=1000, height=700"); 
    });
  </script>
{/if}
      <p  id="reduclink" style="padding-left: 1.25rem;
    display: inline-block; color: black; cursor:pointer">Voir les réductions disponibles</p>

{if $logged} allows to know if the client is connected and to redirect on a link according to yes or no.

  • Related