PHP - Session Values Not Passing To Other Pages
I have a script that was written and tested on another server, but now when I transferred it to the live server, session values are not being passed. I made a couple test pages to check and confirmed that the only issue is the session variables. Here is the test I performed. Please tell me what I'm missing:
page1.php <? session_start(); $_SESSION['var1'] = 'testing'; print_r($_SESSION); ?> Returns: Array ( [var1] => testing ) page2.php <? session_start(); print_r($_SESSION); ?> Returns: Array () Similar TutorialsIs it correct that in order to pass values from web page to web page that you either have to... 1.) Use a Cookie 2.) Use a Session 3.) Write/Read to a Database Record Debbie Hi guys, I've been going crazy over this and I'm hoping someone can help me. I'm making a website for a friend and I'm stuck on sending the model over to the contact page (from one form to another on a different page using $_POST). Here is the website : www.ipgetter.com/test I have successfully posted the Make variable to the contact us page, but I can't get the model sent over (the select boxes have different names). Example: Code: [Select] <select class="form-dropdown" style="width:150px" id="input_2" name="q2_make"> <option selected="selected" value="Alfa Romeo"> Alfa Romeo </option> <option value="Aston Martin"> Aston Martin </option> <option value="Audi"> Audi </option> <option value="Bently"> Bently </option> <option value="BMW"> BMW </option> <option value="Chevrolet"> Chevrolet </option> <option value="Chrysler"> Chrysler </option> <option value="Citroen"> Citroen </option> <option value="Ferrari"> Ferrari </option> <option value="Fiat"> Fiat </option> <option value="Ford"> Ford </option> <option value="Honda"> Honda </option> <option value="Hyundai"> Hyundai </option> <option value="Infiniti"> Infiniti </option> <option value="Isuzi"> Isuzi </option> <option value="Jaguar"> Jaguar </option> <option value="Jeep"> Jeep </option> <option value="Kia"> Kia </option> <option value="Lamborghini"> Lamborghini </option> <option value="Land Rover"> Land Rover </option> <option value="Lexus"> Lexus </option> <option value="Lotus"> Lotus </option> <option value="Maserati"> Maserati </option> <option value="Mazda"> Mazda </option> <option value="Mclaren"> Mclaren </option> <option value="Mercedes-Benz"> Mercedes-Benz </option> <option value="MG"> MG </option> <option value="Mini"> Mini </option> <option value="Mitsubishi"> Mitsubishi </option> <option value="Nissan"> Nissan </option> <option value="Peugeot"> Peugeot </option> <option value="Porsche"> Porsche </option> <option value="Renault"> Renault </option> <option value="Rolls-Royce"> Rolls-Royce </option> <option value="Seat"> Seat </option> <option value="Skoda"> Skoda </option> <option value="Smart"> Smart </option> <option value="Ssangyong"> Ssangyong </option> <option value="Subaru"> Subaru </option> <option value="Suzuki"> Suzuki </option> <option value="Toyota"> Toyota </option> <option value="Vauxhall"> Vauxhall </option> <option value="Volkswagen"> Volkswagen </option> <option value="Volvo"> Volvo </option> <option value="Other"> Other </option> </select> That's the make, as for the model, the select boxes have different names so how am I supposed to capture the users selection and POST it? Code: [Select] <li class="form-line" id="id_3"> <label id="label_3" for="input_3"></label> <div id="cid_3" class="form-input"> <select class="form-dropdown" style="width:150px" id="input_3" name="q3_model"> <option selected="selected" value="147"> 147 </option> <option value="159"> 159 </option> <option value="8C"> 8C </option> <option value="Breva"> Breva </option> <option value="Giulietta"> Giulietta </option> <option value="Mito"> Mito </option> <option value="Other"> Other </option> </select> </div> </li> <li class="form-line" id="id_4"> <label id="label_4" for="input_4"></label> <div id="cid_4" class="form-input"> <select class="form-dropdown" style="width:150px" id="input_4" name="q4_model4"> <option selected="selected" value="Cygnet"> Cygnet </option> <option value="DB9"> DB9 </option> <option value="DBS"> DBS </option> <option value="Rapide"> Rapide </option> <option value="Vantage"> Vantage </option> <option value="Virage"> Virage </option> <option value="Other"> Other </option> </select> </div> </li> I want to post only the selected make/model depending on the user selection. So my question is, how can I send the users chosen model selection over to the contact page form where there is more than one different select box? These select boxes are conditional so when you select "other" as make or model make/model, you may type one in. I'd like to send that also. Any help is appreciated guys, thanks so much. I have the registration form blues! form 1 collects the classes chosen, and passes an array of classes chosen(on a previous page), in a hidden field: <input type="hidden" value="<?= $c_row['workshop_id'] ?>" name="wid[]" /> form 2 makes it a variable $wid = $_POST['wid']; I'm trying to pass it to form 3, using the hidden input again, this time as a variable: $wid = $_POST['wid']; <input type="hidden" value="<?= $wid ?>" name="wid[]" /> The next page is a printable page. But I can't do anything with the classes, because it's some how made an array of an array??? I wrote: $wid = $_POST['wid']; print_r($wid); This produces--- Array ( => Array ) I want it to give me the original array? Is there a different way to do this? Hi there,
I want to pass a input variable from login_success.php which will be sent to sqlprocess.php as the variable 'SQLinput';
sqlprocess.php
$link = mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $query = $_REQUEST['SQLinput']; //You don't need a ; like you do in SQL $result = mysql_query($query); $numfields = mysql_num_fields($result);login_sucess.php <form action="" method="post" <label> <span>SQL Input :</span> <input type ="text" id="message" name="SQLinput" placeholder="Input SQL"></textarea> </label> <label> <span>SQL Output :</span> <output id="text" id="SQLoutput" ></input> <script type="text/javascript" charset="utf-8"> // handles the click event for link 1, sends the query function getOutput() { getRequest( 'sqlprocess.php', // URL for the PHP file drawOutput, // handle successful request drawError // handle error ); return false; } // handles drawing an error message function drawError () { var container = document.getElementById('output'); container.innerHTML = 'Bummer: there was an error!'; } // handles the response, adds the html function drawOutput(responseText) { var container = document.getElementById('output'); container.innerHTML = responseText; } // helper function for cross-browser request object function getRequest(url, success, error) { var req = false; try{ // most browsers req = new XMLHttpRequest(); } catch (e){ // IE try{ req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { // try an older version try{ req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ return false; } } } if (!req) return false; if (typeof success != 'function') success = function () {}; if (typeof error!= 'function') error = function () {}; req.onreadystatechange = function(){ if(req .readyState == 4){ return req.status === 200 ? success(req.responseText) : error(req.status) ; } } req.open("GET", url, true); req.send(null); return req; } </script> <a href="#" onclick="return getOutput();"><button type="submit" id="search_btn" value="Submit">Submit</button> </a> <div id="output">waiting for action</div>Prior to the JS code - I was able to peform this action - however the JS code enables me to post the query onto the same page. I would like essentially like to query the database through an input box and output the same result on the same page. Thanks! i am making a website and some part of which is to show user information...for this i had make a class and functions within it...one of the function is for retrieving values from database(im using mysql)...i know a variable is limited only in function,also tried $_session for this too..the function works fine ....but it is not sendind the information to the page from where im calling it...here is my code..... in xyz.php file <?php class book{ public $v1; public $v2; public $v3; function book(){ } function page1(){ $this->con=mysql_connect("localhost","root","usa"); $this->db=mysql_select_db("truth",$this->con); } function page2($xyz){ $this->page1(); $query="SELECT * FROM member_signup WHERE Uid=$xyz"; $result=mysql_query($query,$this->con); $result1=mysql_fetch_array($result); $_SESSION['info']=$result1; return $_SESSION['info']; return $result1; } }?> in show.php file <? require_once("xyz.php"); $pen = new book; if($pen->page2(100011)) { session_start(); if (mysql_error()) { print "Database ERROR: " . mysql_error(); } else{ echo "cows"; echo "<br>cows<br>"; echo "my name is'".$_SESSION['info']."'"; echo "my name is'".$_SESSION['FIRST_NAME']."'"; //i have a fied is db named FIRST_NAME } } else{echo "happy";} ?> http://kansasoutlawwrestling.com/bio?username=wonder <?php if(isset($_GET['username']) && $_GET['username'] != ''){ $username = $_GET['username']; $query = "SELECT bio.username AS username, ebw.manager_id AS managerid, ebw.finisher AS finisher, ebw.setup AS setup, ebw.music AS music, ebw.nicknames AS nicknames, bio.id AS id, bio.posername AS posername, bio.charactername AS charname, bio.style_id AS style, bio.status_id AS status FROM `efed_bio` AS bio LEFT JOIN `efed_bio_wrestling` AS ebw ON bio.id = ebw.bio_id WHERE bio.username = '$username'"; if(!$result = mysql_query($query)){ debug($query); } while ($row = mysql_fetch_assoc($result)){ $fieldarray=array('id','username','posername','charname','style','managerid','finisher','setup','music','nicknames'); foreach ($fieldarray as $fieldlabel){ if (isset($row[$fieldlabel])){ $$fieldlabel=$row[$fieldlabel]; $$fieldlabel=cleanquerydata($$fieldlabel); } } } $query2 = "SELECT * FROM `efed_bio_quotes` WHERE bio_id = '$id'"; if(!$result2 = mysql_query($query2)){ debug($query2); } $i = 0; $quotes = array(); while($row2 = mysql_fetch_assoc($result2)){ $fieldarray=array('quote'); $quotes[$i] = $row2['quote']; $i++; } if($managerid != ''){ $query = "SELECT * FROM `efed_bio` WHERE id = '$managerid'"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); $manager = $row['charactername']; } else{ $manager = 'None'; } switch($style){ case 2: //tag team query break; case 3: $query3 = "SELECT * FROM `efed_bio_manager` WHERE bio_id = '$id'"; if(!$result3 = mysql_query($query3)){ debug($query3); } while ($row3 = mysql_fetch_assoc($result3)){ $height = $row3['height']; $weight = $row3['weight']; $hometown = $row3['hometown']; } break; case 4: $query3 = "SELECT * FROM `efed_bio_referee` WHERE bio_id = '$id'"; if(!$result3 = mysql_query($query3)){ debug($query3); } while ($row3 = mysql_fetch_assoc($result3)){ $height = $row3['height']; $weight = $row3['weight']; $hometown = $row3['hometown']; } break; case 5: $query3 = "SELECT * FROM `efed_bio_staff` WHERE bio_id = '$id'"; if(!$result3 = mysql_query($query3)){ debug($query3); } while ($row3 = mysql_fetch_assoc($result3)){ $height = $row3['height']; $weight = $row3['weight']; $hometown = $row3['hometown']; $job = $row3['job']; } break; case 6: //stable query break; default: $query3 = "SELECT * FROM `efed_bio_singles` WHERE bio_id = '$id'"; if(!$result3 = mysql_query($query3)){ debug($query3); } while ($row3 = mysql_fetch_assoc($result3)){ $height = $row3['height']; $weight = $row3['weight']; $hometown = $row3['hometown']; } break; } $query4 = "SELECT * FROM `efed_bio_history` WHERE bio_id = '$id'"; if(!$result4 = mysql_query($query4)){ debug($query4); } if(mysql_num_rows($result4) == 0){ $kowtitles = ''; $kowawards = ''; } else{ while ($row4 = mysql_fetch_assoc($result4)){ $kowtitles = $row4['kowtitles']; $kowawards = $row4['kowawards']; } } ?> <div id="bio"> <h1><?php echo $charname; ?>'s Biography</h1> <p class="biolinkpages"><a href="http://kansasoutlawwrestling.com/bio?username=$username&page=wrestling">Wrestling</a> | <a href="http://kansasoutlawwrestling.com/bio?username=$username?page=bio">Biography</a> | <a href="http://kansasoutlawwrestling.com/bio?username=$username?page=appearances">Appearances</a> | <a href="http://kansasoutlawwrestling.com/bio?username=$username?page=gallery">Gallery</a></p> <?php if(file_exists('images/fullshots/' . $posername . '.png')){ echo '<img class="fullshot" src="images/fullshots/' . $posername . '.png" />'; } else{ echo '<img class="fullshot" src="images/fullshots/default.png" />'; } ?> <h2>Personal</h2> <?php switch($style){ case 2: ?> <table class="biotable" cellspacing="10px"> <tr class="biotablerowa"> <td class="biotableheadingb">Height:</td> <td class="biotabledatab"><?php echo $height; ?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Weight:</td> <td class="biotabledatab"><?php echo $weight; ?></td> </tr> <tr class="biotablerowa"> <td class="biotableheadingb">Hometown:</td> <td class="biotabledatab"><?php echo $hometown; ?></td> </tr> </table> <?php break; case 3: ?> <table class="biotable" cellspacing="10px"> <tr class="biotablerowa"> <td class="biotableheadingb">Nicknames:</td> <td class="biotabledatab"><?php if (strlen ($nicknames) < 1) { print "N/A"; } else { print "$nicknames";}?></td> </tr> <tr class="biotablerowa"> <td class="biotableheadingb">Height:</td> <td class="biotabledatab"><?php echo $height; ?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Weight:</td> <td class="biotabledatab"><?php echo $weight; ?></td> </tr> <tr class="biotablerowa"> <td class="biotableheadingb">Hometown:</td> <td class="biotabledatab"><?php echo $hometown; ?></td> </tr> </table> <?php break; case 4: ?> <table class="biotable" cellspacing="10px"> <tr class="biotablerowa"> <td class="biotableheadingb">Height:</td> <td class="biotabledatab"><?php echo $height; ?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Weight:</td> <td class="biotabledatab"><?php echo $weight; ?></td> </tr> <tr class="biotablerowa"> <td class="biotableheadingb">Hometown:</td> <td class="biotabledatab"><?php echo $hometown; ?></td> </tr> </table> <?php break; case 5: ?> <table class="biotable" cellspacing="10px"> <tr class="biotablerowa"> <td class="biotableheadingb">Height:</td> <td class="biotabledatab"><?php echo $height; ?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Weight:</td> <td class="biotabledatab"><?php echo $weight; ?></td> </tr> <tr class="biotablerowa"> <td class="biotableheadingb">Hometown:</td> <td class="biotabledatab"><?php echo $hometown; ?></td> </tr> </table> <?php break; case 6: ?> <table class="biotable" cellspacing="10px"> <tr class="biotablerowa"> <td class="biotableheadingb">Height:</td> <td class="biotabledatab"><?php echo $height; ?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Weight:</td> <td class="biotabledatab"><?php echo $weight; ?></td> </tr> <tr class="biotablerowa"> <td class="biotableheadingb">Hometown:</td> <td class="biotabledatab"><?php echo $hometown; ?></td> </tr> </table> <?php break; default: ?> <table class="biotable" cellspacing="10px"> <tr class="biotablerowa"> <td class="biotableheadingb">Nicknames:</td> <td class="biotabledatab"><?php if (strlen ($nicknames) < 1) { print "N/A"; } else { print "$nicknames";}?></td> </tr> <tr class="biotablerowa"> <td class="biotableheadingb">Height:</td> <td class="biotabledatab"><?php echo $height; ?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Weight:</td> <td class="biotabledatab"><?php echo $weight; ?></td> </tr> <tr class="biotablerowa"> <td class="biotableheadingb">Hometown:</td> <td class="biotabledatab"><?php echo $hometown; ?></td> </tr> </table> <?php break; } ?> <h2>History</h2> <?php switch($style){ case 2: ?> <table class="biotable" cellspacing="10px"> <tr class="biotablerowb"> <td class="biotableheadingb">KOW Titles:</td> <td class="biotabledatab"><?php if (strlen ($kowtitles) < 1) { print "N/A"; } else { print "$kowtitles";}?></td> </tr> <tr class="biotablerowa"> <td class="biotableheadingb">KOW Awards:</td> <td class="biotabledatab"><?php if (strlen ($kowawards) < 1) { print "N/A"; } else { print "$kowawards";}?></td> </tr> </table> <?php break; case 3: ?> <table class="biotable" cellspacing="10px"> <tr class="biotablerowa"> <td class="biotableheadingb">KOW Awards:</td> <td class="biotabledatab"><?php if (strlen ($kowawards) < 1) { print "N/A"; } else { print "$kowawards";}?></td> </tr> </table> <?php break; case 4: ?> <table class="biotable" cellspacing="10px"> <tr class="biotablerowa"> <td class="biotableheadingb">KOW Awards:</td> <td class="biotabledatab"><?php if (strlen ($kowawards) < 1) { print "N/A"; } else { print "$kowawards";}?></td> </tr> </table> <?php break; case 5: ?> <table class="biotable" cellspacing="10px"> <tr class="biotablerowa"> <td class="biotableheadingb">KOW Awards:</td> <td class="biotabledatab"><?php if (strlen ($kowawards) < 1) { print "N/A"; } else { print "$kowawards";}?></td> </tr> </table> <?php break; case 6: ?> <table class="biotable" cellspacing="10px"> <tr class="biotablerowb"> <td class="biotableheadingb">KOW Titles:</td> <td class="biotabledatab"><?php if (strlen ($kowtitles) < 1) { print "N/A"; } else { print "$kowtitles";}?></td> </tr> <tr class="biotablerowa"> <td class="biotableheadingb">KOW Awards:</td> <td class="biotabledatab"><?php if (strlen ($kowawards) < 1) { print "N/A"; } else { print "$kowawards";}?></td> </tr> </table> <?php break; default: ?> <table class="biotable" cellspacing="10px"> <tr class="biotablerowb"> <td class="biotableheadingb">KOW Titles:</td> <td class="biotabledatab"><?php if (strlen ($kowtitles) < 1) { print "N/A"; } else { print "$kowtitles";}?></td> </tr> <tr class="biotablerowa"> <td class="biotableheadingb">KOW Awards:</td> <td class="biotabledatab"><?php if (strlen ($kowawards) < 1) { print "N/A"; } else { print "$kowawards";}?></td> </tr> </table> <?php break; } ?> <?php switch($style){ case 2:?> <h2>Quotes</h2> <ul id="quotes"> <?php if(count($quotes) > 0){ for($i = 0; $i < count($quotes); $i++){ echo "<li>".$quotes[$i]."</li>"; } } else{ echo '<li>This tag team has no quotes.</li>'; } ?> </ul> <?php break; case 3:?> <h2>Quotes</h2> <ul id="quotes"> <?php if(count($quotes) > 0){ for($i = 0; $i < count($quotes); $i++){ echo "<li>".$quotes[$i]."</li>"; } } else{ echo '<li>This manager has no quotes.</li>'; } ?> </ul> <?php break; case 4:?> <?php break; case 5:?> <h2>Quotes</h2> <ul id="quotes"> <?php if(count($quotes) > 0){ for($i = 0; $i < count($quotes); $i++){ echo "<li>".$quotes[$i]."</li>"; } } else{ echo '<li>This staffer has no quotes.</li>'; } ?> </ul> <?php break; case 6:?> <h2>Quotes</h2> <ul id="quotes"> <?php if(count($quotes) > 0){ for($i = 0; $i < count($quotes); $i++){ echo "<li>".$quotes[$i]."</li>"; } } else{ echo '<li>This stable has no quotes.</li>'; } ?> </ul> <?php break; default:?> <h2>Quotes</h2> <ul id="quotes"> <?php if(count($quotes) > 0){ for($i = 0; $i < count($quotes); $i++){ echo "<li>".$quotes[$i]."</li>"; } } else{ echo '<li>This wrestler has no quotes.</li>'; } ?> </ul> <?php break; } ?> <?php switch($style){ case 2:?> <h2>Wrestling</h2> <table class="biotable" cellspacing="10px"> <tr class="biotablerowb"> <td class="biotableheadingb">Manager/Valet:</td> <td class="biotabledatab"><?php if (strlen ($manager) < 1) { print "N/A"; } else { print "$manager";}?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Finisher:</td> <td class="biotabledatab"><?php if (strlen ($finisher) < 1) { print "N/A"; } else { print "$finisher";}?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Setup:</td> <td class="biotabledatab"><?php if (strlen ($setup) < 1) { print "N/A"; } else { print "$setup";}?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Entrance Music:</td> <td class="biotabledatab"><?php if (strlen ($music) < 1) { print "N/A"; } else { print "$music";}?></td> </tr> </table> <?php break; case 3:?> <h2>Wrestling</h2> <table class="biotable" cellspacing="10px"> <tr class="biotablerowb"> <td class="biotableheadingb">Manages:</td> <td class="biotabledatab"><?php if (strlen ($manager) < 1) { print "N/A"; } else { print "$manager";}?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Entrance Music:</td> <td class="biotabledatab"><?php if (strlen ($music) < 1) { print "N/A"; } else { print "$music";}?></td> </tr> </table> <?php break; case 4:?> <?php break; case 5:?> <?php break; case 6:?> <h2>Wrestling</h2> <table class="biotable" cellspacing="10px"> <tr class="biotablerowb"> <td class="biotableheadingb">Manager/Valet:</td> <td class="biotabledatab"><?php if (strlen ($manager) < 1) { print "N/A"; } else { print "$manager";}?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Finisher:</td> <td class="biotabledatab"><?php if (strlen ($finisher) < 1) { print "N/A"; } else { print "$finisher";}?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Setup:</td> <td class="biotabledatab"><?php if (strlen ($setup) < 1) { print "N/A"; } else { print "$setup";}?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Entrance Music:</td> <td class="biotabledatab"><?php if (strlen ($music) < 1) { print "N/A"; } else { print "$music";}?></td> </tr> </table> <?php break; default:?> <h2>Wrestling</h2> <table class="biotable" cellspacing="10px"> <tr class="biotablerowb"> <td class="biotableheadingb">Manager/Valet:</td> <td class="biotabledatab"><?php if (strlen ($manager) < 1) { print "N/A"; } else { print "$manager";}?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Finisher:</td> <td class="biotabledatab"><?php if (strlen ($finisher) < 1) { print "N/A"; } else { print "$finisher";}?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Setup:</td> <td class="biotabledatab"><?php if (strlen ($setup) < 1) { print "N/A"; } else { print "$setup";}?></td> </tr> <tr class="biotablerowb"> <td class="biotableheadingb">Entrance Music:</td> <td class="biotabledatab"><?php if (strlen ($music) < 1) { print "N/A"; } else { print "$music";}?></td> </tr> </table> <?php break; } } ?> </div> Hello all! I cannot seem to figure out a way to pass an object from one page to another. Now, my flow may be way off, and if it is, please do advise. I want to have a form for username/password log in. When the submit button is hit, it takes those values, finds the matching user in the database, and returns the user object. We'll call him user_object Now, I want to bring up another page, that allows user_object to enter in additional information (Event details). After it does this, it writes those Event Objects into the database. My problem is: I need the ID Object attached to user_object while inserting the Event Objects into the database. The user_object and Event Objects values are assigned from two separate forms and two separate submit buttons. How do I pass this information? I don't want to use session because I have a lot of objects and do not want to serialize and unserialize all the time. I also read that $_GET is a security risk. Thanks in advance for any help! This is the basic logic of the code I am trying: Code: [Select] <html form whatevs post> <php object_one if (creds_match) { build_object from db } else "Wrong info, dude" ?></endhtml stuffs> Code: [Select] <html form whatevs post> <php object_two if (post!empty) { object_two = poststuff } assign object_two object_one's _id insert object_two into db ?></endhtml stuff> How do I keep the values assigned in section one, and send them or be able to use that same variable in section 2? Hii,
I created a view with few selected data from table. I provided link to title to have redirection on editing page. I am passing variables to dynamic editing page. In editing page, I created a form which is filled automatically using id. Now on submission of updated form I redirected it to another php page for back-end processing. But now I am not getting data of inputs from editing page. POST and GET both are not working. I don't understand why is it not passing values.
Login ► View Data ► Select Data To Update ► Update Is not working here
Edited by Parth_Innovator, 05 December 2014 - 12:57 PM. Hello. Basically I've created a login script. Works great. It sends users to different locations depending on what type of user they are. Now I have also created a Members account. Upon logging in this user should go to the members area. That all works fine! In the login script i stored a few session variable like username, access_level and so on. Now in the members area I am trying to make the page echo the name of the current user. I have been stairing at my code too long and can no longer see why nothing is echo'ing. Any ideas. I thought that the session_start() would continue the session in the next page and throughout the site until the person logs off and runs the session_destroy()! Is this not correct. First ill post the login script <?php include('database.php'); session_start(); if(isset($_POST['submit3'])) { $email = stripslashes($_POST['email3']); $password = stripslashes($_POST['password3']); $email = mysql_real_escape_string($_POST['email3']); $password = md5($password); $CheckUser = "SELECT * FROM Members WHERE email='".$email."' AND password='".$password."'"; $userDetails2 = mysql_query($CheckUser); $userInfo = mysql_fetch_array($userDetails2); $count = mysql_num_rows($userDetails2); if($count != 0) { $_SESSION['username'] = $userInfo['username']; $_SESSION['usertype'] = $userInfo['usertype']; $_SESSION['access_level']= $userInfo['access_level']; if($userInfo['usertype']== 'Member') { header('Location: members/index.php'); } else if($userInfo['usertype'] == 'Owner') { header('Location: owner/index.php'); } else if($userInfo['usertype'] == 'Corporation') { header('Location: corporation/index.php'); } else if($userInfo['usertype'] == 'Administrator') { header('Location: owner/admin/index.php'); } else if($userInfo['usertype'] == 'Staff') { header('Location: owner/staff/index.php'); } } else { $message = "incorrect login details"; } } ?> now ill post the members page <?php include('../database.php'); session_start(); ?> <head> <link href="stylz.css" rel="stylesheet" type="text/css" /> <link href="reset.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="wrapper"> WELCOME TO THE MEMBERS AREA <?php $_SESSION['username']; ?> <?php include('../title.php');?> <?php include('../nav.php');?> <div id="test"></div> <?php include('../footer.php');?> </div> </body> </html> Hi, I have a user/password protected page that displays a list of clients. When clicking on them you're redirected to the client record update page. This is how I am linking to taht page now: Code: [Select] <a href="DIST_clientes_update.php?id_cliente=<?php echo $row_clients_RS['id_cliente']; ?>The problem with this is that the client id is appended to the url and so if the user chnges it will be able to access records from a different user...and I dont want that. So I have created a session: Code: [Select] $_SESSION["idCliente"] = $row_clients_RS['id_cliente'];but how do I pass it to the update page without showing in the url? Thanks I'm building a login page that then redirects to a new page. But it seems the session isn't working. But I don't know much about sessions, so I'm not sure what I might be doing wrong. The login page sets the session with this code: Code: [Select] // Fetch the result - This will tell us whether this user exists $userExists = mysql_fetch_assoc($doQuery); // If user exists log them in if($userExists){ mysql_free_result($doQuery); mysql_close(); // Set the SESSION variables $_SESSION['first_name'] = $userExists['first_name']; $_SESSION['id'] = $userExists['id']; The page that it redirects to is this: Code: [Select] <?php session_start(); if(isset($_SESSION['id'])) { echo "<html><body><p> You are now logged in,{$_SESSION['ID']}.</p>"; } else { echo 'something went wrong'; exit(); } ob_end_flush(); ?> Hello, we got a site running in to different servers, the other one is a sub domain that will be use as internal pages and the other one is external. As of that I need to pass session to see if a user details.
Is there a another secure way to pass session data to other server without storing on the database?
Having some problems with PHP session i currently use cookies to log users in, but i have decided to use php session instead but i can get it to work, it simply dose not pass the variables unless include session id in every single link on my website, can anyone tell me where i am going wrong these are the session setting from php.in session.use_cookies = 1 session.use_only_cookies = 0 session.name = usersesid session.auto_start = 1 session.cookie_lifetime = 0 session.referer_check = 1 session.cache_expire = 180 session.use_trans_sid = 1 I have my php pages set up like this: 1. log in with login.php 2. that sends you to main.php 3. in main.php, there are links to page-a.php, page-b.php, page-c.php, etc. when you type in a password at login.php, it passes your input to main.php. the correct password is hardcoded in main.php. if it matches, a session variable is set, which should be able to be used on page-a.php, page-b.php, page-c.php, etc. to verify that whoever accesses those pages has gone through the login process. if the session variable doesn't match (or null) the user is redirected to the login page. also the session variable is checked (recursively) when accessing main.php, just like the other pages. the problem is, it's as if each page starts over. the session variable does not make it beyond the page that sets it. it should be passed on to the next page but it's not. I used an echo statement in page-a.php to verify and rem'd out the rest of the code. no echo because session value is null, page goes on to load the html. without the code rem'd out it redirects the user to login.php. code: LOGIN.PHP <? session_start(); if(isset($_SESSION['aaa'])) unset($_SESSION['aaa']); ?> <html> <head> <title>title</title> </head> <body> <table width="400" align="center" border="0" bordercolor="#000099" bordercolordark="#000066" bordercolorlight="#6666FF"> <tr bgcolor="#B0C4DE"> <td> <form action="main.php" method="POST"> <p align="center"><strong><font size="2" face="Verdana, Arial, Helvetica, sans-serif" color="#FFFFFF"><br> Password</font></strong> <input name="pwfield" type="password" value size="20" maxlength=20> <input type="submit" value="Login"></p> </form> </td></tr></table> </body></html> MAIN.PHP <? if ($_SESSION['aaa']!="abcdef") { $password="twinkies"; if ($_POST["pwfield"]==$password) $_SESSION['aaa']="abcdef"; // successful login else {header("Location: login.php"); exit();} } ?> <html> <head> <title>title</title> </head> <body> <a href="page-a.php">Page A</a> <a href="page-b.php">Page B</a> <a href="page-c.php">Page C</a> </body></html> PAGE-A.PHP <? echo $_SESSION['aaa']; //if ($_SESSION['aaa']!="abcdef") //header("Location: login.php"); //exit(); ?> <html> <head> <title>title</title> </head> <body> ... Hi, I have built a registration and login system for a website, part of which I wish to protect certain pages. The registration systems works well, as does the login BUT I am having difficulty with the next stage. How do I then 'capture' the username and password that were entered by the user and get the PHP page I want to protect to check that these are valid? I guess it is a piece of code I need to put in the top of the protected page? Here is the final piece of code (which then includes a link to the page I want to protect) from the login page which includes session_register, but then how can I use this information in the page I wish to protect? //Now if everything is correct let's finish his/her/its login session_register("username", $username); session_register("password", $password); echo "Welcome, ".$username." please continue onto our ".$sub." membership area...<a href=".$index.">click here</a>"; } Thanks, Simon Alright, So i want to pass a session from www.mysite.com to mobile.mysite.com And i'm doing so by calling this on the top of every page on each site: <?php session_set_cookie_params(360000, "/",".mysite.com"); session_start(); print_r($_SESSION); ?> yet, the session data that is set on one subdomain is NOT printed on the other subdomain. I've even tried destroying the sessions several times to start over. But it won't work. What could be up? Thanks Hi All, I am using the uploadify script available at http://uploadify.com/ Now I can get the file uploads working fine with the script below: Code: [Select] <?php session_start(); ?> <link href="/uploadify/uploadify.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="/uploadify/jquery-1.3.2.min.js"></script> <script type="text/javascript" src="/uploadify/swfobject.js"></script> <script type="text/javascript" src="/uploadify/jquery.uploadify.v2.1.0.min.js"></script> <input id="fileInput" name="fileInput" type="file" /> <script type="text/javascript">// <![CDATA[ $(document).ready(function() { $('#fileInput').uploadify({ 'uploader' : '/uploadify/uploadify.swf', 'script' : '/uploadify/uploadify.php', 'cancelImg' : '/uploadify/cancel.png', 'auto' : true, 'folder' : '<?php echo $_SESSION['filepath']."/downloads/"; ?>', 'multi' : true }); }); // ]]></script> The problem that I am having is that I also store the mysql connection details in session vars (they change depending on who logs in). I have tried a number of ways of "passing" these session vars to the uploadify.php file which does the grunt work of the uploading, but I can never seem to access them. I obviously dont want to pass them to the uploadify.php script through the js because that will show my credentials in the source code. So, the question is, how can I access these session vars in the called file. I assume its a combination of session_write_end() and session_start() but I havent got the right combination yet. Hi guys,
I am having a problem transferring data between pages, using PHP sessions. I have a HTML SELECT drop-down to let user set the number of posts per page to display. <form method="POST" style="margin:auto;position:relative;width:35%;padding:17px;top:47px;"> <span>select posts-per-page:</span> <select name="ppp"> <option selected disabled>--select ppp--</option> <option value=10>10</option> <option value=15>15</option> <option value=20>20</option> <option value=50>50</option> <option value=100>100</option> </select> <input type="submit" name="submit" value="OK"/> </form> I want to transfer the value selected by user to a session so that I can load the value in other pages. The value of posts per page is carried by variable $ppp; so, file1 contains the code $_SESSION['ppp'] = $ppp; That seems to work great; the system updates correctly the session's value as user submits different numbers of posts-per-page.
The problem is in page2.php: it doesn't update to the new user's selection; I already have a session active in that page so I don't need session_start(). To call the session, I use the line $ppp=$_SESSION['ppp']; When user changes the selection from 50 to 100 posts per age, for example, the value of page1.php changes as expected, but the value transferred to page2.php doesn't change, appears to remain with the default value the page loads with. I don't know if the problem is that I already have a session going. Can you have more than one session running simultaneously in a page? Can anybody help? Thanks in advance!
Sept Most of my website is written in php4. My hosting server has support for both 4 and 5 just by changing file extension. .php which is the default supports 4, .php5 of course supports 5. The problem I am having is that the pages with the .php5 extensions are not recognizing session variables. Is there something I should be doing differently in 5 for my session variables? For example a variable request like this returns 0 print $_SESSION['FULLNAME']; Please Help!! Thank you in advance? |