learningPHP1 Posted September 17, 2012 Share Posted September 17, 2012 Hello everybody, Having problems keeping variables within the same page when the content of the page is saved or when the page is reloads to add the next set of data. The application is a data collecting page so I would need to keep certain variables the same as the same variables needs to appear in the next record. Looking at the code below, 2 variables are received into the page but it won?t stay if I hit the add button basically reloading the page. need the 2 variables returned back after clicking save. <?php echo "<br/>". $TaskId = $_POST['taskid1']; echo "<br/>". $Site = $_POST['site']; ?> <body> <form name="projectwalkthrough" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" > Task ID: <select name="taskid1" > <option value="selectid"> <?PHP if($TaskId) {echo $TaskId;} else {echo "Select Task ID";} ?></option> <?PHP while($row1=mysqli_fetch_array($ProjectIDResults)) { echo '<option value=" ' . $row1['ci_taskid'] . ' ">' . $row1['ci_taskid'] . '</option>'; } ?> </select> Site: <select name="site" > <option value="projectsite" > <?PHP if($Site) {echo $Site;} else {echo "select site";} ?></option> <?PHP while($row=mysqli_fetch_array($ProjectSiteResults)) { echo '<option value=" ' . $row['ps_site_short'] . ' ">' . $row['ps_site_short'] . '</option>'; } ?> </select> <input type="submit" name="savewalkthrough" id="button" value="Save current scope" /> </body> </form> </html> Quote Link to comment https://forums.phpfreaks.com/topic/268472-passing-variables-wtih-in-the-reloading-applicaion/ Share on other sites More sharing options...
Jessica Posted September 17, 2012 Share Posted September 17, 2012 Look into sessions. Quote Link to comment https://forums.phpfreaks.com/topic/268472-passing-variables-wtih-in-the-reloading-applicaion/#findComment-1378672 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.