PHP - $_session['rows'] Unsetting Upon Submit...
Driving myself nuts...can't figure out what is wrong with this code. This is part of a pagination system that uses an array instead of hitting the db each time. I am using CodeLobster PHP version (3.7), Windows 7, and using a virtual server on my computer for development (XAMPP)
the error I get is this: Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\website\searchinv.php on line 45 Warning: array_multisort() function.array-multisort: Argument #1 is expected to be an array or a sort flag in C:\xampp\htdocs\website\searchinv.php on line 49 Warning: array_slice() expects parameter 1 to be array, boolean given in C:\xampp\htdocs\website\searchinv.php on line 108 Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\website\searchinv.php on line 146 I am pasting the code below and point out each of the lines in the warnings above, and will try to clean up some so that it's not too extensive... Here is the problem: If I click on any of the "page" $_SESSION['rows'] has all the correct information contained in it. However, if I trigger the "re-sort" select option...$_SESSION['rows'] is empty...all my other $_SESSION variables are still there. At first I thought it was an issue with too many "if/ifelse/else" statements or a wrong syntax...so I changed it to a "switch" and traced it closely. I don't see anything wrong. Next I thought it was caused by the JavaScript "onchange" event...so I took that out...and replaced it with just a submit button...same result. I've done a search on the page for EVERY $_SESSION['rows'] and found only 4 and none of them should blank it out...I've been going crazy on this code for 2 days I'm pulling my hair out now...can ANYONE help? Code: [Select] if(!empty($_POST)) { if(empty($_POST['page'])) { switch($_POST) { case (!empty($_POST['ref'])): $deleted=sql_ending($_POST['del']); $rows=select_from_database('inventory', '*', 'ref_number=\''.$_POST['ref'].'\' and '.$deleted); break; case (!empty($_POST['type'])): $sort=$_POST['sort']; $deleted=sql_ending($_POST['del']); if($_POST['type']!='*') { $type=$_POST['type']; $len=strlen(trim($type)); if($len!=1) $type=$type.'-'; $end=$deleted.' and ref_number like \''.$type.'%\''; } else $end=$deleted; $rows=select_from_database('inventory', '*', $end, $sort); break; default: $data=$_SESSION['rows']; $sorts=explode(' ', $_POST['sort']); $keys=$sorts[0]; $order=$sorts[1]; Line 45 --> foreach ($data as $key => $row) { $column[$key]=$row[$keys]; } Line 49 --> $rows=array_multisort($column, $order, $data); break; } $_SESSION['rows']=$rows; } $x=count($_SESSION['rows']); if(isset($_SESSION['admin_user'])) $width=1280; else $width=900; $srch_rslt= ' <div id="displaybox"> <div id="translucent"></div> <div id="result" style="width:'.$width.'px;"> <!--[if lt IE 7]> <h3 class="center">This site looks much better with IE 7 and above. Please consider upgrading <a href="browsers.php">HERE</a>.</h3> <![endif]--> '; if($x==0) $srch_rslt.=' <h3>Search Result</h3> <a style="display: block; margin-right:10px;" href="searchinv.php" title="Close this box.">Close <img src="images/close.png" alt="Close this box." /></a> <p>We are sorry, but we currently do not have the equipment available for the given search. Please go back and <a href="searchinv.php" title="Search Again">search again</a>, or <a href="mailto:mywebsite@mywebsite.com" title="Send us an email so we can locate the equipment you need." onclick="popup(\'email.php?title=pray\', \'Request for Equipment\', 500, 500); return false">contact us</a> so we may begin to utilze are vast resources to locate your needs. </div> </div> '; else { if(empty($_POST['page'])) $pg=1; else $pg=$_POST['page']; $page=($pg-1)*20; $_SESSION['pages']=ceil($x/20); if(!$_SESSION['pages']>1) $buttons='<button type="button" class="active" title="Page 1">1</button> '; elseif($pg>1) { $prev_pg=$pg-1; $buttons='<button type="submit" class="button" title="First" value="1" name="page"><< First</button> <button type="submit" class="button" title="Previous" value="'.$prev_pg.'" name="page">< Prev</button> '; } for($i=1; $i<=$_SESSION['pages']; $i++) { if($i==$pg) $buttons.=' <button type="button" class="active" title="Page '.$pg.'">'.$pg.'</button> '; else $buttons.=' <button type="submit" class="button" title="Page '.$i.'" value="'.$i.'" name="page">'.$i.'</button> '; } if($pg<$_SESSION['pages']) { $next_pg=$pg+1; $buttons.=' <button type="submit" class="button" title="Next" value="'.$next_pg.'" name="page">Next ></button> <button type="submit" class="button" title="Last" value="'.$_SESSION['pages'].'" name="page">Last >></button> '; } Line 108 --> $results=array_slice($_SESSION['rows'], $page, 20, true); $srch_rslt.=' <h3>Search Complete!</h3> <a class="close" href="searchinv.php" title="Close this box.">Close <img style="border:none;" src="images/close.png" alt="Close this box." /></a> <p>You may now browse, re-sort and download your results in either PDF or an Excel format.</p> '; if (isset($_SESSION['admin_user'])) $table = 1260; else $table = 880; $tableinner = $table-20; $srch_rslt.=' <form name="search_page" method="post" action="searchinv.php?search='.$_POST['search'].'"> <div style="border:2px solid #00000; width:'.$table.'px;"> /* there's a table here */ '; $y=0; Line 146 --> foreach($results as $result) { $y++; $cl_type=explode('-', $result['ref_number']); $type=select_from_database('car_types', '*', 'abbvr=\''.$cl_type[0].'\''); $raw_notes=$result['notes']; if ($raw_notes == NULL) $notes="Call for additional information."; elseif (strlen($raw_notes) >65) { $txtlth=strpos($raw_notes, " ", 65); $notes=substr($raw_notes, 0, $txtlth).'<span id="para'.$pg.$y.'" class="jshide"> '.substr($raw_notes, $txtlth).'</span><a class="jsunhide" href="javascript:function(){};" onclick="toggleMe(\'para'.$pg.$y.'\', \'href'.$pg.$y.'\')" id="href'.$pg.$y.'" style="text-decoration: none">...[click for more]</a>'; } else $notes=$raw_notes; $srch_rslt.=' /*just some html output stuff */ $srch_rslt.=' </table> </div> <div> <input type="hidden" name="search" value="'.$_POST['search'].'" /> <p class="center"> '.$buttons.' </p> </div> </td> </tr> </table> </div> </form> <div class="search_menu_wrapper"> <ul class="sermenu"> <li>Need to search again? Back to the <a href="searchinv.php" title="Do another search.">search page</a>.</li> <li>Download this search to a <a href="http://www.mywebsitedowloadpdf.php?search='.$_POST['search'].'" title="Download to .pdf.">.pdf <img src="images/adobe.png" style="width:15px; height:15px; border:none;" alt="Download in Adobe PDF format." /></a></li> <li>Download this search to a <a href="http://www.mywebsitedowloadexcel.php?search='.$_POST['search'].'" title="Download to MS Excel.">MS Excel <img src="images/excel.png" style="width:15px; height:15px; border:none;" alt="Download in MS Excel format." /></a></li> </ul> </div> Like I said if I click a "page" button (stored in the $buttons var and printed above)...the code works beautifully...it's when the next lines (below) are triggered that cause $_SESSION['rows'] to be empty...I just don't get it Code: [Select] <div style="text-align:center;"> <form name="re_sort" method="post" action="searchinv.php?search='.$_POST['search'].'"> <label class="form-label-left" id="l_sort" for="sort">Re-Sort By:</label> <div class="form-input"> <select class="form-dropdown" style="width:190px" id="sort" name="sort" onchange="this.form.submit();"> <option value="ref_number SORT_ASC" selected="selected"> Reference Number - Ascending </option> <option value="ref_number SORT_DESC"> Reference Number - Descending </option> <option value="date_added SORT_ASC"> Date Added - Ascending </option> <option value="date_added SORT_DESC"> Date Added - Descending </option> <option value="last_update SORT_ASC"> Date Updated - Ascending </option> <option value="last_update SORT_DESC"> Date Updated - Descending </option> '; if($_SESSION['admin'] == 10) $srch_rslt.=' <option value="source SORT_ASC"> Source - Ascending </option> <option value="source SORT_DESC"> Source - Descending </option> '; $srch_rslt.=' </select><button type="submit" value="submit">Submit</button> </div> </form> </div> </div> </div> <script type="text/javascript" language="javascript"> //<![CDATA[ document.body.style.overflow="hidden"; //]]> </script> '; } } echo $srch_rslt; Similar TutorialsHello everyone, I am working on a form that is similar to a shopping cart system and I am thinking of creating a button that submits the checked value and saves them to a $_SESSION variable. And also a link that links to a cart.html that takes the values of a $_SESSION variable. I am have trouble figuring what tag/attribute should I use in order to achieve that.
Right now my code attached below submits the checked values to cart.html directly. However I want my submit button to save the checked box to a $_SESSION variable and STAY on the same page. And then I will implement a <a> to link to the cart.php.
I researched a little bit about this subject and I know it's somewhat related to ajax/jquery. I just wanted to know more about it from you guys. I appreciate your attention for reading the post and Thanks!
Below is the form that I currently have:
<form name= "finalForm" method="POST" action="cart.php"> <input type="Submit" name="finalSelected"/> <?php foreach($FinalName as $key => $item) {?> <tr> <td><input type="checkbox" name="fSelected[]" value="<?php echo htmlspecialchars($FinalID[$key])?>" /> <?php echo "$FinalID[$key] & $item";?> </td> </tr> <?php } ;?>Below is the code for cart.php <?php require ('connect_db.php'); if(isset($_POST['finalSelected'])) { if(!empty($_POST['fSelected'])) { $chosen = $_POST['fSelected']; foreach ($chosen as $item) echo "aID selected: $item </br>"; $delimit = implode(", ", $chosen); print_r($delimit); } } if(isset($delimit)) { $cartSQL = "SELECT * from article where aID in ($delimit)"; $cartQuery = mysqli_query($dbc, $cartSQL) or die (mysqli_error($dbc)); while($row = mysqli_fetch_array($cartQuery, MYSQLI_BOTH)) { $aTitle[] = $row[ 'name' ]; } } ?> <table> <?php if(isset($delimit)) { $c=0; foreach($aTitle as $item) {?> <tr> <td> <?php echo $aTitle[$c]; $c++;?> </td> </tr> <?php }}?> </table> Only the last row will update when I submit. I have this form (and one nerve left): <form action="" method="post" > echo" <input style=\"text-align:center\" type=\"text\" name=\"linkorder\" value=\"".$row['order']."\" /> <input type=\"hidden\" name=\"id\" value=\"".$row['id']."\"/> "; <input type="submit" name="updateorder" value="Save Order" /> </form> On Submit: if (isset($_POST['updateorder'])){ connect(); $changeorder = mysql_unbuffered_query("update links set `order` = '".$_POST['linkorder']."' where id = '".$_POST['id']."'") or die(mysql_error()); } I was going put my fist through the monitor but then I remembered I could get help here. Thank you!
First let me explain my code. This is later included in project_status.php] . In project_status.php] , I have included another file project_status_app.php which contains a HTML form.
<?php include 'inc_fn_header_and_menu.php'; function includeFile($file,$variable) { $var = $variable; include($file); } if (isset($_GET['id']) && $_GET['id']!="") { $pid = $_GET['id']; $_SESSION['pidForApproval'] = $_GET['id']; $query = 'SELECT * FROM `profile` WHERE pid ='.'\''.$pid.'\''; $result=mysqli_query($db,$queryToRetrievePP) or die("There are no records to display ... \n" . mysqli_error()); foreach ($result as $row) { $status = $row['status']; } } ...........some PHP and HTML code....... <div id="customerPurchaseApprovalForm"> <?php echo '<p>APPROVAL FOR CUSTOMER PURCHASE</p>'; $discountApprovalStatus = "Granted"; if ($discountApprovalStatus == "Granted") { includeFile("project_status_app.php",$highestannualvalue); } else { //......... } In project_status_app.php I am attempting to retrieve pidForApproval from the $_SESSION array. <?php // put your code here UPDATE `pp` SET `customer_purchase_remarks` = 'hahaha' WHERE `pp`.`id` = 207; if ($_SERVER['REQUEST_METHOD'] == 'POST') { include '../../inc/fastlogin.php'; $sql = "UPDATE pp SET customer_purchase_remarks ='{$_POST['remarkstxt']}' WHERE pp.pid='{$_SESSION['pidForApproval']}'"; $result = mysqli_query ( $fastdb, $sql ) ; if (mysqli_affected_rows($fastdb) != 1) { $_SESSION['err_cpa_rmks'] = "<p>Error while updating WHERE id='{$_SESSION['pidForApproval']}'</p>"; //echo "<p>Error while updating WHERE id='{$_POST['pidForApproval']}'</p>".mysqli_error($fastdb); } else { $_SESSION['suc_cpa_rmks'] = "<p>Records was updated successfully.</p>"; //echo "Records was updated successfully."; } header ("location: project_status.php?id="$_SESSION['pidForApproval']); exit(); } ?> When I load project_status.php, project_status_app.php is supposed to display the form. Once the user fills in the form the and the submit button has been pressed, the UPDATE statement is supposed to run and then it is supposed to navigate back to project_status.php?id=FA142. But the update is failing and the when the project_status.php is loaded back, the url looks like this http://localhost/fast/project_status.php?id= . The id is empty. It is supposed to be something like this http://localhost/fast/project_status.php?id=FA142. With the id being populated at the header ("location: project_status.php?id=".$_SESSION['pidForApproval']);
Missing some information. Hi All, I'm hoping someone can help me. I'm looking to create a form that will submit multiple entries to a MySQL database depending on the options selected on the form. I am able to submit single entries, but the multiple entire is a bit of a mystery to me. I have attached an JPG image to show an example of how I would like the form to work. I have also added the description/explination below to this example: Example 1 The form was completed and three access types were selected. Thus Three entries, all with the Same Reference number were captured into the database Example 2 The form was completed and Two Access Types were selected. Thus Two entries, all with the Same Reference number were captured into the database Example 3 The form was completed and Four Access Types were selected. Thus Four entries, all with the Same Reference number were captured into the database I have a shopping cart, and I am using a php session to track the basket. All works fine, the only problem I have is completely removing the session once the order is placed. The user places the order, goes through the process and then once complete are sent back to a page called order complete. I have placed the following at the very top of this file: session_start(); session_unset(); session_destroy(); At first it looks as if the session is destroyed, but when I add an item to the basket it pulls up the item I previously ordered. Is the above the correct way? The session is only the sid? I am using session variables to keep track of what is in a shopping cart. I can add the items to the cart quite easily enough. But my problem is that I can't delete a specific item in the cart. Below is a summary of what the array looks like $Item1=array("ProdID"=>"Hat","Color"=>"Not Needed","Size"=>5); $Item4=array("ProdID"=>"Shirt","Color"=>"Green","Size"=>"L"); $Item2=array("ProdID"=>"Pants","Color"=>"Not Needed","Size"=>"32x32"); $Item3=array("ProdID"=>"Socks","Color"=>"Not Needed","Size"=>"Not Needed"); $NumItems=4; $TestArray=array("NumItems"=>$NumItems,1=>$Item1,2=>$Item2,3=>$Item3,4=>$Item4); However when I attempt to delete any of the top level elements (1,2,3,4,NumItems), I either end up deleting only the last element (4) or somehow taking out 2 of them. I know that this must be an easy fix but I've looked at it for so long that I can't seem to figure out what the problem is. below is the code that I use to delete the Item from the array Code: [Select] $ItemNum=$_GET['item']; if ($ItemNum=="All"){ $ItemNum=$_GET['item']; if ($ItemNum=="All"){ unset($TestArray); unset($TestArray['NumItems']); unset($_SESSION['OrderTotal']); //header("Location:Cart.php?act=view"); } else{ $TestArray['NumItems']=$TestArray['NumItems']-1; if($TestArray['NumItems']<1) { unset($_SESSION['OrderTotal']); unset($TestArray); unset($TestArray['NumItems']); } else { unset($TestArray[$ItemNum]); } Can anyone take a look at this and point me in the correct direction? What I am after is to delete any element of the top array and keep the rest. I'm teaching myself a bit of OOP in php. found that i could pass an object into the SESSION array if i serialize() the object and then unserialize() it where i need it in other page files. all seems to work well until it comes time for a user to logout from my application and attempt to destroy the session. at times, when they log back in, this serialized SESSION value seems to still be set while other SESSION values have been cleared. at least i *thinnk* this is what is going on.
in my logout handler, i have the following:
$_SESSION = array(); // clear all SESSION vars setcookie(); // clear cookies session_destroy();but the above does not seem to be working. my guess is there is something native to serialized SESSION values that im not yet aware of. any help here would be much appreciated. so im developing a WEB GAME etc.... etc.... and im including a page that has functions on it in another page if that makes sense....<br> so here's my code tell me why i cant get theese array values to clear? Code: [Select] function unlockables(){ // restore the content $unlockables = array( 'ach'=>array( // achevements unlockables md5(0)=>array('key'=>md5(0),'title'=>'novice','cash'=>'1000', 'exp'=>'100000', 'lvl'=>'20'), md5(1)=>array('key'=>md5(1),'title'=>'rookie','cash'=>'5000', 'exp'=>'150000', 'lvl'=>'40'), md5(2)=>array('key'=>md5(2),'title'=>'pro','cash'=>'10000', 'exp'=>'250000', 'lvl'=>'60'), md5(3)=>array('key'=>md5(3),'title'=>'king','cash'=>'50000', 'exp'=>'500000', 'lvl'=>'80'), md5(4)=>array('key'=>md5(4),'title'=>'Morphelo','cash'=>'100000','exp'=>'1000000','lvl'=>'100'), ), 'levels'=>array( // lvl up md5(5)=>array('key'=>md5(5),'price'=>'1000', 'lvlup'=>'1'), md5(6)=>array('key'=>md5(6),'price'=>'4000', 'lvlup'=>'5'), md5(7)=>array('key'=>md5(7),'price'=>'7500', 'lvlup'=>'10'), md5(8)=>array('key'=>md5(8),'price'=>'15000', 'lvlup'=>'25'), md5(9)=>array('key'=>md5(9),'price'=>'25000', 'lvlup'=>'50') ), 'exp'=>array( // exp up md5(10)=>array('key'=>md5(10),'price'=>'100','expup'=>'500'), md5(11)=>array('key'=>md5(11),'price'=>'1000','expup'=>'6000'), md5(12)=>array('key'=>md5(12),'price'=>'10000','expup'=>'75000'), md5(13)=>array('key'=>md5(13),'price'=>'50000','expup'=>'375000'), md5(14)=>array('key'=>md5(14),'price'=>'100000','expup'=>'750000') ) ); if($_COOKIE['lvl'] >= 0 && $_COOKIE['lvl'] < 20) { // first snakes $status = 'fs'; }elseif($_COOKIE['lvl'] >= 20 && $_COOKIE['lvl'] < 40){ // Novice $status = 'novice'; }elseif($_COOKIE['lvl'] >= 40 && $_COOKIE['lvl'] < 60){ // Rookie $status = 'rook'; }elseif($_COOKIE['lvl'] >= 60 && $_COOKIE['lvl'] < 80){ // pro $status = 'pro'; }elseif($_COOKIE['lvl'] >= 80 && $_COOKIE['lvl'] < 100){ // Novice $status = 'king'; }elseif($_COOKIE['lvl'] >= 100){ // Novice $status = 'morphelo'; } switch($status){ case 'novice': unset( $unlockables['ach'][md5(0)], $unlockables['ach'][md5(2)], $unlockables['ach'][md5(3)], $unlockables['ach'][md5(4)] ); break; case 'rook': unset( $unlockables['ach'][md5(0)], $unlockables['ach'][md5(1)], $unlockables['ach'][md5(3)], $unlockables['ach'][md5(4)] ); break; case 'pro': unset( $unlockables['ach'][md5(0)], $unlockables['ach'][md5(1)], $unlockables['ach'][md5(2)], $unlockables['ach'][md5(4)] ); break; case 'king': unset( $unlockables['ach'][md5(0)], $unlockables['ach'][md5(1)], $unlockables['ach'][md5(2)], $unlockables['ach'][md5(3)] ); break; case 'morphelo': unset($unlockables['ach']); break; } // here is were im trying print to screen but the array is still printing full print_r($unlockables['ach']); } HI, I'm having trouble with unsetting a key from SESSION. I can unset the cart, but when I try to target the key, it doesn't work. Are there some regular things I should be looking for? The only thing I can think of is that I'm re-initializing the key by accident elsewhere in my code. if(isset($_POST['mainCartDelete'])){ unset($_SESSION['cart_array'][21]); $sessionArray = $_SESSION['cart_array']; print_r ($sessionArray); }Print_r returns Array ( [0] => Array ( [item_id] => 21 [quantity] => 1 ) ) Edited by 7blake, 10 December 2014 - 01:43 PM. This topic has been moved to Application Frameworks. http://www.phpfreaks.com/forums/index.php?topic=353397.0 what Im basically trying to do is just like a phpmyadmin function... you select rows you want to update with a checkbox and then it takes you to a page where the rows that are clicked are shown in forms so that you can view and edit info in them... and then have 1 submit button to update them all at once. I have 2 queries that I want to join together to make one row
Say I have an "Entries" table. I want to submit same multiple entries using a form submission. And If I have other queries submitted in the same form, I want those quarries to be submitted only once. Is that possible to do? Here's my code. if(isset($_POST['submit'])) { $entries = 10; $id = 55; $name = 'Smith'; $insert = $db->prepare("INSERT INTO entries(id, name) VALUES(:id, :name)"); $insert->bindParam(':id', $id); $insert->bindParam(':name', $name); $result_insert = $insert->execute(); if($result_insert == false) { echo 'Fail'; } else { echo 'Success'; } } ?> <form action="" method="post"> <input type="submit" name="submit" value="SUBMIT" /> </form> Edited January 13, 2019 by imgrooot Hi. Pretty straight forward I guess but as the name suggests am a newbie. I have a form that requires the user to enter certain parameters. If the values are blank it submits to itself and loads the error messages. What I want to do is create PHP code that submits the form to a different url. What I thought was create two forms (the second with hidden fields replicating the first form), each form having a different url in the action"" code. What I cant work out is the PHP IF ELSE code to submit form 2 if Form1 is is validated correctly. This is the PHP code relevant to the form validation. Help? <?php //If form was submitted if ($_POST['submitted']==1) { $errormsg = ""; //Initialize errors if ($_POST[width]){ $title = $_POST[width]; //If title was entered } else{ $errormsg = "Please enter width"; } if ($_POST[drop]){ $textentry = $_POST[drop]; //If comment was entered } else{ if ($errormsg){ //If there is already an error, add next error $errormsg = $errormsg . " & content"; }else{ $errormsg = "Please enter drop"; } } } if ($errormsg){ //If any errors display them echo "<div class=\"box red\">$errormsg</div>"; } //If all fields present if ($title && $textentry){ //Do something echo 'THIS IS WHERE I WANT THE CODE TO SUBMIT FORM 2 or SUBMIT FORM 1 TO A DIFFERENT URL'; } ?> For the last few hours I have been pulling my hair out on a session not storing when I moved from local host to my vps. I have been setting sessions like: $_SESSION['mydata'] = $variable; This works no problem on my wamp installation. However to get it to work on my vps, I have to store them like this $_SESSION[mydata] = $variable; Can someone please explain to me why this is the case? Hey, i was reading some code and i find this: if(stristr($_SESSION["s"]["user"]["asdasd"]),$someString) How the double/triple [] in $_SESSION works ? PS: I tryied to google it but it was kinda hard to search :X Thanks. edited PHP 5.3.3 I am trying to redirect a user (currently logged in) to a page where they are able to edit a posted comment. To keep things secure I am using a forms hidden input value to pass the {postID} to a redirect page Code: [Select] <form name="post_edit" method="post" action="post-edit-redirect.php" > <input type="hidden" name="local" id="local" value="<?php echo $row_rsPosts['postID']; ?>" /> <input type="image" src="../imgs/managepost.png" name="submit" /> </form> On the redirect page (simplified below) I am setting the {postID} in a SESSION before redirecting to the user to the page to edit their post with the new $_SESSION val for {postID} set. Code: [Select] session_start(); $id = $_REQUEST['local']; $_SESSION['postID']=$id; header("Location: edit-post.php"); This is working fine in every browser except IE (some one please just put an end to it), where when the edit-post.php page is reached the $_SESSION['postID'] is empty. If I regenerate the session ID from the redirect page as below IE then sets the SESSION ok. Code: [Select] session_start(); session_regenerate_id(); $id = $_REQUEST['local']; $_SESSION['postID']=$id; header("Location: edit-post.php"); However there should be no need to do this and would rather not if there is no need. Any help on why IE is not setting the SESSION is appreciated, and I hope I am not covering old ground here however I am unable to find a solution anywhere. - Cheers The $_Session has a url variable. Using a Dom how do I properly do: Code: [Select] html->load($_SESSION['variable']) I was thinking about breaking down the session to retrieve the value inside but I don't know how. Hi i have made a login in system for a website iam trying to make. after you log in im trying to display the members username via the $_session created in the check_login.php. but when i Echo or print_r the $_session all is get is "welcome array" its like its not passing any information via the $_session from page to page. here is my code thanks in advance. Check_login.php session_start(); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=md5($_POST["mypassword"]); // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" $_SESSION["myusername"]==$myusername; $_SESSION["mypassword"]; header("location:login_success.php"); } else { echo "Wrong Username or Password"; } ?> login_success.php <? session_start(); if($_SESSION['myusername']="$myusername"){ header("location:main_login.php"); } Echo "welcome" . $_SESSION['$myusername']; ?> thanks |