Jump to content

Search the Community

Showing results for tags 'session'.

  • 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

  1. when i click on image1 with id=1, it stores in session and when i click on image2 with id=2, it stores in session too next to the first one, and when i click on image3 with id=3, it stores in session next to id=2. and so on.... i hope you understand what i am asking .... need help. i know how to get value from array.... like <?php// begin the sessionsession_start(); // create an array$my_array=array('cat', 'dog', 'mouse', 'bird', 'crocodile', 'wombat', 'koala', 'kangaroo'); // put the array in a session variable$_SESSION['animals']=$my_array; // a little message to say we have done itecho 'Putting array into a session variable';// loop through the session array with foreachforeach($_SESSION['animals'] as $key=>$value) { // and print out the values echo 'The value of $_SESSION['."'".$key."'".'] is '."'".$value."'".' <br />'; }?> /*************************************************************************************************************************************/ but wat i want is, cat ,dog,mouse,bird,crocodile,wombat,koala,kangaroo ... stored in array when i click on them.... i hope you understand.. please help!!! thanks and regards, jazz..
  2. This problem is for real PHP freaks. I do not post in forums unless I really can't find a solution. I have been bugged by this for days now. Here it is. I have a page signup.php among other pages on the website. Once you logout from logout.php all session is destroyed and all cookies are deleted. you can visit the website as a visitor after logging out. I visited all pages to make sure I was really logged out. Everything is normal up till here. However, when I click on signup again which call signup.php, the old session becomes suddenly alive and you are logged in again as if you had never logged out. I have never faced this problem before and I have made many websites using PHP. I have tested and found that session is already there when the page loads and values are not formed by any variable or function manipulation. I am using hostgator shared hosting. Please guyz help me out. I am not sure what I am doing wrong here.
  3. Return

    session

    * I have a field in a db table called "name", as would be helping me to record it in a session to be viewing this page? * Here is the code that the user uses to login. <?php include ('smarty/libs/Smarty.class.php');$smarty = new Smarty(); $smarty->template_dir = "smarty/demo/templates"; $smarty->compile_dir = "smarty/demo/templates_c"; $smarty->config_dir = "smarty/demo/configs"; $smarty->cache_dir = "smarty/demo/cache"; ?> <?php session_start(); if($_POST) { include ('config.php'); $username = $_POST['username']; $password = $_POST['password']; $conn = mysql_connect($dbhost,$dbuser,$dbpass) or die ('Error connecting to mysql'); mysql_select_db($dbname); $query = sprintf("SELECT COUNT(id) FROM users WHERE UPPER(username) = UPPER('%s')AND password='%s'", mysql_real_escape_string($username), mysql_real_escape_string(md5($password))); $result = mysql_query($query); list($count) = mysql_fetch_row($result); if($count >= 1) { $_SESSION['authenticated'] = true; $_SESSION['username'] = $username; $query = sprintf("SELECT COUNT(id) FROM users WHERE UPPER(username) = UPPER('%s')AND confirmed='1'", mysql_real_escape_string($username), mysql_real_escape_string(($confirmed))); $result = mysql_query($query); list($count) = mysql_fetch_row($result); if($count == 1) { $query = sprintf("UPDATE users SET last_login = NOW() WHERE UPPER(username) = UPPER('%s') AND password = '%s'", mysql_real_escape_string($username), mysql_real_escape_string(md5($password))); mysql_query($query); $query = sprintf("SELECT is_admin FROM users WHERE UPPER(username) = UPPER('%s') AND password='%s'", mysql_real_escape_string($username), mysql_real_escape_string(md5($password))); $result = mysql_query($query); list($is_admin) = mysql_fetch_row($result); if($is_admin == 1) { print"<script> window.location='';</script>"; } else { print"<script> window.location='';</script>"; } } $error = ''; }else{ $error = ''; } } $smarty->assign('error',$error); $smarty->assign('message',$message); $smarty->display('login.tpl'); ?>
  4. Hi There, I am trying to make a login system with PHP and I have made one but I can't see the problem, it just keeps taking me back to login.php. All files involved attached. Many Thanks for Your Help in Advance. includes.zip
  5. After a couple days of search google and looking through the plethora of books here on the shelf, I have come to the conclusion that what I am looking for I simply don't have the right terminology for it as the results I am getting are clearly not what I am looking for. Therefore I post in hope that someone here could shine a light onto where I am going wrong. The Brief: I have an IP address lookup script that can use GET or POST to produce the GEO Location of an IP address, fairly simply stuff. However the system is getting abused which is not fair on our other visitors looking to find out those nasties. I would like to LIMIT the amount of lookups, say 10 in any one hour. This is where I hit the proverbial wall, as I am unsure as to how one could achieve this, nor do I have an understanding on what this would be called as my assumed "Limit Form Submits" does not bear fruit. Any help, guidance of RTFMs appreciated.
  6. Hello All I am generating new session value every time when page is reload. I am getting session result like this: compare_session_281,147,136 ⇒ 281,147,136 compare_session_96,46,30 ⇒ 96,46,30 compare_session_29,27,26 ⇒ 29,27,26 compare_session_281,147,136, compare_session_96,46,30 and compare_session_29,27,26 are my sessions. Now I want to concate session value like this: compare_session = 281,147,136,96,46,30,29,27,26 Any ideas or suggestion? Thanks
  7. this expire system wont work.. whats wrong with it? When you login: (login page) <?php session_start(); $_SESSION['start'] = time(); $_SESSION['expire'] = $_SESSION['start'] + (3600); ?> The page you goto after you login: (logged in page) <?php session_start(); $now = time(); if($now > $_SESSION['expire']) { session_destroy(); echo "session expired!"; } else { echo $myusername; } ?> When im at the logged in page, and i refresh it just says "session expired!"
  8. hi all , I have to system running Ubuntu 13.04 . on my laptop everything works fine but on my PC I can not work with session variable , I have installed Apache2 and PHP from terminal ,i'm running a same code on both devices. the code that I used for checking if the variable is set or not on every page is : <?php session_start(); if(!isset($_SESSION["mys"])) { header('location:../index.php'); } ?> as you can see if the variable do not set , user would redirect to the index page . the problem is my session variable is not getting set at all , this is a code that i ran on both devices : <?php session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <link REL="SHORTCUT ICON" HREF="qeshmac.ico"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> <?php include 'mytool.php'; if(isset($_POST["myusername"])) { // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $host='localhost'; // Host name $username='root'; // Mysql username $password=''; // Mysql password switch ($_POST['tabs']) { case 'students': $db_name='students'; // Database name $tbl_name='test'; // Table name break; case'teachers': $db_name='managers'; // Database name $tbl_name='teachers'; // Table name break; case'managers': $db_name='managers'; // Database name $tbl_name='employes'; // Table name break; case'admin': $db_name='managers'; // Database name $tbl_name='moderator'; // Table name break; } // Connect to server and select database. mysql_connect($host,$username,$password)or die("cannot connect"); $selected=mysql_select_db($db_name)or die("cannot select DB"); mysql_query("SET CHARACTER SET utf8;"); mysql_query("SET SESSION collation_connection = 'utf8_persian_ci'"); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); if(mysql_fetch_assoc($result)) { switch ($_POST['tabs']) { case 'students': $_SESSION["mys"]=$myusername; print( redirect('student/index.php')); break; case 'teachers': $_SESSION["mys"]=$myusername; print( redirect('teachers/index.php')); break; case 'managers': $_SESSION["mys"]=$myusername; print( redirect('managers/index.php')); break; case 'admin': $_SESSION["mys"]=$myusername; print( redirect('admin/index.php')); break; } } else { //back to login print( redirect('index.php?cmd=error')); } } else { print( redirect('index.php')); } ?> </body> </html>
  9. I am working on a code that will help me in creating and maintaining the session on webpage. When the customer visits the page the session must become active and increase the counter by one. I am able to do that. But, when the customer visits that page again, session_start() has been called again and it provided a warning. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\index.php:13) in C:\xampp\htdocs\counter.php on line 2 so, what can I do to omit this warning After visiting the page the session gets created and it does not updates further but it gives the above listed warning , looking for a quick answer .................
  10. my session value automatically changes, when i submit my form . actually i am using ajax in one of the fields in form. and when i submitthe form, my session value changes automatically to some random value. please suggest me, wat should i do??? do i use some other code instead of ajax for that field? or .... something else...???
  11. I need to increase the session length for my app, it keeps timing out on the people using it.. just changing the default in my php settings would be great but I haven't found anything that's worked for me on-line, is anyone able to help?
  12. Hi, I just have a quick question to ask which I can't find an answer to. Is there a way to set a session time for the "start_session" because everytime I log in, it doesn't keep my session for that long when I then access the page again later. Help is appreciated
  13. Trying to make a game where the user plays the computer, the user does not get to place ships and the computer does not try to sink the human's ships. on submit, the game is supposed to tell the user hit or miss or you sank my ship the board is supposed to remember where the user clicked each time until the game is over the computer randomly places 5 boats, I have the computer placing the boats, and I have some fire buttons, but its not connecting, and its not supposed to show where the boats are ( user is not supposed to see that part) <?php session_start() ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Battleship</title> <style type = "text/css"> #footer {font-size: small; text-align:center; clear:right; padding-bottom:20px; } body { background-image:url("infor.jpg"); color: white;text-align:center } p { color: yellow; text-align:center;} </style> </head> <body> <?php if(isset($_POST['start_game']) || isset($_POST['myGuess'])){ if (isset($_POST["counter"])){ $counter = $_POST["counter"]; } else { $counter = 0; } // end if $counter++; //store new data in counter $_SESSION["counter"] = $counter; if(isset($_POST['start_game']) || isset($_POST['myGuess'])){ if (isset($_POST["counter"])){ $counter = $_POST["counter"]; } else { $counter = 0; } // end if $counter++; //store new data in counter $_SESSION["counter"] = $counter; if(isset($_POST['choice'])){ if($_POST['choice']=="correct") print "<br>I got it! it took me $counter tries. <br>"; } $myGuess=rand($lowest,$highest); //This is used for debugging - keeping track of what each value is when the submit button is pressed // if(isset($_POST['choice'])){ //print_r($_POST); //} $form = "showOptions"; }else{ $form = "showStart"; } if($form == "showOptions"){ ?> <h2> <form method="post" action="" name="target"> <input type="Submit" value="Submit" align="MIDDLE"> </form> </h2> <form action="" method="post" > <table border="1" align="center"> <?PHP $step = $_POST['step']; if ($step > 2) { $step = 0; } else { $step += 1; }//end if if($step == 1) { for ($i = a; $i < k; $i++){ echo "<tr><td width='20' align='right'>$i</td>"; for ($j = 1; $j < 11; $j++){ echo "<td><input type='submit' value='fire' name='$i$j'></td>"; } // end for loop echo "</tr>"; } // end for loop echo "<tr><td></td>"; for ($j = 1; $j < 11; $j++){ echo "<td>$j</td>"; } echo "</tr></table>"; // result of fire } else { echo "Result "; for ($i = a; $i < k; $i++){ echo "<tr><td width='10' align='right'>$i</td>"; for ($j = 1; $j < 11; $j++){ echo "<td><input type='checkbox' checked='checked' disabled='disabled' name='$i$j'></td>"; } // end for loop echo "</tr>"; } // end for loop echo "<tr><td></td>"; for ($j = 1; $j < 11; $j++){ echo "<td>$j</td>"; } echo "</tr></table><br><input type='submit' name='' value='shoot'>"; }//end if ?> <input type="hidden" name="step" value="<?php echo "$step";?>" /> </form> </center> <?php if ($step == 0) { for ($i = a; $i < k; $i++){ echo "<tr><td width='10' align='right'>$i</td>"; for ($j = 1; $j < 11; $j++){ echo "<td><input type='submit' value='fire' name='$i$j'></td>"; } // end for loop echo "</tr>"; } // end for loop echo "<tr><td></td>"; for ($j = 1; $j < 11; $j++){ echo "<td>$j</td>"; } echo "</tr></table>"; //player fireing } else if($step == 1) { for ($i = a; $i < k; $i++){ echo "<tr><td width='10' align='right'>$i</td>"; for ($j = 1; $j < 11; $j++){ echo "<td><input type='submit' value='fire' name='$i$j'></td>"; } // end for loop echo "</tr>"; } // end for loop echo "<tr><td></td>"; for ($j = 1; $j < 11; $j++){ echo "<td>$j</td>"; } echo "</tr></table>"; // result of fire } else { echo "Result "; for ($i = a; $i < k; $i++){ echo "<tr><td width='10' align='right'>$i</td>"; for ($j = 1; $j < 11; $j++){ echo "<td><input type='checkbox' checked='checked' disabled='disabled' name='$i$j'></td>"; } // end for loop echo "</tr>"; } // end for loop echo "<tr><td></td>"; for ($j = 1; $j < 11; $j++){ echo "<td>$j</td>"; } } echo "</tr></table><br><input type='submit' name='' value='shoot'>"; }//end if ?> <input type="hidden" name="step" value="<?php echo "$step";?>" /> <h2>The number of squares for each ship is determined by the type of the ship. <BR /> The ships cannot overlap (i.e., only one ship can occupy any given square in the grid). <BR /> In each round, the Human clicks the target square which is to be shot at. <BR /> The Computer announces whether or not the square is occupied by a ship, <BR /> and if it is a hit they mark this on their own primary grid. <BR /> When all of the squares of a ship have been hit, the ship is sunk, <BR /> and the Computer owner announces this (e.g. You sunk my battleship!!). <BR /> If all of a player's ships have been sunk, the game is over and their opponent wins. </h2> <h2><?php echo "<br> <a href='battleshipmajorstart.php'>Reset Game</a>" ?></h2> <?php error_reporting( E_ALL ); // $ships['Ship Name'] = size (int); $ships = array( 'Carrier' => 5, 'Battleship' => 4, 'Destroyer' => 3, 'Submarine' => 3, 'Patrol Boat' => 2 ); // $grid[x-coord][y-coord] $grid = array(); // Loop through ships for placement foreach( $ships as $name => $size ) { // Begin an infinite loop ( dangerous, but we can break it when // the ship is happily placed ) while ( TRUE ) { // Determine direction of ship // x- horizontal, y- vertical $axis = ( mt_rand(0,1) == 1 ? 'x' : 'y' ); // Maximum values on grid $max = array( 'x' => 10, 'y' => 10 ); // Subtract $size from the max value to compensate for ship size $max[ $axis ] -= $size; // Generate random placement $x = mt_rand( 1, $max['x'] ); $y = mt_rand( 1, $max['y'] ); // Check to see if the grid is empty by checking $size squares in $axis direction for ( $i = 0; $i < $size; $i++ ) { //Create a temporary holder for our coordinates $curr = array( 'x' => $x, 'y' => $y ); ////Add current grid position to the direction we're going $curr[ $axis ] += $i; // Check to see if the grids populated if ( isset( $grid[ $curr['x'] ][ $curr['y'] ] ) ) //If it is, start at the beginning of the while loop and find new coordinates continue 2; } // If the for loop didn't run into a collision, then we know the grid space is empty //and we can break out of the infinite loop! break; } //Now that we have a position for the ship, write it into the grid! for ( $i = 0; $i < $size; $i++ ) { // Create a temporary holder for our coordinates $curr = array( 'x' => $x, 'y' => $y ); // Add current grid position to the direction we're going $curr[ $axis ] += $i; // Add the first letter of the ships name to the grid ( just for example purposes ) $grid[ $curr['x'] ][ $curr['y'] ] = substr( $name, 0, 1 ); } } //Display the grid echo '<table width="300" height="300" border="1" align="center">'; for ( $row = 1; $row <= 10; $row++ ) { echo '<tr>'; for( $col = 1; $col <= 10; $col++ ) { echo '<td width="30" align="center">'; echo ( isset($grid[$row][$col]) ? $grid[$row][$col] : ' ' ); echo '</td>'; } echo '</tr>'; } echo '</table>'; ?> <?php } else{ ?> When play begins, The Computer secretly arranges Her ships on Her primary grid. <BR /> Each ship occupies a number of consecutive squares on the grid, <BR />arranged either horizontally or vertically. <BR /> <BR /> The number of squares for each ship is determined by the type of the ship. <BR /> The ships cannot overlap (i.e., only one ship can occupy any given square in the grid). <BR /> In each round, the Human clicks the target square which is to be shot at. <BR /> The Computer announces whether or not the square is occupied by a ship, <BR /> and if it is a "hit" they mark this on their own primary grid. <BR /> The attacking player notes the hit or miss on their own "tracking" grid, in order to build up a picture of the opponent's fleet. <BR /> When all of the squares of a ship have been hit, the ship is sunk, <BR /> and the ship's owner announces this (e.g. "You sunk my battleship!"). <BR /> If all of a player's ships have been sunk, the game is over and their opponent wins. <form method="post" action="" name="choice"> <input name="start_game" id="start_game" value="Start Game" type="submit" src="game.png" name="image" width="100" height="150"><br> </form> <?php } ?> <p id="footer">Copyright © 2013 DeAnna Riddlespur & Gene Lau & Matthew Semple</p> </body> </html>
  14. Hi, I'm reading Head First PHP and the book talks about how superior the persistence is for using both cookies and session variables by resetting the session variables from existing cookie variables when you open up the browser again. But when you think about it, what's the point of using sessions again in addition to cookies, if when you're using both the cookies are already exposed? That is, I'm not talking about session ID cookies here, I'm talking about just copying the cookie variables straight onto the session variables - not getting an address or anything like that. Hope I made the question clear enough, thanks!
  15. Hi all, I'm having this problem.. Sorry that if there is some one already post this top before... But I couldn't found 1 here or any other forum as well. My problem is this, eg: I'm using chrome browser to login using session. but when I'm using other browsers like firefox or IE. session appeared as well.... How can I do so that session value stored using 1 browser, other browser will not appear this value. Thank you very much!
  16. I am using this code <?php session_start(); // store session data $_SESSION['views']=1; ?> <html> <body> <?php //retrieve session data echo "<br><br>Pageviews=". $_SESSION['views']; if(isset($_SESSION['views'])) $_SESSION['views']=$_SESSION['views']+1; else $_SESSION['views']=1; echo "<br><br>Views=". $_SESSION['views']; ?> </body> </html> it is giving error, I don't know how to remove it. Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\prac\session1.php:2) in C:\xampp\htdocs\prac\session1.php on line 3
  17. Hi I'm a beginner in PHP, anyway i'm designing a website with membership, and I've created a register form and also a login, I can login and have used sessions so I can recall the username and create individual pages for each user. My next challenge is I want every user to have their own personal details stored on their individual page, the details are stored in a another database. My question Is how to link the sessions of the users to personal databases which are created in MySQL let me explain more. the user logged in welcome page the session will be called load up personal details from a second database Now I would need to link up another database to the members database using their ID key Members ID -Primary Key The second Database stuff will be inserted in this this will have to link up to the members database Now I'm not looking for an answer from you on how to do this, just recommend on what tutorials I should be following, and where to find more details on doing this.
  18. Hello everyone! This is my first post here! I was hoping I could get some help! I'm trying to create an age gate form and I'm running into a problem. The index page that I created actually works fine, but when I create the form and set up the php code the form is not interacting with the data beyond the action. I really don't understand what's going on here. I have a verify.php page that has a form on it and the php that should interact with it is at the top like so: <?php session_start(); if(isset($_POST['submit'])) { $remember = $_REQUEST ['remember']; $day = $_POST ['day']; $month = $_POST ['month']; $year = $_POST ['year']; $country = $_POST ['country']; $birthday = mktime(0,0,0,$month,$day,$year); $difference = time() - $birthday; $age = floor($difference / 31556926); echo $age; if($age >= 21) { $_SESSION ['verifyok'] = 1; header ("location: index.php"); } else { $_SESSION ['verifyfail'] = 0; header("loaction: http://www.centurycouncil.org/"); } if($remember == 'save') { setcookie("verifyok", 1,mktime(0,0,0,01,01,date("Y")+30)); $_SESSION['verified'] = 1; header("location: index.php"); exit(0); } } ?> And here I have the form that does not interact with the php and has the action as verify.php, the test server works and the php at the top of my index.php does redirect me to the verify page, but the verify page just isn't working. <form action="verify.php" method="POST"> <span class="heading">ENTER YOUR BIRTH DATE</span> <div id="dob"> <select name="day" class="styled" /> <option selected="selected" disabled="disabled">DD</option> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> <option>12</option> <option>13</option> <option>14</option> <option>15</option> <option>16</option> <option>17</option> <option>18</option> <option>19</option> <option>20</option> <option>21</option> <option>22</option> <option>23</option> <option>24</option> <option>25</option> <option>26</option> <option>27</option> <option>28</option> <option>29</option> <option>30</option> <option>31</option> </select> <select name="month" class="styled" /> <option selected="selected" disabled="disabled">MM</option> <option>01</option> <option>02</option> <option>03</option> <option>04</option> <option>05</option> <option>06</option> <option>07</option> <option>08</option> <option>09</option> <option>10</option> <option>11</option> <option>12</option> </select> <select name="year" class="styled" /> <option selected="selected" disabled="disabled">YYYY</option> <option>2013</option> <option>2012</option> <option>2011</option> <option>2010</option> <option>2009</option> <option>2008</option> <option>2007</option> <option>2006</option> <option>2005</option> <option>2004</option> <option>2003</option> <option>2002</option> <option>2001</option> <option>2000</option> <option>1999</option> <option>1998</option> <option>1997</option> <option>1996</option> <option>1995</option> <option>1994</option> <option>1993</option> <option>1992</option> <option>1991</option> <option>1990</option> <option>1989</option> <option>1988</option> <option>1987</option> <option>1986</option> <option>1985</option> <option>1984</option> <option>1983</option> <option>1982</option> <option>1981</option> <option>1980</option> <option>1979</option> <option>1978</option> <option>1977</option> <option>1976</option> <option>1975</option> <option>1974</option> <option>1973</option> <option>1972</option> <option>1971</option> <option>1970</option> <option>1969</option> <option>1968</option> <option>1967</option> <option>1966</option> <option>1965</option> <option>1964</option> <option>1963</option> <option>1962</option> <option>1961</option> <option>1960</option> <option>1959</option> <option>1958</option> <option>1957</option> <option>1956</option> <option>1955</option> <option>1954</option> <option>1953</option> <option>1952</option> <option>1951</option> <option>1950</option> </select> </div> <span class="heading" id="heading2">ENTER YOUR LOCATION</span> <div id="location"> <select name="country" class="styled" id="country" /> <option>USA</option> </select> </div> <div id="cookie"> <div id="box"><input type="checkbox" name="remember" value="save" class="styled" /></div><span id="notice"><b>Remember Me</b><br> <i>Do not check this box if you use a shared computer.</i> </span> </div> <div class="clear"></div> <div id="button"> <input id="enter" type="image" name="submit" src="images/enter_inactive.png" WIDTH="117" HEIGHT="44" BORDER="0" ALT="SUBMIT!"> </div> </form> I put a couple of divs inside the form but I don't see how that would really effect the PHP at all, the whole form is still together. I can't even get an echo test to work. I'm completely stumped here. I would greatly appreciate some help! Thanks You!
  19. Hi, I'm currently trying to understand exactly how php sessions work? So far I've been told that you start a session with session_start() and then hold that data in a variable like $_SESSION['User_Id']; but my problem is, is that I want it to hold the database user id so when the client logs in it keeps their session through their user_id. How would I execute this cause all the examples given to me look something like this: session_start(); $_SESSION['name'] = 'John';
  20. Hey I was wondering if there is a way where I can write a code that will find the user's previous session if they deleted thier cookie, or if the cookie has been expired in the middle of a session. Thanks
  21. I've been working on the delete item from cart functionality all day. Still cannot figure this out. When I add 2+ items to my cart, and try to delete any item but the last item added, the script deletes the listing the last item added no matter which one I'm attempting to delete. I could do this in C++ but the php solution is evading me. This has frustrated me today for over 4 hours just this one little problem. Can somebody please shine light on this for me, to help me see why I'm so close to finishing the delete functionality but it won't quite work. Here's my code: header.html (included in cart at top): session_start(); // For personal debugging -- REMOVE WHEN DONE // if ($_GET['des']) { session_destroy(); unset($_GET['des']); } // ---- // // Count Cart Items // if (empty($_SESSION['count_cart'])) { $_SESSION['count_cart'] = 0; } // Handle Delete Item // if ($_POST['submitted']) { $_SESSION['count_cart']--; $delItem = $_POST['delItem']; unset($_SESSION['item'][$delItem]); unset($_POST['submitted']); } // Handle setting sessions // if ($_POST['name'] == $PHPSESSID && isset($_POST['mdl_key'])) { $idx = $_SESSION['count_cart']; $_SESSION['count_cart']++; $_SESSION['item'][$idx][0] = $_POST['mdl_key']; $_SESSION['item'][$idx][1] = $_POST['model']; $_SESSION['item'][$idx][2] = $_POST['manufacturer']; $_SESSION['item'][$idx][3] = $_POST['sellprice']; $_SESSION['uri'][$idx] = $_POST['uri']; } And here is the code for the shoppingcart_customer.php page where the above is included with include: <form name="del" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <?php $i=0; $count = $i + 1; foreach ($_SESSION['item'] as $key=>$v1) { if (isset($_SESSION['item'][$key])) { echo "<tr><td width='30px'></td><td bgcolor='white'>".$count.".) "; foreach ($v1 as $v2){ echo $v2." "; } } echo " - <a href='".$_SESSION['uri'][$i]."' target='_blank'>View Details</a> | <input type='submit' value='Delete' name='delete'/> <input type='hidden' name='delItem' value='".$i."'/> <input type='hidden' name='submitted' value='TRUE'/> </td><td width='80px'></td></tr>"; $i++; } ?> </form> and here is the html $_POST code: <form enctype="multipart/form-data" action="shoppingcart-customer.php" method="post"> <input type="hidden" name="name" value="<?php echo $PHPSESSID; ?>"/> <input type="hidden" name="mdl_key" value="<?php echo $mdl_key; ?>"/> <input type="hidden" name="model" value="<?php echo $model; ?>"/> <input type="hidden" name="manufacturer" value="<?php echo $manufacturer; ?>"/> <input type="hidden" name="sellprice" value="<?php echo $sellprice; ?>"/> <input type="hidden" name="uri" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/> <input type="submit" name="addtocart" value="Add To Cart" id="hyperlink-style-button"/> </form>
  22. Hi, I have a page where students in my school can update an avatar. (my_profile.php) On this page, they see their avatar nice and large in the middle of the page. However, on this page, as well as all other pages in the site, the avatar is also displayed in a smaller version on the top-right corner, according to session data. if (!empty($_SESSION['userName']) && $_SESSION['member_avatar'] != "") { echo "<img src=\"images/member_avatars/" . $_SESSION['member_avatar'] . "\" width='40px' height='40px' alt=\"Avatar\" tyle=\"float: left; padding: 3px 3px 3px 3px;\" /></td>"; } if (!empty($_SESSION['userName']) && $_SESSION['member_avatar'] == "") { echo "<img src=\"images/member_avatars/default_avatar_50.gif\" width=\"40\" height=\"40\" alt=\"Your Avatar Here\" />"; } When the member uploads a new file, the large version can be seen immediately on the my_profile.php page where the code is echoing the row in the database. echo "<img src=\"images/member_avatars/" . $my_profile["member_avatar"] . "\" height='250' width='250' alt=\"Avatar\" /></td>"; However, the aforementioned smaller avatar ( $_Session['member_avatar'] ) does not update on this or any other page on the site. To update this, the user has to log out, and then log in again. How can I fresh the $_Session['member_avatar'] as soon as the new image is uploaded? Thanks in advance, Dave
  23. basically with my code it tells the user that they would need to be logged in to view the topics but once a user has logged in and tries to view them that it tells the user that they are not logged in and need to signin but once click this it already tells the user they are logged in can someone help me solve this i'm baffled. this is the code i'm using <?php //create_cat.php include 'mysql.php'; include 'header.php'; $sql = "SELECT id, subject FROM topics WHERE id = ". mysql_real_escape_string($_GET['id']); $result = mysql_query($sql); if(!$result) { echo 'The topic could not be displayed, please try again later.' . mysql_error(); } else { if(mysql_num_rows($result) == 0) { echo 'This topic dose not exist.'; } else { while($row = mysql_fetch_assoc($result)) { //display post data echo '<table class="topic" border="1"> <tr> <th colspan="2">' . $row['subject'] . '</th> </tr>'; //fetch the posts from the database $posts_sql = "SELECT post.topic, post.content, post.date, post.postby, users.id, users.username FROM post LEFT JOIN users ON post.postby = users.id WHERE post.topic = " . mysql_real_escape_string($_GET['id']); $posts_result = mysql_query($posts_sql); if(!$posts_result) { echo '<tr><td>The posts could not be displayed, please try again later.</tr></td></table>'; } else { while($posts_row = mysql_fetch_assoc($posts_result)) { echo '<tr class="topic-post"> <td class="user-post">' . $posts_row['username'] . '<br/>' . date('d-m-Y H:i', strtotime($posts_row['date'])) . '</td> <td class="post-content">' . htmlentities(stripslashes($posts_row['content'])) . '</td> </tr>'; } } if($_SESSION['loggedIn']) { echo '<tr><td colspan=2>You must be <a href="signin.php">signed in</a> to reply. You can also <a href="signup.php">sign up</a> for an account.'; } else { //show reply box echo '<tr><td colspan="2"><h2>Reply:</h2><br /> <form method="post" action="reply.php?id=' . $row['id'] . '"> <textarea name="reply-content"></textarea><br /><br /> <input type="submit" value="Submit reply" /> </form></td></tr>'; } //finish the table echo '</table>'; } } } include 'footer.php'; ?>
  24. Hello all, i have a change your password feature on one of my websites. It works perfectly in FF and Chrome but it is not working in IE 8. I have used MySQLi prepared statements and the script is fairly straight forward. In IE 8 when i click on submit button, it kills the session and gives "you are not authorized to view this page message". So I need some help in solving it. Below is the HTML form. <form name="frmcp" method="post" action="#"> <table border="0" cellpadding="5" cellspacing="5"> <tr><td>Old Password</td></tr> <tr><td><input type="password" name="password" id="password" /></td></tr> <tr><td>New Password</td></tr> <tr><td><input type="password" name="txtpass1" /></td></tr> <tr><td>Confirm Password</td></tr> <tr><td><input type="password" name="txtpass2" /></td></tr> <tr><td><input type="submit" name="btncp" value="Change Password" class="button" onclick="formhash(this.form, this.form.password);" /></td></tr> </table> </form> Below is the PHP Script which is on the same page above the html open tag. <?php // Include database connection and functions here. include '../php/config.php'; include 'php/functions.php'; //Securely Start Session sec_session_start(); //Check if user is logged in or not if((login_check($mysqli) == true) && $_SESSION['usertype'] == 0) { $userid = $_SESSION['user_id']; // Check if the button was clicked or not. if(isset($_POST['btncp'])){ //Check if all fields are filled. if(isset($_POST['txtpass1']) && !empty($_POST['txtpass1']) AND isset($_POST['txtpass2']) && !empty($_POST['txtpass2'])){ $newpass = htmlspecialchars(strip_tags($_POST['txtpass1'])); $newpass = hash('sha512', $newpass); $newcpass = htmlspecialchars(strip_tags($_POST['txtpass2'])); $newcpass = hash('sha512', $newcpass); //Check if new password matches the confirm password or not. if($newpass == $newcpass){ $password = $_POST['p']; //Check if the old password entered is correct or not. if ($stmt = $mysqli->prepare("SELECT username, password, usertype, salt FROM active_users WHERE user_id = ? LIMIT 1")) { $stmt->bind_param('i', $userid); // Bind "$email" to parameter. $stmt->execute(); // Execute the prepared query. $stmt->store_result(); $stmt->bind_result($username, $db_password, $usertype, $salt); // get variables from result. $stmt->fetch(); $password = hash('sha512', $password.$salt); // hash the password with the unique salt. if($stmt->num_rows == 1) { if($db_password == $password) { //Hash the new password with a new randomly created salt. $new_random_salt = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true)); $new_db_password = hash('sha512', $newcpass.$new_random_salt); //Update new password in the table. if ($stmt = $mysqli->prepare("UPDATE active_users SET password = ?, salt = ? WHERE user_id = ?")) { // Bind the variables to the parameter as strings. $stmt->bind_param("ssi", $new_db_password, $new_random_salt, $userid); // Execute the statement. $stmt->execute(); // Close the prepared statement. $stmt->close(); } //Redirect if password was changed and ask the user to login again using new password. header('Location: error.php?error=5'); } else { $msg = 'Old password entered is incorrect.'; } } else { $msg = 'User Does Not Exist.'; } } } else { $msg = 'New Password and Confirm Password does not match.'; } } else { $msg = 'All fields are mandatory.'; } } ?> The problem appears to be in the line where PHP checks if the button was clicked or not or in the line where it checks if user is logged in or not. But it works in FF and Chrome, just not in IE 8.
  25. I have a php login script which checks the user and displays the page without any issues on my production server which is on internet. The same php script is not working when i run it locally, am using win xp, UNISERV(Like XAMPP, WAMP). i have tested the database, it is working fine. I have tested sample session programs, it is creating the session in the tmp folder. But when I run login.php, it just give me blank page. Can someone help. Pl find my code below: <?php // login.php include_once 'common.php'; include_once 'db2.php'; session_start(); $uid = isset($_POST['uid']) ? $_POST['uid'] : $_SESSION['uid']; $pwd = isset($_POST['pwd']) ? $_POST['pwd'] : $_SESSION['pwd']; if(!isset($uid)) { ?> <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Test - Login</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <head> <style type="text/css"> <!-- .style1 { font-size: 16px; font-family: Verdana, Arial, Helvetica, sans-serif; } .style3 { font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; } body { background-color: #D7F0FF; margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } --> </style> </head> <body> <h1 class="style1"> <br><br>Exceltron Site -Testing Login Required </h1> <span class="style3"><br> You <strong>must login to access this area </strong>of the site. <br> <br> If you are not a registered user, please contact your Admin to sign up for instant access!</span> <p><form method="post" action="<?=$_SERVER['PHP_SELF']?>"> <span class="style3">User ID: <input type="text" name="uid" size="12" /> <br> <br /> Password:</span> <input type="password" name="pwd" SIZE="12" /> <br> <br /> <input type="submit" value="Login" /> </form></p> </body> </html> <?php exit; } $_SESSION['uid'] = $uid; $_SESSION['pwd'] = $pwd; dbConnect("exceltron"); $sql = "SELECT * FROM user WHERE userid = '$uid' AND password = '$pwd'"; $result = mysql_query($sql); if (!$result) { error('A database error occurred while checking your '. 'login details.\\nIf this error persists, please '. 'contact you@example.com.'); } if (mysql_num_rows($result) == 0) { unset($_SESSION['uid']); unset($_SESSION['pwd']); ?> <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> Access Denied </title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> <!-- .style1 { font-size: 16px; font-family: Verdana, Arial, Helvetica, sans-serif; } .style3 { font-size: 12px; font-family: Verdana, Arial, Helvetica, sans-serif; } --> </style> </head> <body> <br/> <br/> <h1 class="style1"> Access Denied </h1> <p class="style3">Your user ID or password is incorrect, or you are not a registered user on this site. To try logging in again, click <a href="<?=$_SERVER['PHP_SELF']?>">here</a>. To access, please contact our Admin !</a>.</p> </body> </html> <?php exit; } $username = mysql_result($result,0,'fullname'); $_SESSION['user'] = mysql_result($result,0,'userid'); ?>
×
×
  • 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.