I am trying to save a $_POST['name'] variable and it works when i hit 'update' but when I logout and log back in I noticed the variable isn't saving...

can someone please assist?

thanks

    When you assign a $POST variable to a $myVariableName php variable, as soon as you go to a page which is controlled by a different file than the one in which the $myVariableName is getting assigned, your php variable and your $POST variable will be null. You can save the data from the $POST variable longer in a $SESSION variable or a cookie.

      well, I was actually just trying to update a css value if the user had this input filled out. if they do, i need the image to update...
      i have something like this:

      [code=php]
         if(isset($_POST['menu_logo'])) {
         ?> 
      	<style type="text/css">#wphead #site_logo .dashboard_link { background:url("<?php echo $_POST['menu_logo']; ?>") no-repeat top left !important; }</style>;
        <?php		
      } [/code]

      again it updates (temporarily) unless you leave the page/logout
      thanks

        fxpepper wrote:

        again it updates (temporarily) unless you leave the page/logout

        Isn't that to be expected? HTML code in that code snippet will only be outputted if there was an element named 'menu_logo' POST'ed to the PHP script.

          okay, so how to get it save the css value then?
          I want this input field

          <input type="text" id="menu_logo" name="menu_logo" />

          to update my css file after the user leaves the page

          thanks

            well there is a few ways i do this.
            1:
            use sessions. (the vars go away if the browser is closed)

            put session_start(); at the top of your page before any code or spaces

            $SESSION["Menu_Logo"]=$POST["menu_logo"];

            you can call it back whenever you want by saying $random_var=$_SESSION["Menu_Logo"]

            Or you could use cookies (goes away when you specify)

            setcookie("Menu_Logo", $_POST["menu_logo"], time()+3600,"",".<site name>.com");

            wich will set a cookie to self destruct in a hr.
            and you can call it by

            $_COOKIE["Menu_Logo"];

            hope i could help you out buddy!

            🙂

              great - I will try the cookie method since I need it to persist unless the user changes the image.

              thank you!! you did help : )

                Write a Reply...