php session on refresh page or on button submit -


my site url this: http://localhost/record/index.php when add,update,delete record table url this: http://localhost/record/index.php?delmsg=users%20has%20been%20deleted how can remove php variable on refresh page or button submit using session

you right trying remove message handling variables, using sessions lot better , let control logic not safe users pointed.

use session_start(); in beginning of every php file want handle session values.

to set value want read later:

if (isset($_get['del'])) {     $del_id = intval($_get['del']); // intval improve security     if (mysqli_query($sql,"delete user id = ".$del_id.";")) {         $_session["delmsg"] = "user id = " . $del_id . " has been deleted";         header('location: index.php');     } } 

to read value in further request , show contents accordingly:

if (isset($_session["delmsg"])) {     echo "<div class='message'>".$_session["delmsg"]."</div>";     // clean session variable value if don't need anymore     unset($_session["result"]); } 

this code understand session variables, there still security flaws in code, don't go live it. first, learn sql injection: http://php.net/manual/en/security.database.sql-injection.php , pdo: http://php.net/manual/en/book.pdo.php

hope helps.


read more $_session array: http://php.net/manual/en/reserved.variables.session.php


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -