Expiry System Php

问题内容:

We’re having problem in our system. I dont know how and where to start to put the code in the system. The process is after the seller register his/her account it will start to count 30 days, and after 30 days there will be a pop out notification in the seller account telling that is already expired. I’ve also try to search tutorial over the internet but it just confuses me. Hoping to help and get rid of it. Thank you 🙂 Btw, mysqli please.

This is the code of the seller checking if the user is valid:

   <?php
session_start();

?>
<?php
include("db_connection.php");

$s_username = $_POST['s_username'];
$s_password= sha1($_POST['s_password']);

//check user if exist
$check_query = mysqli_query($db, "SELECT * FROM seller WHERE s_username = '$s_username' AND s_password = '$s_password'");
$count = mysqli_num_rows($check_query);

if($count == 1)
{
    session_start();
    while($result = mysqli_fetch_array($check_query))
    {
        $_SESSION['seller_id'] = $result['seller_id'];
        $_SESSION['s_fname'] = $result['s_fname'];
        $_SESSION['s_username'] = $result['s_username'];
        $_SESSION['s_user_type'] = $result['s_user_type'];
        $_SESSION['s_status'] = $result['s_status'];
    }

    header('location: Seller/seller_home.php');
}else if($count>1){
    echo "Error logging in...<br>Please contact administrator";
}else{
    header('location: index.php');
}
?>

** Where should i begin to put the code expiration? *

问题评论:

    
is the a column in the customer table that stores the datetime when the account is created?
    
@RamRaider sir sorry i inputted a wrong code it should be seller not customer but i’ve already edited the code and regarding to your question there is already a column name “date_joined” in the database but not yet in the code
– cylopes101
52 mins ago
1  
Please read up on SQL Injection (websitebeaver.com/…). Your website can be hacked in seconds.
    
Too few information. But in a nutshell, add a created_at field at the seller’s table with as default value the current timestamp. Then just retrieve it and test for 30 days. Also sha1 is too weak to store passwords, please have a look at password_hash

原文地址:

https://stackoverflow.com/questions/47755708/expiry-system-php

Add a Comment