Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/55323-solved-session-variable/
Share on other sites

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).

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.