kev wood Posted November 20, 2008 Share Posted November 20, 2008 is it possible to send php variables with hidden forms through two pages. i have a php page which processes some user inputs. i then send these variables to a new page which inserts entries into a mysql db. i am then trying to send these variables to one last page but every time i try i just get could not connect. which tells me the variables are not being sent. Link to comment https://forums.phpfreaks.com/topic/133479-solved-posting-variables-with-hidden-form/ Share on other sites More sharing options...
Garethp Posted November 20, 2008 Share Posted November 20, 2008 Well, best idea is to use $_SESSION. It's a variable that exists accross all pages. You just need to add session_start(); at the top of each page and it is set by $_SESSION['Text'] = "Something"; And is called like $_SESSION['Text'] like any other variable. Think of it as an array that doesn't expire when you leave a page Link to comment https://forums.phpfreaks.com/topic/133479-solved-posting-variables-with-hidden-form/#findComment-694215 Share on other sites More sharing options...
kev wood Posted November 20, 2008 Author Share Posted November 20, 2008 when i try to use the session i get errors coming up so that is the reason behind me trying to get it to work with hidden form. when i am trying to echo out the variable $db i am just getting $db printed on the screen. Link to comment https://forums.phpfreaks.com/topic/133479-solved-posting-variables-with-hidden-form/#findComment-694222 Share on other sites More sharing options...
Garethp Posted November 20, 2008 Share Posted November 20, 2008 Well, yes, you can use a hidden form to pass variables along a page, just make sure the form gets submitted. And it's probably best to address the Session issues... Link to comment https://forums.phpfreaks.com/topic/133479-solved-posting-variables-with-hidden-form/#findComment-694224 Share on other sites More sharing options...
kev wood Posted November 20, 2008 Author Share Posted November 20, 2008 i have already passed them on to one page but when i try to pass them on again from this page it fails it is looking like. it is the db i want to connect to and it is just not working every time i try to echo out the variables i just get the variable name printed on the page. i was under the impression that if the variable held nothing then nothing would be printed out. Link to comment https://forums.phpfreaks.com/topic/133479-solved-posting-variables-with-hidden-form/#findComment-694227 Share on other sites More sharing options...
Garethp Posted November 20, 2008 Share Posted November 20, 2008 Is it echoing it as a string or as a variable? What I mean is, does it view it as your general HTML? Maybe it's not parsing it as a variable? Link to comment https://forums.phpfreaks.com/topic/133479-solved-posting-variables-with-hidden-form/#findComment-694231 Share on other sites More sharing options...
kev wood Posted November 20, 2008 Author Share Posted November 20, 2008 i have sorted that part out now it is connecting to the db but it will not insert my image into the db now. it is storing it on the server but not in the db. it is this section of code that id not working now $run=mysql_query("select max(id) from '$table'"); $lastid = mysql_fetch_row($run); $lastid=$lastid[0]; $sql="UPDATE '$table' SET image= '$consname2' WHERE id= '$lastid'"; $query = mysql_query($sql); Link to comment https://forums.phpfreaks.com/topic/133479-solved-posting-variables-with-hidden-form/#findComment-694248 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.