peddel Posted August 22, 2008 Share Posted August 22, 2008 Ok im gonna try to explain it as detailed as i can, cuz my project has over 50 pages of code with 800- 1000 lines each Ive got a form called PR1.php Inside this form the user gives in tons of values he measured inside the factory. When he filled in all his fields needed, he presses the submit button. What happens then is the following : - a javascript checks if all the fields are filled in - when a true has been returned from the script, page tussenstapPR1.php is loaded. Inside form called tussenstapPR1.php Things that happen here in this order - i get all the values of the submitted fields by using for example : $vf1V = $_POST['vf1V']; - at the same time i ask all the values to be putted inside a session variable by using for example : $_SESSION['vf1V'] = $vf1V; The form continues and now checks trough php and mysql if the entered values in the previous forms are between a top and a bottom value. Code use for this is for example : $sql = "SELECT * FROM tag_grenzen_constanten WHERE tag='OO-PI-001'"; $result = @mysql_query($sql); if(!$result){print("Query mislukt [".mysql_error()."]"."<br />");}; $row = mysql_fetch_array($result); if(!((int)$row['bovengrensOperator'] > (int)$vf1V) || !((int)$row['ondergrensOperator'] < (int)$vf1V)){ print("<tr><td class='hoofdtitel' align='center'>"); print("De waarde die je ingaf voor OO-PI-001 = ".$vf1V." is onmogelijk."); print("</td></tr><tr><td class='kortvak' align='center'>"); print("Gelieve de juiste waarde in te geven en nogmaals te controleren. <input type='text' name='vf1V' size='15' />"); print("</td></tr>"); } U can see every time the value is wrong and not between the top and bottom value, 2 things are done : - a message that value is wrong - a new textfield to enter the value At the end of this form there is a submit button. By clicking it we go to ingediend1.php Inside form called ingediend1.php we first include 2 files named test.php and verwerking1.php <?php include("test.php"); include("verwerking1.php"); ?> We enter the test.php and find this code : session_start(); foreach ($_POST as $fld => $val) { unset($_SESSION['$fld']); $_SESSION['$fld'] = $val; } This code runs trough all the fields of the wrong values in the tussenstapPR1.php It takes the value - drops the existing session variable added to that fieldname (which has been made inside tussenstapPR1 at the beginning - add the new value to a new session variable with the name of the field Now i go to verwerking1.php - here all the session values are taken and put inside a mysql database. MY PROBLEM NOW i know alot to read In my database the value of the changed wrong items is still the wrong value and not the thing i changed it into. So i guess i got a problem with the session variables ... Anyone sees why? Quote Link to comment https://forums.phpfreaks.com/topic/120816-solved-problem-on-passing-on-and-changing-session-variables/ Share on other sites More sharing options...
Lamez Posted August 22, 2008 Share Posted August 22, 2008 lol nice explanation Quote Link to comment https://forums.phpfreaks.com/topic/120816-solved-problem-on-passing-on-and-changing-session-variables/#findComment-622753 Share on other sites More sharing options...
peddel Posted August 22, 2008 Author Share Posted August 22, 2008 lol nice explanation sorry i pressed enter too soon added the text happy reading Quote Link to comment https://forums.phpfreaks.com/topic/120816-solved-problem-on-passing-on-and-changing-session-variables/#findComment-622763 Share on other sites More sharing options...
Lamez Posted August 22, 2008 Share Posted August 22, 2008 how are they wrong values? please post an example! Quote Link to comment https://forums.phpfreaks.com/topic/120816-solved-problem-on-passing-on-and-changing-session-variables/#findComment-622765 Share on other sites More sharing options...
peddel Posted August 22, 2008 Author Share Posted August 22, 2008 how are they wrong values? please post an example! well imagine i first emitted 10 for the variable $vf1V then i do $_SESSION['vf1V'] = $vf1V now immagine the top value = 8 and bottom value = 2 U can see its not between the borders so i ask for new value and enter like 6 but when submitted and all configured, the database still got 10 inside and not the 6 at that position so somewhere my session variable hasnt been changed, tough i did it i suppose Quote Link to comment https://forums.phpfreaks.com/topic/120816-solved-problem-on-passing-on-and-changing-session-variables/#findComment-622767 Share on other sites More sharing options...
marcus Posted August 22, 2008 Share Posted August 22, 2008 You don't see your problem? Look: <?php session_start(); $me = "marcus"; $_SESSION['$me'] = "fail session"; $_SESSION[$me] = "correct session"; print_r($_SESSION); ?> Results: Array ( [$me] => fail session [marcus] => correct session ) Don't use the single quotes when you're defining and unsetting the sessions. Quote Link to comment https://forums.phpfreaks.com/topic/120816-solved-problem-on-passing-on-and-changing-session-variables/#findComment-622769 Share on other sites More sharing options...
peddel Posted August 22, 2008 Author Share Posted August 22, 2008 Man thank u for the help Its just when ur making that much code, ive been programming for 3 weeks now ... It sometimes is hard to find those easy mistakes. But indeed i need the name written in the variable and not the $fld as name This helped me out ! thx for ur help and time Quote Link to comment https://forums.phpfreaks.com/topic/120816-solved-problem-on-passing-on-and-changing-session-variables/#findComment-622778 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.