ikkyopaul Posted July 29, 2011 Share Posted July 29, 2011 This is my first stab at PHP although I do have a history of programming going way back to my college years (in the 80s) so I guess I'll be able to pick things ok. I run a martials arts club and am looking at moving to MySQL and PHP as a better solution to take attendance than the spreadsheet that I'm currently using. Unfortunately I'm getting stuck at the first hurdle, hoping someone can help.... The scripts that I have in mind are: 1.dateSelector.php 2.attendance.php 3.SummaryOfAttendance.php I want the variable $class_date to be carried from script1 through script2 (which works fine) then both values from script2 sent to script3 - this is where I'm getting stuck. in more detail: 1. DateSelector.php input class date $classDate send $classDate to MemberAttendance.php 2. MemberAttendance.php input member's name $memberName Send $classDate and $memberName to 3.SummaryOfAttendance.php Keep looping MemberAttendance.php for each person. I imagine it shouldn't be too complicated but I've tried so many different things over the last few days that it's pretty clear I need some experienced help. My Scripts DateSelector.php <html> <body> <form action="MemberAttendance.php" method="get"> Class Date: <input type="text" name="classDate" /> <input type="submit" /> </form> </body> </html> MemberAttendance.php <html> <body> Class Date: <?php echo $_GET["classDate"]; ?><br /><br /> <form action="SummaryOfAttendance.php" method="get"> Members Name: <input type="text" name="memberName" /><br /> // ** How do I also send $classDate along with the form??<br /> <input type="submit" /> </form> </body> </html> SummaryOfAttendance.php <html> <body> Member Name: <?php echo $_GET["memberName"]; ?><br /> Class Date: <?php echo $_GET["classDate"]; ?><br /> <br /> <a href="MemberAttendance.php">Click here to enter another student</a><br /> <a href="some_other_place.php">or here to go some other place</a><br /> </body> </html> Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted July 29, 2011 Share Posted July 29, 2011 You have a choice: send them in the url and use $_GET[], send them by post again using a hidden field set on the page that is popultaed with your variable data or push them into $_SESSION[] variables. The last one is the comon solution, but you will NEED to include session_start(); at the start of every unique page (i.e. any page that is not called as an include/require). Quote Link to comment Share on other sites More sharing options...
WebStyles Posted July 29, 2011 Share Posted July 29, 2011 I don't wanna start confusing things before you get it working, but this may actually help debugging too. You may want to check the variables just to be sure they were sent and received correctly, with something like this: (that checks if the variable exists and if it's value is not empty) if(isset($_GET["classDate"]) && $_GET["classDate"] != ""){ // do your stuff }else{ echo 'Variable classDate never reached this page'; } Quote Link to comment Share on other sites More sharing options...
ikkyopaul Posted July 29, 2011 Author Share Posted July 29, 2011 I don't wanna start confusing things before you get it working, but this may actually help debugging too. Thanks WebStyles, I like the look of that, I'll keep it for future reference. Quote Link to comment Share on other sites More sharing options...
ikkyopaul Posted July 29, 2011 Author Share Posted July 29, 2011 ... or push them into $_SESSION[] variables. The last one is the comon solution, but you will NEED to include session_start(); at the start of every unique page (i.e. any page that is not called as an include/require). Hi Muddy_Funster. Thanks for your reply. I'm starting to come round to the idea of using sessions, it probably is the best solution. To be honest though I find the prospect daunting, nowhere have I been able to find any examples even remotely similar to my above examples. You say push them into $_SESSION[] variables , how would I go about doing this, is it as simple as entering the data directly from the html form? Quote Link to comment Share on other sites More sharing options...
WebStyles Posted July 29, 2011 Share Posted July 29, 2011 as simple as this: $_SESSION['call_it_what_you_want'] = "GIVE IT SOME VALUE"; (same as any variables but will be available on all your pages) (keep in mind what Muddy_Funster said. you MUST have session_start() on every page you wish to set or get $_SESSION variables. <?php session_start(); $_SESSION['example'] = 'Oh Dear.'; echo $_SESSION['example']; ?> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted July 29, 2011 Share Posted July 29, 2011 I recommend that you change your UI (User Interface). Rather than typing in each name, you should either - A) Have a dropdown select menu that lists all the current names so that you just pick the one you want, or B) Display all the names at once (or use pagination if you have more than you care to display at one time) with a checkbox (or similar) next to each name so that you can simply go through and mark the attendance for all the students at once, rather than repeatedly going through your set of forms for each student. Edit: I would also just do this all on one page. You select the date (using a date picker) and display and enter the attendance on one page. To allow for the possibly of 'editing' existing information, when the date is changed, I would submit the page (processing any newly entered data) and retrieve and display any existing data for the newly selected date. Quote Link to comment 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.