[Solved] I need help getting the grand total of a simple php cart using sessions [closed]

Just replace this chunk of code, with my code below….should work… <?php //Print all the items in the shopping cart $totalAll = 0; foreach ($_SESSION[‘SHOPPING_CART’] as $itemNumber => $item) { $totalAll = $totalAll + ($item[‘qty’]*$item[‘price’]); ?> <tr id=”item<?php echo $itemNumber; ?>”> <td height=”41″><a href=”https://stackoverflow.com/questions/17129590/?remove=<?php echo $itemNumber; ?>”>Remove Item</a></td> <td><?php echo $item[‘name’]; ?></td> <td>£<?php echo $item[‘price’]; … Read more

[Solved] How to Skip LauncherActivity and call another Activity when application start

You can use SharedPreference for achieving this. You need to implement the logic in your SplashActivity. You need to check whether already logged in or not using the value stored in shared preference and show next activity based on that. In your SplashActivity (Where you launch the login activity), add the logic like: // Retrieving … Read more

[Solved] Display Username in Index page

CheckLogin.php if ( $count == 1 ) { $_SESSION[‘login_id’] = $row[‘id’]; $_SESSION[‘username’] = $row[‘username’]; // added if ( $_SESSION[‘login_id’] != ” || $_SESSION[‘login_id’] > 0 ) { // edited header(“location: index.php”); } else { header(“location: login3.html”); } } Index.php <?php require_once ‘UserSessionAdmin.php’; // edited $username = $_SESSION[‘username’]; // added ?> <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML … Read more

[Solved] How to send info from two session variable to a text file if a number has been guessed [closed]

You can create/open a new file then write in it the concatenation of your variables: $scores_file=”scores.txt”; // open the file $handle = fopen($scores_file, ‘w’) or die(‘Cannot open file: ‘.$scores_file); // create 1rst line and a line feed \n $data=”Number of guesses:”.$_SESSION[‘antal_gaet’].”\n”; // concat the 2nd line $data .= ‘Username:’.$_SESSION[‘username’]; // write to the opened file … Read more

[Solved] Session Full Name instead of Username in PHP Login Form [closed]

use this code index.php <!DOCTYPE html> <html> <body> <h2>HTML Forms</h2> <form action=”login.php” method=”post”> <label for=”fname”>First name:</label><br> <input type=”text” id=”fname” name=”username” value=”John”><br> <label for=”lname”>Last name:</label><br> <input type=”password” id=”lname” name=”password” value=”Doe”><br><br> <input type=”submit” value=”Submit”> </form> <p>If you click the “Submit” button, the form-data will be sent to a page called “/action_page.php”.</p> </body> </html> login.php <?php $servername = … Read more

[Solved] Setting a PHP cookie value to be intentionally vulnerable

i looked at it again, try this: $cookie_name=”Authenticated”; // this checks if the value has been set already if (!isset($_GET[‘cookie_value’])) { // if no value is set, it defaults to 0 and displays the error message $cookie_value=0; $error = “You are not authorized to view this page!”; echo $error; } // Now here if the … Read more

[Solved] How to unset session on close page

Looks like this is too much server intensive. Something like a Long Polling! Also, PHP Sessions get automatically destroyed when the window is closed. But still if you insist, you can use something like attaching an AJAX Call with the event onbeforeunload this way: $(window).on(‘beforeunload’, function(){ $.getScript(“killsession.php”); }); This gets a JavaScript before the window … Read more

[Solved] What can i make for this session please help me [closed]

Something on the lines of if I understand your question: Login.php session_start(); if(isset($_POST)): $_SESSION[‘loggedIn’] = TRUE; endif; Profile.php session_start(); if(!isset($_SESSION[‘loggedIn’])): header(‘Location: login.php’); endif; 1 solved What can i make for this session please help me [closed]

[Solved] PHP :Initializing elements of session array

As every on suggested above, try this:- <?php session_start(); $_SESSION[‘yans’] = array(‘A’,’B’,’C’,’D’,’E’); echo “<pre/>”;print_r($_SESSION);die; ?> Output:- http://prntscr.com/7btkxv Note:- it’s a simple example given for your understanding. thanks. solved PHP :Initializing elements of session array