Search
 
SCRIPT & CODE EXAMPLE
 

PHP

session variable

session_start();
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$link = new mysqli('localhost', 'username', 'password', 'db_name');
$link->set_charset('utf8mb4'); // always set the charset
$name = $_GET["username"];
$stmt = $link->prepare("SELECT id FROM Users WHERE username=? limit 1");
$stmt->bind_param('s', $name);
$stmt->execute();
$result = $stmt->get_result();
$value = $result->fetch_object();
$_SESSION['myid'] = $value->id;
Comment

session variable

session_start();
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
$name = $_GET["username"];
$sql = "SELECT 'id' FROM Users WHERE username='$name' limit 1";
$result = mysqli_query($link, $sql);
if ($result !== false) {
    $value = mysqli_fetch_field($result);
    $_SESSION['myid'] = $value;
}
Comment

Registering a variable with $_SESSION.

<?php
session_start();
if (!isset($_SESSION['count'])) {
  $_SESSION['count'] = 0;
} else {
  $_SESSION['count']++;
}
?>
Comment

PREVIOUS NEXT
Code Example
Php :: eager loading set limit to relationship 
Php :: folder name escape php 
Php :: laravel length validation 
Php :: iis change php fastcgi user 
Php :: what does the initals of php stand for? 
Php :: automatically create html page using php and mysql 
Php :: php base64 encode utf8 
Php :: laravel many to many update all pivot 
Php :: check input value is not empty or spaced php 
Php :: magento 2 block called as child pass product variable 
Php :: magento 2 get layout create block with cache 
Php :: create or update laravel 5.8 stackoverflow 
Php :: detect mobile device laravel 
Php :: verta sample jalali laravel problem return object 
Php :: wc php after login redirect page 
Php :: laravel pdf generator 
Php :: laravel framework 
Php :: prestashop get product id 
Php :: php api call with headers 
Php :: upgrade php 5.6 to 7 centos 7 
Php :: Laravel9 Failed to listen on 127.0.0.1:8000 (reason: ?) 
Php :: ziparchive laravel not found 
Php :: php class comment 
Java :: import collectors java 
Java :: java create jframe 
Java :: how to close a jframe in java with an if statement 
Java :: react-native force rtl on android 
Java :: creating random color in java 
Java :: change visibility of textview andoird 
Java :: spigot spawn entity 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =