sheldon_cooper
-
Posts
5 -
Joined
-
Last visited
Posts posted by sheldon_cooper
-
-
Thanks cyberRobot, you are a genius!!! Cannot thank you enough!
Think I might need to go through another few tutorials before I attempt a few pages on my own.
-
You sir, are a genius!! I was banging my head off a brick wall with that one and didn't even think to look at my forms! Thank you again!
Now I just need to figure out a way to fix the if/else isset/empty statements at the bottom so when it displays the 'testingMe' function, it doesn't ask for a username input (second form) at the same time!
-
Hi cyberRobot, thanks for your reply. My forms look like :
<?php include 'connect.php'; ini_set('display_errors',1); ini_set('display_startup_errors',1); error_reporting(-1); function pickacolour(){ ?> <form name="colourlist" method="post" action="<?php print $_SERVER['PHP_SELF'] ?>"> <table border=0> <tr> <td>Select this colour: </td> <?php $colourlist = file("colourlist.txt"); echo '<td><select name="colourname">'; foreach ($colourlist as $list) { echo '<option value="' . $list .'">' .$list. '</option>'; } echo '</select>'; ?> <input type=hidden value=<?php print $_POST['colourForm']; ?> name=colourForm> <td><input type=submit tabindex=1 value="Next" name="colour"></td></tr> </table></form> <?php } // end of pickacolour() function selectUser(){ ?> <form name"enteruser" method="post" action"<?php echo $_SERVER['PHP_SELF'] ?>"> <table border=0> <tr><td>Enter username (Favourite colour being <?php echo "". $_POST['colourname'] ?>) <input type="text" name="user"></td> <input type=hidden value=<?php echo $_POST['colourForm']; ?> name=colourForm> <td><input type=submit tabindex=1 value="Submit" name="resetNOW"></td></tr> <?php } // end of selectUser function testingMe(){ echo "This is a test"; echo "<br>You just entered " . $_POST['user']; echo "<br>You just selected " . $_POST['colourname']; } //end of testingMe ////////////////////////////////// // Main prog // ////////////////////////////////// if (empty($_POST['colourname'])) { pickacolour(); } if (!empty($_POST['colourname'])) { selectUser(); echo "You have selected " . $_POST['colourname']; } if (isset($_POST['resetNOW'])) { if (isset($_POST['resetNOW'])){ testingMe(); echo "<br>You just entered " . $_POST['user']; echo "<br>You just selected " . $_POST['colourname']; } else{ echo "Nothing to see here"; } } ?>
Probably not the most efficient or cleanest code, but I'm still learning!
Thanks for looking
-
HI folks,
Been reading the forums for a while, but this is my first post - what a wealth of knowledge on these boards!
I've been trying to learn PHP and followed a few tutorials, thought I was doing well but have hit some trouble with a page I've been creating. Basically I've created a single page with two forms that take input (one from a list, one from a text box) and those work fine. However when I attempt to read the value of the of the POST variables into the third function to display, it only displays one and I can't figure out why!
I think I've made errors in my if/else statement at the bottom but I've rewrote it a few times and think i'm just getting confused! Here is the code:
if (empty($_POST['colourname'])) { pickacolour(); } if (!empty($_POST['colourname'])) { selectUser(); echo "You have selected " . $_POST['colourname']; } if (isset($_POST['resetNOW'])) { if (isset($_POST['resetNOW'])){ testingMe(); echo "<br>You just entered " . $_POST['user']; echo "<br>You just selected " . $_POST['colourname']; } else{ echo "Nothing to see here"; } }
It gets to the end and prints the 'testingMe' function (which basically just echos to say we made it that far) and the user entered but won't print the colourname, that is always blank. But it does print the colourname when I am selecting a user in the 'selectUser' function - I just can't figure out why it doesn't echo it with the 'testingMe' function and its driving me insane!
Thanks for any help guys
Updating multiple records at once with checkboxes
in PHP Coding Help
Posted
Hi folks,
I'm having a little trouble with a little script that I wrote to try and update dates in a user table. I'm still learning PHP as I go, but this has had me stumped for the past few days!!
Basically, it selects a list of users from a table with their end dates (if they have one) and I should be able to update multiple users at once by entering dates or removing the values, ticking the checkbox and clicking 'Update' but it doesn't work! It either only updates the first record, or gives me multiple errors about '2015 not being a valid day for a date/time column'. If I run the SQL directly into the database, then everything works fine, I have a suspicion that its something to do for my for loop in the updateNow() function.
Can anyone help !?
Can anyone help !? It's driving me crazy!
Cheers!