Jump to content

How To Redirect Back And Reload Session Value


Recommended Posts

Hi all, I have just started learning PHP. I hit into this wall currently where I have a page(main.php) which stores the session value 'name' of the login personnel.On login to main.php, some sql scripts will run and username and some values will be shown on the page. The page also allows user to input some values and on submit, the value will be send to confirm.php to validate. So on confirm.php, I have this small code

 if ($tday < $day){		  		  if($tmth <= $mth){					  echo "Please select a valid Date!!";			  header("Refresh: 3; url=http://localhost/main.php");}		  else{			  $tempDay = cal_days_in_month(0,$mth,$yr);			  $tempTotal = $tday + ($tempDay-$day);			  $calDays = $tempTotal + 1;			  echo "Total Number of Days Taken is ".$calDays;		  }   }

This line

header("Refresh: 3; url=http://localhost/main.php");

will redirect back to the previous page automatically after 3 seconds.but I find that the session value 'name' is not loaded. anyway i can change it to reload the whole main.php? TIABai

Link to post
Share on other sites

i am not sure what do you mean byy raloading whole main.php .did you started session_start() in that page where you want to pull data of session?

Link to post
Share on other sites

Hi, Sorry abt it think I found my problem.

$_SESSION['name'] = $_POST['fname'];

think the page also reloaded this and as fname is empty, the session name is also empty. I put an if statement in front to do a check if fname have value before assigning it to session name and it work. Thanks for the reply.

Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...