kgb49 Posted October 11, 2009 Share Posted October 11, 2009 hi all, iam doing this php assignment and i need some help. i need to store info of few pages using the Session statements, then show a summery and submit it using sql. here is the fist page, how do i set session statements up? <?php session_start(); ???????????? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Personal Information</title> </head> <body> <h1>Personal Information</h1> <form action="business.php" method="get"> <p>First Name <input type="text" name="fname" /></p> <p>Last Name <input type="text" name="lname" /></p> <p>Email:<input type="text" name="email" /></p> <input name="Submit1" type="submit" value="Continue" /> </body> </html> ~thank you in advance. ~code tags are cool Quote Link to comment https://forums.phpfreaks.com/topic/177351-please-help-for-school/ Share on other sites More sharing options...
Dorky Posted October 11, 2009 Share Posted October 11, 2009 someone else may be able to tell what you are looking to get done here but the lack of description of what information you need to obtain to be placed in the db or things like. is it a page, user info, images, ect.... ill check back later. Quote Link to comment https://forums.phpfreaks.com/topic/177351-please-help-for-school/#findComment-935098 Share on other sites More sharing options...
grissom Posted October 11, 2009 Share Posted October 11, 2009 For your first page, you don't need any PHP, you can use good old HTML. But remember to include a </FORM> statement at the end of your form. Now, the info in your form will be sent off to business.php and this is where the fun begins Start your business.php file off like this : <?php session_start(); $_SESSION['fname'] = $_POST['fname']; $_SESSION['lname'] = $_POST['lname']; $_SESSION['email'] = $_POST['email']; ?> Now you have captured the values in your form into session variables which you can now access as you surf from page to page on your site. just remember to start each php file with session_start(); Quote Link to comment https://forums.phpfreaks.com/topic/177351-please-help-for-school/#findComment-935099 Share on other sites More sharing options...
Dorky Posted October 11, 2009 Share Posted October 11, 2009 ok i didnt look at the form. why are we starting a session on the form page? Quote Link to comment https://forums.phpfreaks.com/topic/177351-please-help-for-school/#findComment-935102 Share on other sites More sharing options...
mikesta707 Posted October 11, 2009 Share Posted October 11, 2009 do you know how post variables work? if so just set the post variable to its corresponding session variable. they are both arrays, so the use is fundamentally the same. you need session_start() at the top of any page that uses the session super global, but something like $_SESSION['fname'] = $_POST['fname']; Quote Link to comment https://forums.phpfreaks.com/topic/177351-please-help-for-school/#findComment-935110 Share on other sites More sharing options...
Dorky Posted October 11, 2009 Share Posted October 11, 2009 yes i do understand post and get and sessions. you do not need session_start until you are ready to call a session. you don't even need it to appoint data to session. i have sites up and running on this information as we speak. Quote Link to comment https://forums.phpfreaks.com/topic/177351-please-help-for-school/#findComment-935114 Share on other sites More sharing options...
kgb49 Posted October 11, 2009 Author Share Posted October 11, 2009 Thank you, i thought that i needed session on every page. ill give it a try, post back later Thank you Quote Link to comment https://forums.phpfreaks.com/topic/177351-please-help-for-school/#findComment-935116 Share on other sites More sharing options...
PFMaBiSmAd Posted October 11, 2009 Share Posted October 11, 2009 You need a session_start() on every page that references or sets a session variable. Quote Link to comment https://forums.phpfreaks.com/topic/177351-please-help-for-school/#findComment-935120 Share on other sites More sharing options...
kgb49 Posted October 11, 2009 Author Share Posted October 11, 2009 how do i display info that is stored in the session? thank you. Quote Link to comment https://forums.phpfreaks.com/topic/177351-please-help-for-school/#findComment-935121 Share on other sites More sharing options...
PFMaBiSmAd Posted October 11, 2009 Share Posted October 11, 2009 how do i display info that is stored in the session? thank you. By echoing it (or printing it, depending on your coding preferences.) kgb49, if you have jumped into trying to use php, a programming language, without first having read a basic php book or at least gone through a comprehensive php tutorial, it is going to take you a very long time to get any piece of code to work and it is going to be extremely frustrating for you and for those trying to help you when you have to be told the basics. Quote Link to comment https://forums.phpfreaks.com/topic/177351-please-help-for-school/#findComment-935127 Share on other sites More sharing options...
kgb49 Posted October 11, 2009 Author Share Posted October 11, 2009 yeah i know i do have some basic php knowledge, and i just need to do this one project and i'll be done with php Quote Link to comment https://forums.phpfreaks.com/topic/177351-please-help-for-school/#findComment-935133 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.