Jump to content

KevinM1

Moderators
  • Posts

    5,222
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by KevinM1

  1. Ah, okay, cool. Makes total sense. And yeah, I didn't see that comment about __FILE__ until you just mentioned it. Thanks!
  2. For us novices following along, would you mind explaining the __CLASS__ bit? I sort of see how it works, but the default value in the getInstance() function signature is throwing me off. Also, am I right in guessing you merely left out the bit that deals with the class' path? Or am I missing something obvious? Thanks!
  3. The logic of your form validation is pretty muddled. I believe the best thing to do would be to create a sticky form, which is basically what you're trying to build anyway. This will save you from jumping around between scripts, as well as trimming down the number of times you use the database. If you were to make a sticky form out of what you currently have, it'd probably go a bit like this: <?php function myEscape($string){ //function that helps clean info to be inserted into the database return (get_magic_quotes_gpc()) ? mysql_real_escape_string(stripslashes($string)) : mysql_real_escape_string($string); } $errMessage = NULL; if(isset($_POST['submit'])){ //if the form's been submitted, process the info if(isset($_POST['name'])){ //if a name's been entered, run the db check $checkQuery = "SELECT * FROM wmusers WHERE username = '{$_POST['name']}' LIMIT 1"; $checkResult = mysql_query($checkQuery); if(mysql_num_rows($checkResult)){ //if the name's already been taken (rows >= 1). $errMessage .= "That username has already been taken. Please enter another.<br />\n"; $nameCheck = false; } else{ $name = myEscape($_POST['name']); $nameCheck = true; } else{ //user forgot to enter a username $errMessage .= "Please enter a username.<br />\n"; $nameCheck = false; } if(isset($_POST['password'])){ //was the password set? if(strlen($_POST['password']) < 6)){ //if it's too short $errMessage .= "The password you provided is too short. Please enter a password of at least six characters in length<br />\n"; $passCheck = false; } else{ $password = myEscape($_POST['password']); $passCheck = true; else{ //user forgot to enter a password $errMessage .= "Please enter a password.<br />\n"; $passCheck = false; } if(isset($_POST['email')){ //was the e-mail set? if(preg_match("/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/", $_POST['email'])){ //does it fit the correct pattern? $email = myEscape($_POST['email']); $emailCheck = true; else{ $errMessage .= "Please enter a correctly formed e-mail address (name@host).<br />\n"; $emailCheck = false; } else{ //e-mail not set $errMessage .= "Please enter your e-mail address.<br />\n"; $emailCheck = false; } if($nameCheck && $passCheck && $emailCheck){ //if everything checks out $insertQuery = "INSERT INTO wmusers (username, password, email) VALUES ('$name', '$password', '$email')"; $insertResult = mysql_query($insertQuery); if(mysql_affected_rows($insertResult) == 1){ //only 1 row was inserted header("Location: http://www.somewhereelse.php"); exit(); } else{ //something still went wrong! $errMessage .= "Something went wrong with the registration. Please contact the webmaster.<br />\n"; } } else{ echo "<span style='color: #ff0000;'>$errMessage</span><br />\n"; } } ?> //close PHP to display the form <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> <!-- form inputs go here --> </form>
  4. I don't believe parent classes (in your example, class a) can have knowledge of their child classes (class b). Child classes, however, can have knowledge (properties and methods) of their parent class. So, if you have a super class that is the basis of all your datamap stuff, the child classes will have the same types of properties and methods as those that are either public or protected in the parent class. So: <?php class DataMapper{ protected $dataMap; protected function test(){ print_r($this->dataMap); } } class UniqueMapper extends DataMapper{ public function __construct(){ $this->dataMap = array("a" => "b"); } } class ComplexMapper extends DataMapper{ public function __construct($key, $value){ $this->dataMap = array($key => $value); } } $unique = new UniqueMapper(); $complex = new ComplexMapper("name", "Bubba"); $unique->test(); //prints a => b $complex->test(); //prints name => Bubba ?> In this example, even though all classes have a $dataMap property, it's not the same exact one. Extending a class/using inheritence doesn't copy data. It just tells the child class that part of its mold came from the parent class.
  5. You're running mysql_query twice. You should have: ??php $query = "INSERT INTO....*; $result = mysql_query($query); ?> I'm not sure if that will cure all your problems, but it'll help.
  6. Which version of the script are you using? The original or redarrow's? My proposed fix is intended for the original.
  7. It's a simple problem ... You have: <?php if($orders == '0') ?> You shouldn't be testing against the character '0' -- you need to test against the number 0. '0' is always true in the context you provide. Try: ‹?php if($orders == 0) ?>
  8. Thanks for finding the missing bracket.
  9. This is a continuation of my thread 'Form logic issue' on the PHP Help section of the board. I keep getting an error on line 35, character 2, and for the life of me I can't see it. I'm wondering if it's stemming from a logic error, as only one of the events arrays will be available for the script to grab. If one tries to execute an asignment to elements that aren't on the page, will JavaScript return null/false? Or will it spit out an error? Of course, my error is probably the result of a stupid typo I've made somewhere. Regardless, anyone mind taking a look? As always, here's the code in question. I'll post the PHP script that I use to populate the form's checkboxes, too, so you can see how I'm trying to do things. My JavaScript is part of subheader.php. registration_controller.php: <?php require_once "maincore.php"; require_once "subheader.php"; require_once "side_left.php"; if(!iMEMBER){ fallback(); } if(isset($_POST['edit'])){ //for editing registrations. only 1 registration can be edited at a time if(isset($_POST['events'])){ //MEMBER $event = explode(", ", $_POST['events'][0]); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $query = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $result = dbquery($query); $row = mysql_fetch_assoc($result); header("Location: ". BASEDIR ."registration.php?evid={$row['ev_id']}&regAgent={$row['registering_agent']}&agentWritingNum={$row['agent_writing_number']}&phone={$row['phone']}&email={$row['email']}&regSales={$row['regional_sales_coordinator']}&disSales={$row['district_sales_coordinator']}"); } else if(isset($_POST['personalEvents'])){ //ADMIN $event = explode(", ", $_POST['personalEvents'][0]); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $query = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $result = dbquery($query); $row = mysql_fetch_assoc($result); header("Location: ". BASEDIR ."registration.php?evid={$row['ev_id']}&regAgent={$row['registering_agent']}&agentWritingNum={$row['agent_writing_number']}&phone={$row['phone']}&email={$row['email']}&regSales={$row['regional_sales_coordinator']}&disSales={$row['district_sales_coordinator']}"); } } else if(isset($_POST['delete'])){ //for deleting events. multiple events can be deleted if(isset($_POST['events'])){ //MEMBER's personal registrations foreach($_POST['events'] as $value){ $event = explode(", ", $value); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $deleteTextQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $deleteTextResults[] = dbquery($deleteTextQuery); $deleteAflacQuery = "DELETE FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $deleteLoginsQuery = "DELETE FROM ". DB_PREFIX ."aw_ec_logins WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $deleteAflacResult = dbquery($deleteAflacQuery); $deleteLoginsResult = dbquery($deleteLoginsQuery); } if($deleteAflacResult && $deleteLoginsResult){ $deleteText = "The following registration(s) have been deleted:\n<br />\n<br />\n"; $deleteText .= "<table cellspacing='0'>\n\t<tr>\n\t\t<th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; foreach($deleteTextResults as $queryResult){ while($row = mysql_fetch_assoc($queryResult)){ $deleteText .= "\n\t<tr class='regtbl1'>\n\t\t<td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } } $deleteText .= "\n</table>\n"; echo $deleteText; } } else if(isset($_POST['personalEvents'])){ //ADMIN's personal registrations foreach($_POST['personalEvents'] as $value){ $event = explode(", ", $value); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $deleteTextQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $deleteTextResults[] = dbquery($deleteTextQuery); $deleteAflacQuery = "DELETE FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $deleteLoginsQuery = "DELETE FROM ". DB_PREFIX ."aw_ec_logins WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $deleteAflacResult = dbquery($deleteAflacQuery); $deleteLoginsResult = dbquery($deleteLoginsQuery); } if($deleteAflacResult && $deleteLoginsResult){ $deleteText = "The following registration(s) have been deleted:\n<br />\n<br />\n"; $deleteText .= "<table cellspacing='0'>\n\t<tr>\n\t\t<th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; foreach($deleteTextResults as $queryResult){ while($row = mysql_fetch_assoc($queryResult)){ $deleteText .= "\n\t<tr class='regtbl1'>\n\t\t<td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } } $deleteText .= "\n</table>\n"; echo $deleteText; } } else if(isset($_POST['adminEvents'])){ //ADMIN: ALL possible registrations foreach($_POST['adminEvents'] as $value){ $event = explode(", ", $value); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $deleteTextQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $deleteTextResults[] = dbquery($deleteTextQuery); $deleteAflacQuery = "DELETE FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $deleteLoginsQuery = "DELETE FROM ". DB_PREFIX ."aw_ec_logins WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $deleteAflacResult = dbquery($deleteAflacQuery); $deleteLoginsResult = dbquery($deleteLoginsQuery); } if($deleteAflacResult && $deleteLoginsResult){ $deleteText = "The following registration(s) have been deleted:\n<br />\n<br />\n"; $deleteText .= "<table cellspacing='0'>\n\t<tr>\n\t\t<th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; foreach($deleteTextResults as $queryResult){ while($row = mysql_fetch_assoc($queryResult)){ $deleteText .= "\n\t<tr class='regtbl1'>\n\t\t<td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } } $deleteText .= "\n</table>\n"; echo $deleteText; } } } if(isset($_POST['personalSubmit'])){ //ADMIN's personal registrations if(isset($_POST['personalEvents']) && $_POST['personalEvents'][0] == '*'){ //if ALL personal registrations are selected $personalQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '". $userdata['user_id'] ."'"; $personalResult = dbquery($personalQuery); echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>\n"; echo "<table cellspacing='0'>\n\t<tr>\n\t\t<th></th><th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; $count = 0; while($row = mysql_fetch_assoc($personalResult)){ if($count % 2 == 0){ echo "\n\t<tr class='regtbl1'>\n\t\t<td><input type='checkbox' name='personalEvents[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } else{ echo "\n\t<tr class='regtbl2'>\n\t\t<td><input type='checkbox' name='personalEvents[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } $count++; } echo "</table>\n<input type='submit' name='edit' value='Edit' /><input type='submit' name='delete' value='Delete' />\n</form>"; } else if(isset($_POST['personalEvents']) && $_POST['personalEvents'][0] != ''){ //for singular personal registrations $event = explode(", ", $_POST['personalEvents'][0]); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $personalQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $personalResult = dbquery($personalQuery); echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>\n"; echo "<table cellspacing='0'>\n\t<tr>\n\t\t<th></th><th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; while($row = mysql_fetch_assoc($personalResult)){ echo "\n\t<tr class='regtbl1'>\n\t\t<td><input type='checkbox' name='personalEvents[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } echo "</table>\n<input type='submit' name='edit' value='Edit' /><input type='submit' name='delete' value='Delete' />\n</form>"; } } if(isset($_POST['submit'])){ //non-ADMIN's personal registrations if(isset($_POST['events']) && $_POST['events'][0] == '*'){ //if ALL personal registrations are selected $personalQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '". $userdata['user_id'] ."'"; $personalResult = dbquery($personalQuery); echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>\n"; echo "<table cellspacing='0'>\n\t<tr>\n\t\t<th></th><th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; $count = 0; while($row = mysql_fetch_assoc($personalResult)){ if($count % 2 == 0){ echo "\n\t<tr class='regtbl1'>\n\t\t<td><input type='checkbox' name='events[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } else{ echo "\n\t<tr class='regtbl2'>\n\t\t<td><input type='checkbox' name='events[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } $count++; } echo "</table>\n<input type='submit' name='edit' value='Edit' /><input type='submit' name='delete' value='Delete' />\n</form>"; } else if(isset($_POST['events']) && $_POST['events'][0] != ''){ //for singular personal registrations $event = explode(", ", $_POST['events'][0]); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $personalQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $personalResult = dbquery($personalQuery); echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>\n"; echo "<table cellspacing='0'>\n\t<tr>\n\t\t<th></th><th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; while($row = mysql_fetch_assoc($personalResult)){ echo "\n\t<tr class='regtbl1'>\n\t\t<td><input type='checkbox' name='events[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } echo "</table>\n<input type='submit' name='edit' value='Edit' /><input type='submit' name='delete' value='Delete' />\n</form>"; } } if(isset($_POST['adminSubmit'])){ //ADMIN-only: ALL possible event registrations if(isset($_POST['adminEvents']) && $_POST['adminEvents'][0] == '*'){ //if ALL registrations are selected $adminQuery = "SELECT * FROM ". DB_PREFIX ."aflac"; $adminResult = dbquery($adminQuery); echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>\n"; echo "<table cellspacing='0'>\n\t<tr>\n\t\t<th></th><th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; $count = 0; while($row = mysql_fetch_assoc($adminResult)){ if($count % 2 == 0){ echo "\n\t<tr class='regtbl1'>\n\t\t<td><input type='checkbox' name='adminEvents[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } else{ echo "\n\t<tr class='regtbl2'>\n\t\t<td><input type='checkbox' name='adminEvents[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } $count++; } echo "</table>\n<input type='submit' name='delete' value='Delete' />\n</form>"; } else if(isset($_POST['adminEvents']) && $_POST['adminEvents'][0] != ''){ //for singular registrations $event = explode(", ", $_POST['adminEvents'][0]); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $adminQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $adminResult = dbquery($adminQuery); echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>\n"; echo "<table cellspacing='0'>\n\t<tr>\n\t\t<th></th><th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; while($row = mysql_fetch_assoc($adminResult)){ echo "\n\t<tr class='regtbl1'>\n\t\t<td><input type='checkbox' name='adminEvents[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } echo "</table>\n<input type='submit' name='delete' value='Delete' />\n</form>"; } } require_once "side_right.php"; require_once "footer.php"; ?> regValidate.js (I put in a comment labeling which line is line 35): var W3CDOM = (document.createElement && document.getElementsByTagName); function init(){ if(!W3CDOM) return; var registrationForm = document.getElementById('registrationForm'); registrationForm.onsubmit = validate; } function validate(){ var events = registrationForm['events[]']; var personalEvents = registrationForm['personalEvents[]']; var adminEvents = registrationForm['adminEvents[]']; var eventsResult = false; var personalEventsResult = false; var adminEventsResult = false; var i; if(events){ for(i = 0; i < events.length; i++){ if(events[i].checked){ eventsResult = true; } } if(!eventsResult){ alert('Please select a registration to edit or delete!'); return false; } else{ return true; } else if(personalEvents){ for(i = 0; i < personalEvents.length; i++){ // <-- line 35 if(personalEvents[i].checked){ personalEventsResult = true; } } if(!personalEventsResult){ alert('Please select a registration to edit or delete!'); return false; } else{ return true; } else if(adminEvents){ for(i = 0; i < adminEvents.length; i++){ if(adminEvents[i].checked){ adminEventsResult = true; } } if(!adminEventsResult){ alert('Please select a registration to delete!'); return false; } else{ return true; } } else{ alert('Unforseen error!'); return false; } } window.onload = init; Thanks in advance!
  10. Good idea. It's funny -- I know JavaScript (more or less, anyway), but still tend to avoid it. Must be leftover loathing from the 1990's when seemingly every site had a plethora of frames and JavaScript errors.
  11. Like my last few posts, this is about the custom scripts I've been writing for a PHP-Fusion site. The scripts in question deal with editing and deleting user registrations to events listed in a 3rd party event calendar plugin. One script creates a pulldown list of registrations that the user has submitted previously (two if the user is an administrator -- one for their personal registrations, one for all member registrations). Upon selecting the registration(s) they want, the user is directed to another script, which pulls that/those registration(s) from the database. A checkbox is placed next to each record, allowing the user to select the registration(s) they wish to edit or delete. This works perfectly. My problem is this: figuring what to do if the user clicks on either the 'Edit' or 'Delete' form button when there isn't a checked registration. Right now, the script just displays a blank page (albeit with PHP-Fusion chrome), which isn't very useful. I'd like for it to keep the table of registrations on the screen so the user can select what registration(s) they want to mess with, but I don't see how that's possible without rewriting the script, which I really, really don't want to do unless absolutely necessary. And no, AJAX is not an option as I have yet to learn that technology. Here's the code for the two scripts. registration_viewer.php -- the script that generates the pulldown lists: <?php require_once "maincore.php"; require_once "subheader.php"; require_once "side_left.php"; if(!iMEMBER){ fallback(); } if(iADMIN){ //if ADMIN: two lists, one for the events ADMIN registered to, one for ALL events $personalQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '". $userdata['user_id'] ."'"; $personalResult = dbquery($personalQuery); $adminQuery = "SELECT * FROM ". DB_PREFIX ."aflac"; $adminResult = dbquery($adminQuery); echo "<form method='post' action='registration_controller.php'>\n<br />\n"; echo "Your registrations: <br /><br />\n"; echo "<select name='personalEvents[]'>\n<br />\n"; echo "<option value='*'>All</option>\n<br />\n"; while($row = mysql_fetch_assoc($personalResult)){ echo "<option value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}'>{$row['ev_title']} -- ". date('M j, Y', $row['login_timestamp']) ."</option>\n<br />\n"; } echo "</select>\n"; echo "<input type='submit' name='personalSubmit' value='Go' />\n<br />\n<br /><br /><br /><br />\n"; echo "All registrations: <br /><br />\n"; echo "<select name='adminEvents[]'>\n<br />\n"; echo "<option value='*'>All</option>\n<br />\n"; while($row = mysql_fetch_assoc($adminResult)){ echo "<option value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}'>{$row['registering_agent']}: {$row['ev_title']} -- ". date('M j, Y', $row['login_timestamp']) ."</option>\n<br />\n"; } echo "</select>\n"; echo "<input type='submit' name='adminSubmit' value='Go' />\n<br />\n<br />\n</form>\n"; } if(iMEMBER && !iADMIN){ //if MEMBER && !ADMIN: one list of events MEMBER registered for $query = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '". $userdata['user_id'] ."'"; $result = dbquery($query); echo "<form method='post' action='registration_controller.php'>\n<br />\n"; echo "<select name='events[]'>\n<br />\n"; echo "<option value='*'>All</option>\n<br />\n"; while($row = mysql_fetch_assoc($result)){ echo "<option value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}'>{$row['ev_title']} -- ". date('M j, Y', $row['login_timestamp']) ."</option>\n<br />\n"; } echo "</select>\n"; echo "<input type='submit' name='submit' value='Go' />\n<br />\n</form>\n<br />\n"; } require_once "side_right.php"; require_once "footer.php"; ?> registration_controller.php -- the script that does everything else: <?php require_once "maincore.php"; require_once "subheader.php"; require_once "side_left.php"; if(!iMEMBER){ fallback(); } if(isset($_POST['edit'])){ //for editing registrations. only 1 registration can be edited at a time if(isset($_POST['events'])){ //MEMBER $event = explode(", ", $_POST['events'][0]); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $query = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $result = dbquery($query); $row = mysql_fetch_assoc($result); header("Location: ". BASEDIR ."registration.php?evid={$row['ev_id']}&regAgent={$row['registering_agent']}&agentWritingNum={$row['agent_writing_number']}&phone={$row['phone']}&email={$row['email']}&regSales={$row['regional_sales_coordinator']}&disSales={$row['district_sales_coordinator']}"); } else if(isset($_POST['personalEvents'])){ //ADMIN $event = explode(", ", $_POST['personalEvents'][0]); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $query = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $result = dbquery($query); $row = mysql_fetch_assoc($result); header("Location: ". BASEDIR ."registration.php?evid={$row['ev_id']}&regAgent={$row['registering_agent']}&agentWritingNum={$row['agent_writing_number']}&phone={$row['phone']}&email={$row['email']}&regSales={$row['regional_sales_coordinator']}&disSales={$row['district_sales_coordinator']}"); } } else if(isset($_POST['delete'])){ //for deleting events. multiple events can be deleted if(isset($_POST['events'])){ //MEMBER's personal registrations foreach($_POST['events'] as $value){ $event = explode(", ", $value); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $deleteTextQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $deleteTextResults[] = dbquery($deleteTextQuery); $deleteAflacQuery = "DELETE FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $deleteLoginsQuery = "DELETE FROM ". DB_PREFIX ."aw_ec_logins WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $deleteAflacResult = dbquery($deleteAflacQuery); $deleteLoginsResult = dbquery($deleteLoginsQuery); } if($deleteAflacResult && $deleteLoginsResult){ $deleteText = "The following registration(s) have been deleted:\n<br />\n<br />\n"; $deleteText .= "<table cellspacing='0'>\n\t<tr>\n\t\t<th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; foreach($deleteTextResults as $queryResult){ while($row = mysql_fetch_assoc($queryResult)){ $deleteText .= "\n\t<tr class='regtbl1'>\n\t\t<td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } } $deleteText .= "\n</table>\n"; echo $deleteText; } } else if(isset($_POST['personalEvents'])){ //ADMIN's personal registrations foreach($_POST['personalEvents'] as $value){ $event = explode(", ", $value); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $deleteTextQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $deleteTextResults[] = dbquery($deleteTextQuery); $deleteAflacQuery = "DELETE FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $deleteLoginsQuery = "DELETE FROM ". DB_PREFIX ."aw_ec_logins WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $deleteAflacResult = dbquery($deleteAflacQuery); $deleteLoginsResult = dbquery($deleteLoginsQuery); } if($deleteAflacResult && $deleteLoginsResult){ $deleteText = "The following registration(s) have been deleted:\n<br />\n<br />\n"; $deleteText .= "<table cellspacing='0'>\n\t<tr>\n\t\t<th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; foreach($deleteTextResults as $queryResult){ while($row = mysql_fetch_assoc($queryResult)){ $deleteText .= "\n\t<tr class='regtbl1'>\n\t\t<td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } } $deleteText .= "\n</table>\n"; echo $deleteText; } } else if(isset($_POST['adminEvents'])){ //ADMIN: ALL possible registrations foreach($_POST['adminEvents'] as $value){ $event = explode(", ", $value); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $deleteTextQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $deleteTextResults[] = dbquery($deleteTextQuery); $deleteAflacQuery = "DELETE FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $deleteLoginsQuery = "DELETE FROM ". DB_PREFIX ."aw_ec_logins WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $deleteAflacResult = dbquery($deleteAflacQuery); $deleteLoginsResult = dbquery($deleteLoginsQuery); } if($deleteAflacResult && $deleteLoginsResult){ $deleteText = "The following registration(s) have been deleted:\n<br />\n<br />\n"; $deleteText .= "<table cellspacing='0'>\n\t<tr>\n\t\t<th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; foreach($deleteTextResults as $queryResult){ while($row = mysql_fetch_assoc($queryResult)){ $deleteText .= "\n\t<tr class='regtbl1'>\n\t\t<td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } } $deleteText .= "\n</table>\n"; echo $deleteText; } } } if(isset($_POST['personalSubmit'])){ //ADMIN's personal registrations if(isset($_POST['personalEvents']) && $_POST['personalEvents'][0] == '*'){ //if ALL personal registrations are selected $personalQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '". $userdata['user_id'] ."'"; $personalResult = dbquery($personalQuery); echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>\n"; echo "<table cellspacing='0'>\n\t<tr>\n\t\t<th></th><th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; $count = 0; while($row = mysql_fetch_assoc($personalResult)){ if($count % 2 == 0){ echo "\n\t<tr class='regtbl1'>\n\t\t<td><input type='checkbox' name='personalEvents[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } else{ echo "\n\t<tr class='regtbl2'>\n\t\t<td><input type='checkbox' name='personalEvents[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } $count++; } echo "</table>\n<input type='submit' name='edit' value='Edit' /><input type='submit' name='delete' value='Delete' />\n</form>"; } else if(isset($_POST['personalEvents']) && $_POST['personalEvents'][0] != ''){ //for singular personal registrations $event = explode(", ", $_POST['personalEvents'][0]); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $personalQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $personalResult = dbquery($personalQuery); echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>\n"; echo "<table cellspacing='0'>\n\t<tr>\n\t\t<th></th><th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; while($row = mysql_fetch_assoc($personalResult)){ echo "\n\t<tr class='regtbl1'>\n\t\t<td><input type='checkbox' name='personalEvents[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } echo "</table>\n<input type='submit' name='edit' value='Edit' /><input type='submit' name='delete' value='Delete' />\n</form>"; } } if(isset($_POST['submit'])){ //non-ADMIN's personal registrations if(isset($_POST['events']) && $_POST['events'][0] == '*'){ //if ALL personal registrations are selected $personalQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '". $userdata['user_id'] ."'"; $personalResult = dbquery($personalQuery); echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>\n"; echo "<table cellspacing='0'>\n\t<tr>\n\t\t<th></th><th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; $count = 0; while($row = mysql_fetch_assoc($personalResult)){ if($count % 2 == 0){ echo "\n\t<tr class='regtbl1'>\n\t\t<td><input type='checkbox' name='events[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } else{ echo "\n\t<tr class='regtbl2'>\n\t\t<td><input type='checkbox' name='events[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } $count++; } echo "</table>\n<input type='submit' name='edit' value='Edit' /><input type='submit' name='delete' value='Delete' />\n</form>"; } else if(isset($_POST['events']) && $_POST['events'][0] != ''){ //for singular personal registrations $event = explode(", ", $_POST['events'][0]); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $personalQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $personalResult = dbquery($personalQuery); echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>\n"; echo "<table cellspacing='0'>\n\t<tr>\n\t\t<th></th><th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; while($row = mysql_fetch_assoc($personalResult)){ echo "\n\t<tr class='regtbl1'>\n\t\t<td><input type='checkbox' name='events[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } echo "</table>\n<input type='submit' name='edit' value='Edit' /><input type='submit' name='delete' value='Delete' />\n</form>"; } } if(isset($_POST['adminSubmit'])){ //ADMIN-only: ALL possible event registrations if(isset($_POST['adminEvents']) && $_POST['adminEvents'][0] == '*'){ //if ALL registrations are selected $adminQuery = "SELECT * FROM ". DB_PREFIX ."aflac"; $adminResult = dbquery($adminQuery); echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>\n"; echo "<table cellspacing='0'>\n\t<tr>\n\t\t<th></th><th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; $count = 0; while($row = mysql_fetch_assoc($adminResult)){ if($count % 2 == 0){ echo "\n\t<tr class='regtbl1'>\n\t\t<td><input type='checkbox' name='adminEvents[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } else{ echo "\n\t<tr class='regtbl2'>\n\t\t<td><input type='checkbox' name='adminEvents[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } $count++; } echo "</table>\n<input type='submit' name='delete' value='Delete' />\n</form>"; } else if(isset($_POST['adminEvents']) && $_POST['adminEvents'][0] != ''){ //for singular registrations $event = explode(", ", $_POST['adminEvents'][0]); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $adminQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $adminResult = dbquery($adminQuery); echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>\n"; echo "<table cellspacing='0'>\n\t<tr>\n\t\t<th></th><th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; while($row = mysql_fetch_assoc($adminResult)){ echo "\n\t<tr class='regtbl1'>\n\t\t<td><input type='checkbox' name='adminEvents[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } echo "</table>\n<input type='submit' name='delete' value='Delete' />\n</form>"; } } require_once "side_right.php"; require_once "footer.php"; ?> Any ideas?
  12. Well, the subject basically says it all, but to repeat myself/clarify, are there any resources (either websites or books) for newbies that anyone could recommend regarding the .NET framework? Specifically in ASP.NET or C#? I'm trying to round out my resume and portfolio, and figure I should learn some of the MS stuff. Thanks!
  13. My boss decided that we're going into the auction business, in addition to our generic computing solution stuff (basic web design, computer building and repair, small network building and repair), so I need to help him do research on the different software packages out there that we can use. At this point, the majority of you are probably saying "Just build your own, dimwit." And I agree that we should. Unfortunately, my abilities aren't up to that point yet, and we need to get started on this ASAP. I won't go into details, but it's just not cost effective for us to wait at this point while I research how to construct a site like this from scratch. So, the plan is to use a software package that I can modify and learn from to not only put something online in the immediate future, but to hopefully give me something to learn from so I can build a custom version in the long run. In other words, instead of waiting to learn how to build such an auction site before putting it online, we'll have something up and running 'now' while I learn. So, with all that being said, I have no idea as to what sites are secure and more or less stable. To this point (as we're still in the preliminary planning stages), we've only found AJ Auction software. It seems to meet the requirements, but we'd still like to find a few more options. Yes, we're going to be (and have been) using Google in our search, but I figure that the community here may know of some options that we'll inevitably miss. The requirements that we need to fulfill aren't very limiting: Cost, at this point, isn't much of a concern. It has to be PHP 4+. It has to work on Windows Server 2003. MySQL 4+ would be nice, but not necessary. That's about it. Thanks in advance, guys!
  14. Congrats!
  15. Turns out I already named my submit buttons in the viewer script... d'oh! It's all solved now.
  16. Heh, that's what I get for coding at 7:30 AM. Removing the elseif's almost works perfectly. The only problem is that both the personal event table and admin event table show up if there are events selected in each list... actually, now that I think about it, I should give each submit button on the viewer a different name. That would probably take care of everything. And yes, I'm 'talking' to myself.
  17. This is, of course, related to my PHP-Fusion modifications. I have a script called registration_viewer. It's pretty simple. It generates a pull-down list of the events people registered for. There's a difference in the form if someone is a site administrator or just a normal member, but it's nothing too complicated and works fine. When someone selects an event they registered for (or all of their registered events), the info is passed along to registration_controller where they can edit or delete registrations. My problem is with this second script, specifically when I'm logged in as an administrator. My problem is that the two pulldown lists are interefering with one another. More precisely, no matter what one selects with the bottom list, the value selected in the top list will be the one the administrator gets. I've tried everything I could think of to this point to separate the lists' behaviors, but nothing has worked. Please help. Code is below. registration_viewer.php: <?php /* This will be the file that will allow Rebecca to view/edit event information. Right now, it's pseudo-code. All users should have the ability to view, edit, and delete their registrations (WHERE: ev_id, user_id). VIEW: all/select date (* / WHERE ev_start) EDIT: only one at a time (redirect to registration form, pass info by GET). DELETE: multiple (see store on how to do it). */ require_once "maincore.php"; require_once "subheader.php"; require_once "side_left.php"; /* ADMIN should have the ability to view and delete ALL registrations. ADMIN VIEW: all/select date (* / WHERE ev_start). ADMIN DELETE: multiple (see store on how to do it). */ if(iADMIN){ // Form uses separate script for its action. // Construct personal pulldown from user_id and login_timestamp. // Construct admin pulldown from * and ev_start. // 'Go' submit button for both. $personalQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '". $userdata['user_id'] ."'"; $personalResult = dbquery($personalQuery); $adminQuery = "SELECT * FROM ". DB_PREFIX ."aflac"; $adminResult = dbquery($adminQuery); echo "<form method='post' action='registration_controller.php'>\n<br />\n"; echo "Your registrations: <br /><br />\n"; echo "<select name='personalEvents[]'>\n<br />\n"; echo "<option value=''>--</option>\n<br />\n"; echo "<option value='*'>All</option>\n<br />\n"; while($row = mysql_fetch_assoc($personalResult)){ echo "<option value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}'>{$row['ev_title']} -- ". date('M j, Y', $row['login_timestamp']) ."</option>\n<br />\n"; } echo "</select>\n"; echo "<input type='submit' name='personalSubmit' value='Go' />\n<br />\n<br /><br /><br /><br />\n"; echo "All registrations: <br /><br />\n"; echo "<select name='adminEvents[]'>\n<br />\n"; echo "<option value=''>--</option>\n<br />\n"; echo "<option value='*'>All</option>\n<br />\n"; while($row = mysql_fetch_assoc($adminResult)){ echo "<option value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}'>{$row['registering_agent']}: {$row['ev_title']} -- ". date('M j, Y', $row['login_timestamp']) ."</option>\n<br />\n"; } echo "</select>\n"; echo "<input type='submit' name='adminSubmit' value='Go' />\n<br />\n<br />\n</form>\n"; } /* while(getrow){ //separate script Put checkbox next to each row for deletion. } See store on how to match up arrays (remember their keys). } */ if(iMEMBER && !iADMIN){ // Form uses separate script for its action. // Construct pulldown from user_id and login_timestamp. // 'Go' submit button. $query = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '". $userdata['user_id'] ."'"; $result = dbquery($query); echo "<form method='post' action='registration_controller.php'>\n<br />\n"; echo "<select name='events[]'>\n<br />\n"; echo "<option value=''>--</option>\n<br />\n"; echo "<option value='*'>All</option>\n<br />\n"; while($row = mysql_fetch_assoc($result)){ //check Fusion db stuff echo "<option value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}'>{$row['ev_title']} -- ". date('M j, Y', $row['login_timestamp']) ."</option>\n<br />\n"; } echo "</select>\n"; echo "<input type='submit' name='submit' value='Go' />\n<br />\n</form>\n<br />\n"; } /* while(getrow){ //separate script Put checkbox next to each row for deletion. } TWO BUTTONS: 'Edit' (brings the first registration info back to the registration form) and 'Delete' (deletes all checked rows). } */ require_once "side_right.php"; require_once "footer.php"; ?> registration_controller.php (where the problem lies as it handles what registration_viewer.php sends): <?php require_once "maincore.php"; require_once "subheader.php"; require_once "side_left.php"; if(!iMEMBER){ fallback(); } if(isset($_POST['edit'])){ if(isset($_POST['events'])){ $event = explode(", ", $_POST['events'][0]); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $query = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; $result = dbquery($query); $row = mysql_fetch_assoc($result); // echo "Event ID: {$row['ev_id']}, Registering Agent: {$row['registering_agent']}, Agent Writing Number: {$row['agent_writing_number']}, Phone: {$row['phone']}, E-mail: {$row['email']}, Regional Sales Coordinator: {$row['regional_sales_coordinator']}, District Sales Coordinator: {$row['district_sales_coordinator']}<br /><br />"; header("Location: ". BASEDIR ."registration.php?evid={$row['ev_id']}&regAgent={$row['registering_agent']}&agentWritingNum={$row['agent_writing_number']}&phone={$row['phone']}&email={$row['email']}&regSales={$row['regional_sales_coordinator']}&disSales={$row['district_sales_coordinator']}"); } } if(isset($_POST['personalEvents']) && (!isset($_POST['adminEvents']) || isset($_POST['adminEvents']))){ if($_POST['personalEvents'][0] == '*'){ $personalQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '". $userdata['user_id'] ."'"; echo $personalQuery ."<br /><br />"; $personalResult = dbquery($personalQuery); echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>\n"; echo "<table cellspacing='0'>\n\t<tr>\n\t\t<th></th><th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; $count = 0; while($row = mysql_fetch_assoc($personalResult)){ if($count % 2 == 0){ echo "\n\t<tr class='regtbl1'>\n\t\t<td><input type='checkbox' name='personalEvents[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } else{ echo "\n\t<tr class='regtbl2'>\n\t\t<td><input type='checkbox' name='personalEvents[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } $count++; } echo "</table>\n<input type='submit' name='edit' value='Edit' /><input type='submit' name='delete' value='Delete' />\n</form>"; } else if($_POST['personalEvents'][0] != ''){ $event = explode(", ", $_POST['personalEvents'][0]); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $personalQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; echo $personalQuery ."<br /><br />"; $personalResult = dbquery($personalQuery); echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>\n"; echo "<table cellspacing='0'>\n\t<tr>\n\t\t<th></th><th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; while($row = mysql_fetch_assoc($personalResult)){ echo "\n\t<tr class='regtbl1'>\n\t\t<td><input type='checkbox' name='personalEvents[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } echo "</table>\n<input type='submit' name='edit' value='Edit' /><input type='submit' name='delete' value='Delete' />\n</form>"; } } else if(isset($_POST['events'])){ if($_POST['events'][0] == '*'){ $personalQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '". $userdata['user_id'] ."'"; echo $personalQuery ."<br /><br />"; $personalResult = dbquery($personalQuery); echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>\n"; echo "<table cellspacing='0'>\n\t<tr>\n\t\t<th></th><th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; $count = 0; while($row = mysql_fetch_assoc($personalResult)){ if($count % 2 == 0){ echo "\n\t<tr class='regtbl1'>\n\t\t<td><input type='checkbox' name='events[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } else{ echo "\n\t<tr class='regtbl2'>\n\t\t<td><input type='checkbox' name='events[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } $count++; } echo "</table>\n<input type='submit' name='edit' value='Edit' /><input type='submit' name='delete' value='Delete' />\n</form>"; } else if($_POST['events'][0] != ''){ $event = explode(", ", $_POST['events'][0]); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $personalQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE user_id = '$user_id' AND ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; echo $personalQuery ."<br /><br />"; $personalResult = dbquery($personalQuery); echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>\n"; echo "<table cellspacing='0'>\n\t<tr>\n\t\t<th></th><th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; while($row = mysql_fetch_assoc($personalResult)){ echo "\n\t<tr class='regtbl1'>\n\t\t<td><input type='checkbox' name='events[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } echo "</table>\n<input type='submit' name='edit' value='Edit' /><input type='submit' name='delete' value='Delete' />\n</form>"; } } else if(isset($_POST['adminEvents']) && (!isset($_POST['personalEvents']) || isset($_POST['personalEvents']))){ if($_POST['adminEvents'][0] == '*'){ $adminQuery = "SELECT * FROM ". DB_PREFIX ."aflac"; echo $adminQuery ."<br /><br />"; $adminResult = dbquery($adminQuery); echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>\n"; echo "<table cellspacing='0'>\n\t<tr>\n\t\t<th></th><th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; $count = 0; while($row = mysql_fetch_assoc($adminResult)){ if($count % 2 == 0){ echo "\n\t<tr class='regtbl1'>\n\t\t<td><input type='checkbox' name='adminEvents[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } else{ echo "\n\t<tr class='regtbl2'>\n\t\t<td><input type='checkbox' name='adminEvents[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } $count++; } echo "</table>\n<input type='submit' name='delete' value='Delete' />\n</form>"; } else if($_POST['adminEvents'][0] != ''){ $event = explode(", ", $_POST['adminEvents'][0]); $user_id = $event[0]; $ev_id = $event[1]; $login_timestamp = $event[2]; $adminQuery = "SELECT * FROM ". DB_PREFIX ."aflac WHERE ev_id = '$ev_id' AND login_timestamp = '$login_timestamp'"; echo $adminQuery ."<br /><br />"; $adminResult = dbquery($adminQuery); echo "<form method='post' action='{$_SERVER['PHP_SELF']}'>\n"; echo "<table cellspacing='0'>\n\t<tr>\n\t\t<th></th><th>Registering Agent</th><th>Agent Writing Number</th><th>Phone Number</th><th>E-mail Address</th><th>Regional Sales Coordinator</th><th>District Sales Coordinator</th>\n\t</tr>"; while($row = mysql_fetch_assoc($adminResult)){ echo "\n\t<tr class='regtbl1'>\n\t\t<td><input type='checkbox' name='adminEvents[]' value='{$row['user_id']}, {$row['ev_id']}, {$row['login_timestamp']}' /></td><td>{$row['registering_agent']}</td><td>{$row['agent_writing_number']}</td><td>{$row['phone']}</td><td>{$row['email']}</td><td>{$row['regional_sales_coordinator']}</td><td>{$row['district_sales_coordinator']}</td>\n\t</tr>"; } echo "</table>\n<input type='submit' name='delete' value='Delete' />\n</form>"; } } require_once "side_right.php"; require_once "footer.php"; ?>
  18. When, exactly, do you want the form to display the user submitted info? Because if you have a correct submission (meaning, all info has been entered and entered correctly), at best you'll only display the session value with your current setup.
  19. Source: http://ca.php.net/manual/en/function.mysql-query.php Awesome! That was just what I needed. Thanks a bunch!
  20. Too many versions of my file floating around.... Here's the current version: <?php require_once "maincore.php"; require_once "subheader.php"; require_once "side_left.php"; error_reporting(E_ALL); ini_set('error_display', 'on'); /* function myEscape($string){ return (get_magic_quotes_gpc()) ? mysql_real_escape_string(stripslashes($string)) : mysql_real_escape_string($string); } */ if(file_exists(INFUSIONS."aw_ecal_panel/locale/".$settings['locale'].".php")) { include INFUSIONS."aw_ecal_panel/locale/".$settings['locale'].".php"; } else { include INFUSIONS."aw_ecal_panel/locale/German.php"; } if(!iMEMBER){ fallback(); } if(isset($_GET['evid'])){ $ev = dbquery("SELECT * FROM ".DB_PREFIX."aw_ec_events WHERE ev_id=". $_GET['evid']); $event = dbarray($ev); $ev_id = $event['ev_id']; $user_id = $userdata['user_id']; $ev_title = $event['ev_title']; $ev_start = $event['ev_start']; $ev_end = $event['ev_end']; } $errMessage = NULL; if(isset($_POST['submit'])){ $ev = dbquery("SELECT * FROM ".DB_PREFIX."aw_ec_events WHERE ev_id=". $_POST['evid']); $event = dbarray($ev); $ev_id = $event['ev_id']; $user_id = $userdata['user_id']; $ev_title = $event['ev_title']; $ev_start = $event['ev_start']; $ev_end = $event['ev_end']; if(!empty($_POST['regAgent']) && preg_match("/^[a-zA-Z]+([ a-zA-Z\.-]+)*$/i", $_POST['regAgent'])){ $regAgent = $_POST['regAgent']; //myEscape($_POST['regAgent']); $ra = TRUE; } else{ $errMessage .= "Please enter your name!<br />\n"; } if(!empty($_POST['agentWritingNum']) && preg_match("/^[0-9a-zA-Z]*$/i", $_POST['agentWritingNum'])){ $agentWritingNum = $_POST['agentWritingNum']; //myEscape($_POST['agentWritingNum']); $awn = TRUE; } else{ $errMessage .= "Please enter your writing number!<br />\n"; } if(!empty($_POST['phoneNum'])){ $phoneNum = $_POST['phoneNum']; if(preg_match("/^[0-9]{3}$/i", $phoneNum[0]) && preg_match("/^[0-9]{3}$/i", $phoneNum[1]) && preg_match("/^[0-9]{4}$/i", $phoneNum[2])){ $areaCode = $phoneNum[0]; //myEscape($phoneNum[0]); $firstPart = $phoneNum[1]; //myEscape($phoneNum[1]); $secondPart = $phoneNum[2]; //myEscape($phoneNum[2]); $phoneText = "$areaCode-$firstPart-$secondPart"; $phone = TRUE; } else{ $errMessage .= "Please enter your correct phone number!<br />\n"; } } else{ $errMessage .= "Please enter your phone number!<br />\n"; } if(!empty($_POST['emailAddress']) && preg_match("/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/i", $_POST['emailAddress'])){ $email = $_POST['emailAddress']; //myEscape($_POST['emailAddress']); $e = TRUE; } else{ $errMessage .= "Please enter your e-mail address!<br />\n"; } if(!empty($_POST['regionalSales']) && preg_match("/^[a-zA-Z]+([ a-zA-Z\.-]+)*$/i", $_POST['regionalSales'])){ $regSales = $_POST['regionalSales']; //myEscape($_POST['regionalSales']); $rs = TRUE; } else{ $errMessage .= "Please enter the name of your regional sales coordinator!<br />\n"; } if(!empty($_POST['districtSales']) && preg_match("/^[a-zA-Z]+([ a-zA-Z\.-]+)*$/i", $_POST['districtSales'])){ $disSales = $_POST['districtSales']; //myEscape($_POST['districtSales']); $ds = TRUE; } else{ $errMessage .= "Please enter the name of your district sales coordinator!<br />\n"; } if($ra && $awn && $phone && $email && $rs && $ds){ //start the big process of updating tables and e-mailing results $timestamp = strtotime("now"); echo "SELECT * FROM ".DB_PREFIX."aflac WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'<br /><br />"; $aflacCheck = "SELECT * FROM ".DB_PREFIX."aflac WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'"; $aflacCheckResult = dbquery($aflacCheck); if($aflacCheckResult){ echo "UPDATE ".DB_PREFIX."aflac SET registering_agent='".$regAgent."', agent_writing_number='".$agentWritingNum."', phone='".$phoneText."', email='".$email."', regional_sales_coordinator='".$regSales."', district_sales_coordinator='".$disSales."', ev_title='".$ev_title."', ev_start='".$ev_start."', ev_end='".$ev_end."', login_timestamp='".$timestamp."', login_status='1' WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'<br /><br />"; $aflacQuery = "UPDATE ".DB_PREFIX."aflac SET registering_agent='".$regAgent."', agent_writing_number='".$agentWritingNum."', phone='".$phoneText."', email='".$email."', regional_sales_coordinator='".$regSales."', district_sales_coordinator='".$disSales."', ev_title='".$ev_title."', ev_start='".$ev_start."', ev_end='".$ev_end."', login_timestamp='".$timestamp."', login_status='1' WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'"; $aflacResult = dbquery($aflacQuery); } else{ echo "INSERT INTO ".DB_PREFIX."aflac (registering_agent, agent_writing_number, phone, email, regional_sales_coordinator, district_sales_coordinator, ev_id, user_id, ev_title, ev_start, ev_end, login_timestamp, login_status) VALUES ('". $regAgent ."', '". $agentWritingNum ."', '". $phoneText ."', '". $email ."', '". $regSales ."', '". $disSales ."', '". $ev_id ."', '". $user_id ."', '". $ev_title ."', '". $ev_start ."', '". $ev_end ."', '". $timestamp ."', '1')<br /><br />"; $aflacQuery = "INSERT INTO ".DB_PREFIX."aflac (registering_agent, agent_writing_number, phone, email, regional_sales_coordinator, district_sales_coordinator, ev_id, user_id, ev_title, ev_start, ev_end, login_timestamp, login_status) VALUES ('". $regAgent ."', '". $agentWritingNum ."', '". $phoneText ."', '". $email ."', '". $regSales ."', '". $disSales ."', '". $ev_id ."', '". $user_id ."', '". $ev_title ."', '". $ev_start ."', '". $ev_end ."', '". $timestamp ."', '1')"; $aflacResult = dbquery($aflacQuery); } echo "UPDATE ".DB_PREFIX."aw_ec_events SET ev_allow_logins='1' WHERE ev_id='".$ev_id."'<br /><br />"; $eventQuery = "UPDATE ".DB_PREFIX."aw_ec_events SET ev_allow_logins='1' WHERE ev_id='".$ev_id."'"; $eventResult = dbquery($eventQuery); echo "SELECT * FROM ".DB_PREFIX."aw_ec_logins WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'<br /><br />"; $loginsCheck = "SELECT * FROM ".DB_PREFIX."aw_ec_logins WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'"; $loginsCheckResult = dbquery($loginsCheck); if($loginsCheckResult){ echo "UPDATE ".DB_PREFIX."aw_ec_logins SET login_comment='Definitely Agreed', login_status='1', login_timestamp='".$timestamp."' WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'<br /><br />"; $loginsQuery = "UPDATE ".DB_PREFIX."aw_ec_logins SET login_comment='Definitely Agreed', login_status='1', login_timestamp='".$timestamp."' WHERE ev_id='".$ev_id."' AND user_id='".$user_id."'"; $loginsResult = dbquery($loginsQuery); } else{ echo "INSERT INTO ".DB_PREFIX."aw_ec_logins (ev_id, user_id, login_comment, login_status, login_timestamp) VALUES ('". $ev_id ."', '". $user_id ."', 'Definitely Agreed', '1', '". $timestamp ."')<br /><br />"; $loginsQuery = "INSERT INTO ".DB_PREFIX."aw_ec_logins (ev_id, user_id, login_comment, login_status, login_timestamp) VALUES ('". $ev_id ."', '". $user_id ."', 'Definitely Agreed', '1', '". $timestamp ."')"; $loginsResult = dbquery($loginsQuery); } if($aflacResult && $eventResult && $loginsResult){ $eventTimestamp = strtotime($ev_start); $eventDate = date("m-d-Y h:i:s T", $eventTimestamp); $userName = $userdata['user_name']; $to = "kevinmajor1@gmail.com"; $subject = "Event Registration ($ev_title)"; $mailMessage = "<html>\n<head>\n<title>Event Registration Information</title>\n</head>\n\n<body>"; $mailMessage .= "Below is the registration information:<br />\n<br />\n"; $mailMessage .= "Event Name: $ev_title<br />\nEvent Date: $eventDate<br />\nRegistering Agent: $regAgent<br />\nUser Name: $userName<br />\n"; $mailMessage .= "Agent Writing Number: $agentWritingNum<br />\nPhone Number: $phoneText<br />\n"; $mailMessage .= "E-mail Address: $email<br />\nRegional Sales Coordinator: $regSales<br />\n"; $mailMessage .= "District Sales Coordinator: $disSales<br />\n</body>\n</html>"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; mail($to, $subject, $mailMessage, $headers); // header("Location: success.php?user=$userName&event=$ev_title"); echo "Registering Agent: $regAgent, Agent Writing Number: $agentWritingNum, Phone Number: $phoneText, E-mail Address: $email, Regional Sales Coordinator: $regSales, District Sales Coordinator: $disSales, Event ID: $ev_id, User ID: $user_id<br /><br />"; } else{ echo "<br />Something went wrong with the insert!<br /><br />\n\n"; } } else{ echo "<div style='color: red;'>$errMessage</div><br />"; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Registration Form</title> <link rel="stylesheet" type="text/css" href="formstyles.css"> </head> <body style="text-align: center;"> <div style="width: 400px; margin: 0 auto;"> Registration Form<br /><br /> <form action="<?php echo $_SERVER['PHP_SELF']; ?>?evid=<?php echo $ev_id; ?>" method="post"> <fieldset class="narrow"><legend>Please input your information</legend> <p><label for="regAgent">Registering Agent:</label><input type="text" name="regAgent" value="<?php if(isset($_POST['regAgent'])){echo $_POST['regAgent'];} ?>" /></p> <p><label for="agentWritingNum">Agent Writing Number:</label><input type="text" name="agentWritingNum" value="<?php if(isset($_POST['agentWritingNum'])){echo $_POST['agentWritingNum'];} ?>" /></p> <p><label for="phoneNum">Phone Number:</label>(<input type="text" name="phoneNum[]" size="3" maxlength="3" value="<?php if(isset($_POST['phoneNum'])){echo $_POST['phoneNum'][0];} ?>" />) - <input type="text" name="phoneNum[]" size="3" maxlength="3" value="<?php if(isset($_POST['phoneNum'])){echo $_POST['phoneNum'][1];} ?>" /> - <input type="text" name="phoneNum[]" size="4" maxlength="4" value="<?php if(isset($_POST['phoneNum'])){echo $_POST['phoneNum'][2];} ?>" /></p> <p><label for="emailAddress">E-mail Address:</label><input type="text" name="emailAddress" value="<?php if(isset($_POST['emailAddress'])){echo $_POST['emailAddress'];} ?>" /></p> <p><label for="regionalSales">Regional Sales Coordinator:</label><input type="text" name="regionalSales" value="<?php if(isset($_POST['regionalSales'])){echo $_POST['regionalSales'];} ?>" /></p> <p><label for="districtSales">District Sales Coordinator:</label><input type="text" name="districtSales" value="<?php if(isset($_POST['districtSales'])){echo $_POST['districtSales'];} ?>" /></p> </fieldset> <input type="hidden" name="evid" value="<?php echo $ev_id; ?>" /> <p><input type="submit" name="submit" value="Submit" /></p> </form> </div> </body> </html> <?php require_once "side_right.php"; require_once "footer.php"; ?> As you can see, all queries have WHERE clauses, but the problem remains. mysql_query() should return false on an empty result, correct? I'm asking because I've gone over both the code and the actual queries and I can't see where a logic error could possibly occur, unless the dbquery() function isn't behaving properly. Like I said before, there's literally nothing in the aflac and aw_ec_logins tables right now, so the dbquery() function should be returning false when I check those two tables, forcing it to INSERT rather than UPDATE. EDIT: Here's the data I'm entering (it's not very original): Registering Agent: Admin Agent Writing Number: A1234 Phone: 123-456-7890 E-mail: admin@nightslyr.com Regional Sales Coordinator: Another Person District Sales Coordinator: Someone Else Hidden values: Event ID: 24 User ID: 1 The queries that are echoing to the screen: SELECT * FROM fusion_aflac WHERE ev_id='24' AND user_id='1' UPDATE fusion_aflac SET registering_agent='Admin', agent_writing_number='A1234', phone='123-456-7890', email='admin@nightslyr.com', regional_sales_coordinator='Another Person', district_sales_coordinator='Someone Else', ev_title='Registration test', ev_start='2007-07-02 09:30:00', ev_end='2007-07-02 09:30:00', login_timestamp='1183402221', login_status='1' WHERE ev_id='24' AND user_id='1' UPDATE fusion_aw_ec_events SET ev_allow_logins='1' WHERE ev_id='24' SELECT * FROM fusion_aw_ec_logins WHERE ev_id='24' AND user_id='1' UPDATE fusion_aw_ec_logins SET login_comment='Definitely Agreed', login_status='1', login_timestamp='1183402221' WHERE ev_id='24' AND user_id='1' The ones I've put in bold should be INSERT queries. And for the life of me I can't see why it's defaulting to UPDATE...SET.
  21. It looks like it's defaulting to using the UPDATE...SET syntax. Apparently my if($aflacResult && $eventsResult && $loginsResult) conditional isn't working correctly. I'm not sure why, though, as the dbquery() function, which is what I use to process all of my queries (found in maincore.php), is simply: <?php function dbquery($query) { $result = @mysql_query($query); if (!$result) { echo mysql_error(); return false; } else { return $result; } } ?> It should return false if my SELECT queries find get anything (which they can't in the aflac and aw_ec_logins tables as, right now, there's nothing in them), forcing my queries to use INSERT rather than UPDATE...SET. But it's not doing that.
  22. Another oddity: I can echo the values upon form submission.
  23. Well, I fixed the get_magic_quotes_gpc issue. That removed the error, but the values still won't write to the database. EDIT: and my host hasn't made any changes.
  24. I made simple changes, adding else if(isset($_GET['registering_agent'])){echo $_GET['registering_agent'];} and the like to the form. But here's the thing, my non-edited version also won't work. I tried it on both my test site and the live site and, again, nothing is being written to the database. I've turned error_reporting to all and error_display on. I get the following errors (actually, the same one repeated several times): Would something like this prevent values from being assigned? As you can see from my code above, I use myEscape() on the values entered by the user. The funny thing is, again, I used it this morning -- with the same myEscape() function -- to edit an entry.
  25. 12 views and no response? C'mon guys, I really need help here.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.