html - Pass variables from one file to another in PHP -


i have site in there many users, , there's section editing them. let's call section page 'a.php'. when clicking on page 'a', see list of users registered in site in form of table. then, there's input space entering username want edit, html form method (post), verifies information , if username doesn't exist, error page.

but if does, new page opened, let's call 1 page 'b.php' , see full info, more input spaces in case want change of user values. there's option saving changes (page 'c.php') , option deleting user (page 'd.php).

the problem have right that, since in page 'a.php' send info via form method="post" , later received in page 'b.php', don't know how re send pages 'c.php' , 'd.php', since these pages don't receive data form method="post". tried using include function doesn't work, can me please?

here's how i'm sending info page 'a' 'b':

page a:

<form method="post" action="edit_usr.php">     <font size = "5">username: <input type="text" name="username" />     <input type="submit" name="submit" value="edit user" /></font> </form> 

this how page b (edit_usr.php) receives code:

$usr_mod = $_post['username']; 

i assume thing need export variable $usr_mod pages 'c' , 'd', i've looked on page , php manual , could't find anything. can please me? appreciated guys! :)

as comment mentioned, sessions way go here.

  1. at top of edit_usr.php, write session_start();.
  2. at top of page c , page d, write session_start();.
  3. inside edit_usr.php, write $_session['usr_mod'] = $usr_mod;. alternately, can write $_session['usr_mod'] = $_post['username']; , use $_session['usr_mod'] in place of $usr_mod that's matter of preference.
  4. inside page c , page d, use $_session['usr_mod'] access variable.

when user logs out, make sure destroy session.

session_unset(); session_destroy(); 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -