logo
down
shadow

PHP session if !isset {} else die()


PHP session if !isset {} else die()

By : andrewr
Date : November 15 2020, 06:54 AM
fixed the issue. Will look into that further @Rizier123 right, but one comment - HTTP/1.1 requires an absolute URI as argument to » Location: including the scheme, hostname and absolute path, but some clients accept relative URIs.
code :
<?php require('dbcon.php');?>
<?php
/* Redirect to a different page in the current directory that was requested */
if (!isset($_SESSION['adminauth'])) {
    $host  = $_SERVER['HTTP_HOST'];
    $uri   = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
    $extra = 'login.php';
    header("Location: http://$host$uri/$extra");
    die();
}
?>


Share : facebook icon twitter icon
Checking if session id ISSET in PDO

Checking if session id ISSET in PDO


By : onlinedreamer
Date : March 29 2020, 07:55 AM
like below fixes the issue The call to $stmt->fetch() is failing because at this point, $stmt still refers to the SQL INSERT from which you cannot fetch rows.
So what you need to do is execute a SELECT statement to retrieve the newly entered user details and fetch() from that instead. Assuming you have an auto-increment column in the customer_info table, use PDO::lastInsertId() to get the new row's id and use it in your SELECT query.
code :
$user_name = $_POST['user_name'];
$password = $_POST['password'];  
$hashedPassword = sha1($salt . $password); 
$stmt = $conn->prepare('INSERT INTO customer_info (...) VALUES(...)');
$stmt->bindParam(':user_id', $user_id); 
...  
$insertResult = $stmt->execute();  
if ($insertResult && $stmt->rowCount() == 1) {
  // Ok, the INSERT was successful, so now SELECT the row back
  // Use lastInsertId() to get the new row's id
  // Assuming the id column is `user_id`...
  $stmt_user = $conn->prepare("SELECT * FROM customer_info WHERE user_id = :user_id");
  $stmt_user->bindValue(":user_id", $conn->lastInsertId());
  $stmt_user->execute();

  session_regenerate_id();
  // Fetch from the SELECT query
  $member = $stmt_user->fetch();
  $_SESSION['SESS_USER_ID'] = $member['user_id'];   
}
dynamically name session isset how to use?

dynamically name session isset how to use?


By : Liat
Date : March 29 2020, 07:55 AM
Any of those help i found problem we can not use numeric index for $_SESSION
but we can use number in $_SESSION by convert number to roman numerals
code :
https://example.com/test.php?id=1548393
<?php 
session_start();

$roman_id = romanic_number($_GET['id']);
$_SESSION[$roman_id] = "mysecretstringline";


        function romanic_number($integer, $upcase = true) 
        { 
            $table = array('M'=>1000, 'CM'=>900, 'D'=>500, 'CD'=>400, 'C'=>100, 'XC'=>90, 'L'=>50, 'XL'=>40, 'X'=>10, 'IX'=>9, 'V'=>5, 'IV'=>4, 'I'=>1); 
            $return = ''; 
            while($integer > 0) 
            { 
                foreach($table as $rom=>$arb) 
                { 
                    if($integer >= $arb) 
                    { 
                        $integer -= $arb; 
                        $return .= $rom; 
                        break; 
                    } 
                } 
            } 

            return $return; 
        } 

?>
https://example.com/test2.php?id=1548393
<?php 
session_start();

$roman_id = romanic_number($_GET['id']);

if(isset($_SESSION[$roman_id])){
 echo "working";
}else{
 echo "not working";
}


            function romanic_number($integer, $upcase = true) 
            { 
                $table = array('M'=>1000, 'CM'=>900, 'D'=>500, 'CD'=>400, 'C'=>100, 'XC'=>90, 'L'=>50, 'XL'=>40, 'X'=>10, 'IX'=>9, 'V'=>5, 'IV'=>4, 'I'=>1); 
                $return = ''; 
                while($integer > 0) 
                { 
                    foreach($table as $rom=>$arb) 
                    { 
                        if($integer >= $arb) 
                        { 
                            $integer -= $arb; 
                            $return .= $rom; 
                            break; 
                        } 
                    } 
                } 

                return $return; 
            } 

    ?>
working
if isset SESSION display div

if isset SESSION display div


By : user3848158
Date : October 26 2020, 11:52 AM
This might help you How do i do in jquery, to check if there's anything in isset SESSION user_message, each 1 seconds, and if there is then display #box else dont.. thanks , PHP file (session.php):
CHECK PHP SESSION - ISSET($SESSION - IS NOT WORKING

CHECK PHP SESSION - ISSET($SESSION - IS NOT WORKING


By : Mohan Kumar DB
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Add the NOT operator ! to the if statement. Also don't forget to add exit() after your header. The location header is telling the browser to redirect, but an attacker could view your page and simply ignore the location header, thus bypassing your authentication system becuase your PHP code would continue to execute.
session persisting in PHP despite using isset

session persisting in PHP despite using isset


By : yamabushi170
Date : March 29 2020, 07:55 AM
I hope this helps . I have a form which is used to insert records into the database and if all goes right redirect the user to the index page with a message (actually set with a session) about the success or failure of the operation. , Try deleting the session after displaying:
code :
<?php if(isset($_SESSION['insert'])){
?>
<p class="update"><?php echo $_SESSION['insert'];?></p>
<?php
unset($_SESSION['insert']);
}//end of isset $_SESSION['insert']
?>
Related Posts Related Posts :
  • How to add Smarty templating engine to CodeIgniters 3 framework?
  • Am I maxing out possible data insert
  • Redirect to homepage without changing address bar URL
  • What is the best user-Id Value for a MySql "users" table
  • PHP $_COOKIE is only available in one directory
  • php regular expressions documantation
  • cannot import too large sql file to mysql
  • not getting appilcation/json in content-type in header
  • Only the first data display from my database but other shows but not on a table
  • Is it possible to have a print button link as the content of the mail
  • how to extract full mail address in imap php
  • Alternative to output buffering to put eval'd code into a variable
  • how to run wordpress php snippet mysql update command from ssh and/ultimately cron
  • how to get xml tag by name
  • ModSecurity maximum post limits (PCRE limit errors)
  • Call controller/action in event listener
  • How to improve performance of contacting WebService?
  • PHP nest variable in echoed string that contains a HTML tag in the end
  • Multiple Ajax request for PHP framework
  • Debug Info from Moodle Plugin
  • passing variables through page
  • Passing PHP $result data to Javascript
  • cakePHP File Download was not found or not readable
  • batch waiting until script finishes
  • PHP variables and anchors in URL
  • php eTag generation using php
  • How to check whether the array is an Integer or Not?
  • Is it possible to install Doctrine without PEAR or Composer? If so, how?
  • Call view script of (parent) Abstract controller Zend
  • Curl PHP cannot display amazon
  • Symfony, getters and setters vs magic methods
  • Using 'continue' PHP instruction outside the loop
  • AJAX POST return data not appearing
  • Can I query relations using an INNER JOIN instead of two queries in Eloquent?
  • Looping through dynamic form fields and inserting into database
  • My php code can't select mysql auto_increment value
  • Store Angularjs form data in database using php
  • I want to run my sh file continuously even if I close my Putty connection
  • file_get_contents equivalent for gzipped files
  • Include PHP file with jQuery
  • php curl headers do not return from website?
  • How to find out, if facebook ID is a user, group or page
  • Connect webhost database to android database
  • preg_match get div content with class
  • Upload multiple files in Laravel 4
  • Count array numbers in multidimensional array
  • PHP Date diff with a difference
  • Search Customer by custom field in Netsuite
  • Is it possible to hide/encode/encrypt php source code and let others have the system?
  • list items to be displayed using php code and array
  • check if row exists mysqli
  • PHP errors loading MySQL
  • setup PostgreSQL with Laravel in MAMP
  • PHP - CodeIgniter Notifications
  • Encrypting a password column in a SQL database
  • New to PHP, trying to extract information from another website
  • JavaScript AmChart to Image for Email
  • Is javascript validation enough to keep my forms secure?
  • Regex extract variables from [shortcode]
  • Download a .mp3 link and save it to computer with PHP
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org