waz Posted June 12, 2007 Share Posted June 12, 2007 how am i surpose to set a variable from the previous page check if its same as before if it is then leave the session variable at same value if not change it to $_post['text'] which is the new value to use . but code doesnt seem to work anyone know why. <php session_start(); if($_SESSION['Test'] <> $_POST['textfield']) { echo $_POST['textfield'] && " is not same as the session which is " && $_SESSION['Test']; }else{ $_SESSION['Test'] = $_POST['textfield']; } ?> its really that simple but i cant seem to get it to remeber also its on a php self form thanks waz Quote Link to comment https://forums.phpfreaks.com/topic/55323-solved-session-variable/ Share on other sites More sharing options...
TreeNode Posted June 12, 2007 Share Posted June 12, 2007 Your logic is wrong. If it's not the same, <>, then set the session variable, otherwise it never reaches the $_SESSION['Test'] = $_POST['textfield']; line... unless of course you enter in nothing for the first time vising the site (without the session variable set already). Quote Link to comment https://forums.phpfreaks.com/topic/55323-solved-session-variable/#findComment-273453 Share on other sites More sharing options...
Wuhtzu Posted June 12, 2007 Share Posted June 12, 2007 I don't know what the &&'s are for, but you should use . (dot) to join strings: $_POST['textfield'] . " is not same... " . $_SESSION['Test']; Quote Link to comment https://forums.phpfreaks.com/topic/55323-solved-session-variable/#findComment-273456 Share on other sites More sharing options...
waz Posted June 12, 2007 Author Share Posted June 12, 2007 when it loads there is a default value in the $_POST['textfield'] Quote Link to comment https://forums.phpfreaks.com/topic/55323-solved-session-variable/#findComment-273462 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.