Jump to content

Search the Community

Showing results for tags 'session variable'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 3 results

  1. Login page: <?php require_once('Connections/localhost.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } $loginFormAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } if (isset($_POST['username'])) { $loginUsername=$_POST['username']; $password=$_POST['password']; $MM_fldUserAuthorization = ""; $MM_redirectLoginSuccess = "controlpanel.php"; $MM_redirectLoginFailed = "login.php"; $MM_redirecttoReferrer = false; mysql_select_db($database_localhost, $localhost); $LoginRS__query=sprintf("SELECT username, password FROM users WHERE username=%s AND password=%s", GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); $LoginRS = mysql_query($LoginRS__query, $localhost) or die(mysql_error()); $loginFoundUser = mysql_num_rows($LoginRS); if ($loginFoundUser) { $loginStrGroup = ""; if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();} //declare two session variables and assign them $_SESSION['MM_Username'] = $loginUsername; $_SESSION['MM_UserGroup'] = $loginStrGroup; if (isset($_SESSION['PrevUrl']) && false) { $MM_redirectLoginSuccess = $_SESSION['PrevUrl']; } header("Location: " . $MM_redirectLoginSuccess ); } else { header("Location: ". $MM_redirectLoginFailed ); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url=http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/url] <html xmlns="[url=http://www.w3.org/1999/xhtml]http://www.w3.org/1999/xhtml">[/url] <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> </head> <body><form action="<?php echo $loginFormAction; ?>" method="POST" id="loginform"><table width="600" border="0"> <tr> <td><span id="sprytextfield1">username<br /> <label for="username"></label> <input type="text" name="username" id="username" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td> </td> </tr> <tr> <td><span id="sprytextfield2">password<br /> <label for="password"></label> <input type="password" name="password" id="password" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td> </td> </tr> <tr> <td><input type="submit" name="login" id="login" value="login" /></td> </tr> <tr> <td> </td> </tr> </table> </form> <script type="text/javascript"> var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1"); var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2"); </script> </body> </html> Control panel: <?php require_once('Connections/localhost.php'); ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "login.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) $MM_referrer .= "?" . $_SERVER['QUERY_STRING']; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } }if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $colname_user = "-1"; if (isset($_SESSION['username'])) { $colname_user = $_SESSION['username']; } mysql_select_db($database_localhost, $localhost); $query_user = sprintf("SELECT * FROM users WHERE username = %s", GetSQLValueString($colname_user, "text")); $user = mysql_query($query_user, $localhost) or die(mysql_error()); $row_user = mysql_fetch_assoc($user); $totalRows_user = mysql_num_rows($user);$username_user = "-1"; if (isset($_SESSION['username'])) { $username_user = $_SESSION['username']; } mysql_select_db($database_localhost, $localhost); $query_user = sprintf("SELECT * FROM users WHERE %s = %s", GetSQLValueString($username_user, "text"),GetSQLValueString($username_user, "text")); $user = mysql_query($query_user, $localhost) or die(mysql_error()); $row_user = mysql_fetch_assoc($user); $totalRows_user = mysql_num_rows($user); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url=http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/url] <html xmlns="[url=http://www.w3.org/1999/xhtml]http://www.w3.org/1999/xhtml">[/url] <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <a href="logout.php">logout</a> | <a href="user_epdate.php?username=<?php echo $row_user['username']; ?>">update</a> </body> </html> <?php mysql_free_result($user); ?> User update: <?php require_once('Connections/localhost.php'); ?> <?php if (!isset($_SESSION)) { session_start(); } $MM_authorizedUsers = ""; $MM_donotCheckaccess = "true"; // *** Restrict Access To Page: Grant or deny access to this page function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) { // For security, start by assuming the visitor is NOT authorized. $isValid = False; // When a visitor has logged into this site, the Session variable MM_Username set equal to their username. // Therefore, we know that a user is NOT logged in if that Session variable is blank. if (!empty($UserName)) { // Besides being logged in, you may restrict access to only certain users based on an ID established when they login. // Parse the strings into arrays. $arrUsers = Explode(",", $strUsers); $arrGroups = Explode(",", $strGroups); if (in_array($UserName, $arrUsers)) { $isValid = true; } // Or, you may restrict access to only certain users based on their username. if (in_array($UserGroup, $arrGroups)) { $isValid = true; } if (($strUsers == "") && true) { $isValid = true; } } return $isValid; } $MM_restrictGoTo = "login.php"; if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { $MM_qsChar = "?"; $MM_referrer = $_SERVER['PHP_SELF']; if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&"; if (isset($_SERVER['QUERY_STRING']) && strlen($_SERVER['QUERY_STRING']) > 0) $MM_referrer .= "?" . $_SERVER['QUERY_STRING']; $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer); header("Location: ". $MM_restrictGoTo); exit; } ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "signup")) { $updateSQL = sprintf("UPDATE users SET firstname=%s, lastname=%s, email=%s, username=%s, password=%s WHERE userid=%s", GetSQLValueString($_POST['firstname'], "text"), GetSQLValueString($_POST['lastname'], "text"), GetSQLValueString($_POST['email'], "text"), GetSQLValueString($_POST['username'], "text"), GetSQLValueString($_POST['password'], "text"), GetSQLValueString($_POST['userid'], "int")); mysql_select_db($database_localhost, $localhost); $Result1 = mysql_query($updateSQL, $localhost) or die(mysql_error()); $updateGoTo = "controlpanel.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } $colname_Recordset1 = "-1"; if (isset($_GET['username'])) { $colname_Recordset1 = $_GET['username']; } mysql_select_db($database_localhost, $localhost); $query_Recordset1 = sprintf("SELECT * FROM users WHERE username = %s", GetSQLValueString($colname_Recordset1, "text")); $Recordset1 = mysql_query($query_Recordset1, $localhost) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); $username_Recordset1 = "-1"; if (isset($_GET['username'])) { $username_Recordset1 = $_GET['username']; } mysql_select_db($database_localhost, $localhost); $query_Recordset1 = sprintf("SELECT * FROM users WHERE %s = %s", GetSQLValueString($username_Recordset1, "text"),GetSQLValueString($username_Recordset1, "text")); $Recordset1 = mysql_query($query_Recordset1, $localhost) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = "%"; if (isset($_GET['username'])) { $totalRows_Recordset1 = $_GET['username']; } $colname_registeruser = "-1"; if (isset($_GET['username'])) { $colname_registeruser = $_GET['username']; } mysql_select_db($database_localhost, $localhost); $query_registeruser = sprintf("SELECT userid, firstname, lastname, email, username, password FROM users WHERE username = %s", GetSQLValueString($colname_registeruser, "text")); $registeruser = mysql_query($query_registeruser, $localhost) or die(mysql_error()); $row_registeruser = mysql_fetch_assoc($registeruser); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url=http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/url] <html xmlns="[url=http://www.w3.org/1999/xhtml]http://www.w3.org/1999/xhtml">[/url] <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script> <link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" /> </head> <body><form action="<?php echo $editFormAction; ?>" method="POST" name="signup" id="signup"><table width="600" border="0"> <tr> <td><span id="sprytextfield1">username<br /> <label for="username"></label> <input name="username" type="text" id="username" value="<?php echo $row_registeruser['username']; ?>" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td> </td> </tr> <tr> <td><span id="sprytextfield2">password<br /> <label for="password"></label> <input name="password" type="text" id="password" value="<?php echo $row_registeruser['password']; ?>" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td> </td> </tr> <tr> <td><span id="sprytextfield3">firstname<br /> <label for="firstname"></label> <input name="firstname" type="text" id="firstname" value="<?php echo $row_registeruser['firstname']; ?>" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td> </td> </tr> <tr> <td><span id="sprytextfield4">lastname<br /> <label for="lastname"></label> <input name="lastname" type="text" id="lastname" value="<?php echo $row_registeruser['lastname']; ?>" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td> </td> </tr> <tr> <td><span id="sprytextfield5">email<br /> <label for="email"></label> <input name="email" type="text" id="email" value="<?php echo $row_registeruser['email']; ?>" /> <span class="textfieldRequiredMsg">A value is required.</span></span></td> </tr> <tr> <td> </td> </tr> <tr> <td><input type="submit" name="submit" id="submit" value="Submit" /></td> </tr> <tr> <td><input name="userid" type="hidden" id="userid" value="<?php echo $row_registeruser['userid']; ?>" /></td> </tr> </table> <input type="hidden" name="MM_update" value="signup" /> </form> <script type="text/javascript"> var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1"); var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2"); var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3"); var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4"); var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5"); </script> </body> </html> <?php mysql_free_result($Recordset1); ?> Please help. I am new to php and i am trying to get a session variable working. I am using dreamweaver cs6. I have got the login page working fine and connecting to my database. THis then loads the control panel,working fine. When i click edit on the control panel it is supposed to take me to a templated page with the session variable for the user logged in, this is not happening it is going to the username on the top row of my database.
  2. Hello everybody. I'm changing some php in one wordpress website. What I'm trying to do is to pass some values from one website page to the other. When I do it this way, everything works fine: Example 1: First php file: (the one sending the value) $Variable1 ='Hello'; $_SESSION['kamail']=$Variable1; printf('<li> Variable value:'. $Variable1 .'</li>'); Second php file: (the one getting the value) $Variable2=($_SESSION['kamail']); In the previous "Example 1" I get the correct value in $Variable2 and the print_f also prints the correct value In the next "Example 2", it does print the correct value, but in the second file, $Variable2 gets a completely different value. Example 2: First php file: (the one sending the value) $Variable1 =($javo_directory_query->get('email')); $_SESSION['kamail']=$Variable1; printf('<li> Variable value:'. $Variable1 .'</li>'); Second php file: (the one getting the value) $Variable2=($_SESSION['kamail']); I guess that this haves something to do with pointers or something similar, but I'm a completely PHP beginner, so I'm stuck with this Francisco
  3. I'd describe myself as a "basic" php programmer.... I'm trying to build my first multi-page forms. The first page is calculator_q1.php No session variables are needed here, I have omitted a few options, the code looks like this <form id="page1" method="post" action="calculator_q2.php"> <h1>1. Which best describes the primary and secondary sports combination that will be played on your pitch?</h1> <table> <tr><td>Rugby only</td><td><input type="radio" name="1_primary_secondary_combo" value="Rugby only"></td></tr> <tr><td>Rugby/Soccer</td><td><input type="radio" name="1_primary_secondary_combo" value="Rugby Soccer"></td></tr> <tr><td>Soccer/Hockey</td><td><input type="radio" name="1_primary_secondary_combo" value="Soccer Hockey"></td></tr> </table> <input class="blue" type="submit" value="Next"> </form> The 2nd page is calculator_q2.php. This has some php to start the session, copy the result of form 1 to a session var, I do a debug echo and the variable is printed correctly so I think have captured it correctly. In extract, I do this: <?php //Start the session session_start(); //Store our posted values in the session variables $_SESSION['1_primary_secondary_combo'] = $_POST['1_primary_secondary_combo']; ?> <?php $debug=True; if ($debug) { echo ("Debug: session for q1 = ".$_SESSION['1_primary_secondary_combo']); } ?> <form id="page2" method="post" action="calculator_q3.php"> <h1>2. Please choose a preferred surface</h1> <table> <tr><td>3G Rubber Crumb Filled Turf</td><td><input type="radio" name="2_preferred_surface" value="3G Rubber Crumb Filled Turf "></td></tr> <tr><td>Sand Filled Turf</td><td><input type="radio" name="2_preferred_surface" value="Sand Filled Turf"></td></tr> <tr><td>Sand Dressed Turf or<br>a Water Based Surface</td><td><input type="radio" name="2_preferred_surface" value="Sand Dressed Turf or a Water Based Surface"></td></tr> </table> <p> <script> function submitForm(action){ document.getElementById('page2').action = action; document.getElementById('page2').submit(); } </script> <input class="blue" type="button" onclick="submitForm('/calculator_q1.php')" value="Previous" /> <input class="blue" type="button" onclick="submitForm('/calculator_q3.php')" value="Next" /> </form> So far so good, but when I introduce page 3 (calculator_q3.php) then it prints the previous page's (from page 2) variable but can't find the session variable from question 1. This is from calculator_q3.php: <?php //Start the session session_start(); //Store our posted values in the session variables $_SESSION['2_preferred_surface'] = $_POST['2_preferred_surface']; ?> <?php $debug=True; if ($debug) { echo ("Debug: session for q1 = ".$_SESSION['1_primary_secondary_combo']); echo ("<br>Debug: session for q2 = ".$_SESSION['2_preferred_surface']); } ?> <form id="page3" method="post" action="calculator_q4.php"> <h1>3. Please choose one watering option</h1> <table> <tr><td>With a Rain Gun System</td><td><input type="radio" name="3_watering_option" value="With a Rain Gun System"></td></tr> <tr><td>With a Rain gun System + Water Borehole</td><td><input type="radio" name="3_watering_option" value="With a Rain gun System + Water Borehole"></td></tr> <tr><td>Not Required</td><td><input type="radio" name="3_watering_option" value="Not Required"></td></tr> </table> <p> <script> function submitForm(action){ document.getElementById('page3').action = action; document.getElementById('page3').submit(); } </script> <input class="blue" type="button" onclick="submitForm('/calculator_q2.php')" value="Previous" /> <input class="blue" type="button" onclick="submitForm('/calculator_q4.php')" value="Next" /> </form> To see this in action see: http://www.sports.hardingweb.net/calculator_q1.php Any insights would be appreciated. Many thanks.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.