bagpiperdude90 Posted January 26, 2007 Share Posted January 26, 2007 Ok, this is probably fairly simple - but I'm taking my first steps in PHP.Basically, I want to create a form for 12 to 15 people sign up for specific jobs. There are 6 jobs, plus a backup person for each job (so a total of 12 jobs). I want to have a PHP script that will access the MySQL database. There will be a form on an html page that will pass the info to the php page. (I've gotten this far). The form is very basic - it only has:"Enter your name to sign up for a job, and then hit submit.Job 1: [box to enter name] Job 1 Backup: [box to enter name]Job 2: [box to enter name] Job 2 Backup: [box to enter name](4 more lines, for a total of 6 lines)[submit]"Now, there needs to be one page per month. Once somebody enters their name, i want the text input area for that job to disappear and show the persons name, with a little "edit" link, in case they need to remove their name from the list. Obviously null needs to be displayed with a text box, but anything other than null needs to show the contents of the spot in the table.Like I said, I need one of these per month. It would be nice to have it automatically change to the next month's form and erase the database after each month. I don't need any user authentication or anything of the sort - these people are trustworthy and won't be changing each other's entries. Any login or authentication would just complicate the whole process.I know how to communicate and create tables and databases with PHP and MySQL - I just don't have a clue about the rest. I'm reading up on PHP right now, but it would be nice to get this sign up thing ready soon.Thanks for any info, links to tutorials, or encouragement! Link to comment https://forums.phpfreaks.com/topic/35897-sign-up-for-event-form/ Share on other sites More sharing options...
spfoonnewb Posted January 27, 2007 Share Posted January 27, 2007 I got really bored.. and decided to make this, plus I have gotten a lot of help around here lately.They can only fill the backup or job if it is not filled.It will display the job, and backup, (Filled or not) until both are filled. If one of them is filled, it cannot be changed by the user. Once they are both filled, it will dissapear.[code]<?php ob_start(); ?><?php //Connect to database $link = mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); //Get information from database $result = mysql_query("SELECT * FROM test") or die(mysql_error()); //If query is ok, fetch the information, and display it while($row = mysql_fetch_array( $result )) { //Only display information if the job/backup row is empty if (empty($row['job']) || (empty($row['backup']))) { echo "<form action=\"\" method=\"post\">"; echo "Job ".$row['id'].": <br><input type=\"text\" value=\"".$row['job']."\" name=\"job\"><P>"; echo "Backup ".$row['id'].": <br><input type=\"text\" value=\"".$row['backup']."\" name=\"backup\"><P>"; echo "<input type=\"hidden\" name=\"id\" value=\"".$row['id']."\"><P>"; echo "<input type=\"hidden\" name=\"dowhat\" value=\"fill_position\"><P>"; echo "<input type=\"submit\" value=\"Submit\"><P>"; echo "</form>"; } }?><?php $dowhat = $_POST["dowhat"]; $id = $_POST["id"]; $job = $_POST["job"]; $backup = $_POST["backup"]; if (isset($dowhat) && ($dowhat == "fill_position")) { $link = mysql_connect("localhost", "username", "password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); $result = mysql_query("SELECT * FROM test WHERE id = '$id'") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { if(empty($row['job']) && (isset($_POST["job"]) != $row['job'])) { mysql_query("UPDATE test SET job = '$job' WHERE id = '$id'"); header("location:test.php"); } else { //echo "You cannot change or take someone elses postion!"; } if(empty($row['backup']) && (isset($_POST["backup"]) != $row['backup'])) { mysql_query("UPDATE test SET backup = '$backup' WHERE id = '$id'"); header("location:test.php"); } else { //echo "You cannot change or take someone elses postion!"; } } }?>[/code]Query to create the table:[code]CREATE TABLE `test` (`id` VARCHAR( 2000 ) NOT NULL ,`job` VARCHAR( 2000 ) NOT NULL ,`backup` VARCHAR( 2000 ) NOT NULL) ENGINE = MYISAM ;[/code]The query to create the rows:[code]INSERT INTO `test` ( `id` , `job` , `backup` )VALUES ('1', '', ''), ('2', '', ''), ('3', '', ''), ('4', '', ''), ('5', '', ''), ('6', '', '');[/code]You can create a cron or something to delete it montly and run the querys:[code]UPDATE `test` SET `job` = ''UPDATE `test` SET `backup` = ''[/code] Link to comment https://forums.phpfreaks.com/topic/35897-sign-up-for-event-form/#findComment-170247 Share on other sites More sharing options...
bagpiperdude90 Posted January 27, 2007 Author Share Posted January 27, 2007 [quote author=spfoonnewb link=topic=124234.msg514492#msg514492 date=1169859877][/quote] ;D :owow. Talk about a helpful forum.Thanks a ton dude!I'll try it out and see how it goes, and post here once i try it! I'll probably try to re-write it, just so i can learn how you did it. Again, thanks a lot!!! Link to comment https://forums.phpfreaks.com/topic/35897-sign-up-for-event-form/#findComment-170249 Share on other sites More sharing options...
bagpiperdude90 Posted January 27, 2007 Author Share Posted January 27, 2007 ah! that did a clear up a few things. I'm working on writing my own version, changing one or two things, and stuff. Thanks for the help! I'll post the code when I'm done for any suggestions. Link to comment https://forums.phpfreaks.com/topic/35897-sign-up-for-event-form/#findComment-170271 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.