Samurai Legend Posted June 19, 2016 Share Posted June 19, 2016 Since I am using a $_POST method to find the userid, when I head onto the next page I get the error: Invalid user, Please go back and try again. I need something which will make the $_POST carry onto the next page as this is my problem I believe. function select_user_logs() { global $db, $ir, $sa; echo "Select the user which you want to view their log. <form action='staff_userlogs.php?action=viewlogs' method='post'> User: " . userlogged_dropdown(NULL, 'user') . " <br /> <input type='submit' value='Submit' /> </form>"; } function view_user_logs() { global $db, $ir, $sa; if (!isset($_GET['st'])) { $_GET['st'] = 0; } $st = abs(intval($_GET['st'])); $app = 100; $_POST['user'] = (isset($_POST['user']) && is_numeric($_POST['user'])) ? abs(intval($_POST['user'])) : 0; if (empty($_POST['user'])) { error('Invalid user.'); } $query = $db->query("SELECT COUNT(`uUSERID`) FROM `user_logs` WHERE `uUSERID` = {$_POST['user']}"); $logs = $db->fetch_single($query); $db->free_result($query); if ($logs == 0) { error('There have been no logs yet from this user.'); } $pages = ceil($logs / $app); $q = $db->query(" SELECT `userid` FROM `users` WHERE `userid` = {$_POST['user']}"); if ($db->num_rows($q) == 0) { $db->free_result($q); error('User doesn\'t seem to exist, Please go back and try again.'); } echo "<hr width = '75%'><table width = '75%' cellpadding = '1' cellspacing = '1' class = 'table'> <tr> <th>User</th> <th>Address</th> <th>Time</th> </tr>"; $query = $db->query("SELECT `uID`, `uUSERID`, `uADDRESS`, `uTIME` FROM `user_logs` WHERE `uUSERID` = {$_POST['user']} ORDER BY `uTIME` DESC LIMIT $st, $app"); while ($r = $db->fetch_row($query)) { echo "<tr> <td>" . $sa->username_nonformat($r['uUSERID'], TRUE) . "</td> <td>{$r['uADDRESS']}</td> <td>" . date("F j, Y, g:i:s a", $r['uTIME']) . "</td> </tr>"; } echo"</table><hr width = '75%'> Pages: "; for ($i = 1; $i <= $pages; $i++) { $s = ($i - 1) * $app; echo ($s == $st) ? '<b>' . $i . '</b> ' : '<a href="staff_userlogs.php?action=viewlogs&st=' . $s . '">' . $i . '</a> '; echo ($i % 25 == 0) ? '<br />' : ''; } $mypage = floor($_GET['st'] / 100) + 1; stafflog_add("Viewed " . $sa->username_nonformat($_POST['user'], TRUE) . " user logs. (Page: $mypage)"); } Quote Link to comment Share on other sites More sharing options...
Coly010 Posted June 19, 2016 Share Posted June 19, 2016 Use an hidden input field and store the userid form post in the value of it Quote Link to comment Share on other sites More sharing options...
TheMasterGeneral Posted June 20, 2016 Share Posted June 20, 2016 Is setting the POST to GET out of the question? I'd figure it'd make navigation between pages easier. Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted June 22, 2016 Share Posted June 22, 2016 Untested.. function view_user_logs() { global $db, $ir, $sa; $_GET['user'] = array_key_exists('user', $_GET) && ctype_digit($_GET['user']) ? $_GET['user'] : null; ?>Select the user which you want to view their log. <form action="staff_userlogs.php?action=viewlogs" method="get"> User: <?php echo userlogged_dropdown(NULL, 'user', $_GET['user']);?><br /> <input type="submit" value="Submit" /> </form><?php if(!empty($_GET['user'])) { $st = array_key_exists('st', $_GET) && ctype_digit($_GET['st']) ? $_GET['st'] : 0; $app = 100; if(empty($_GET['user'])) error('Invalid user.'); $query = $db->query('SELECT COUNT(`uUSERID`) FROM `user_logs` WHERE `uUSERID` = '.$_GET['user']); $logs = $db->fetch_single($query); $db->free_result($query); if ($logs == 0) error('There have been no logs yet from this user.'); $pages = ceil($logs / $app); $q = $db->query('SELECT `userid` FROM `users` WHERE `userid` = '.$_GET['user']); if ($db->num_rows($q) == 0) { $db->free_result($q); error('User doesn\'t seem to exist, Please go back and try again.'); } $query = $db->query('SELECT `uID`, `uUSERID`, `uADDRESS`, `uTIME` FROM `user_logs` WHERE `uUSERID` = '.$_GET['user'].' ORDER BY `uTIME` DESC LIMIT '.$st.', '.$app); ?><hr width="75%"><table width="75%" cellpadding="1" cellspacing="1" class="table"> <tr> <th>User</th> <th>Address</th> <th>Time</th> </tr><?php if(!$db->num_rows($query)) echo '<tr><td colspan="3" class="center">There are no logs available</td></tr>'; else while($r = $db->fetch_row($query)) { ?><tr> <td><?php echo $sa->username_nonformat($r['uUSERID'], true);?></td> <td><?php echo $r['uADDRESS'];?></td> <td><?php echo date("F j, Y, g:i:s a", $r['uTIME']);?></td> </tr><?php } ?></table><hr width="75%"> Pages: <?php for($i = 1; $i <= $pages; ++$i) { $s = ($i - 1) * $app; echo ($s == $st) ? '<b>' . $i . '</b> ' : '<a href="staff_userlogs.php?action=viewlogs&st=' . $s . '&user='.$_GET['user'].'">' . $i . '</a> '; echo ($i % 25 == 0) ? '<br />' : ''; } $mypage = floor($_GET['st'] / 100) + 1; stafflog_add('Viewed ' . $sa->username_nonformat($_GET['user'], true) . ' user logs. (Page: '.$mypage.')'); } } Quote Link to comment Share on other sites More sharing options...
Samurai Legend Posted June 23, 2016 Author Share Posted June 23, 2016 [uSER=53425]Magictallguy[/uSER] [uSER=65530]Coly010[/uSER] - Thank you guys for the help! Quote Link to comment Share on other sites More sharing options...
Samurai Legend Posted June 23, 2016 Author Share Posted June 23, 2016 [uSER=53425]Magictallguy[/uSER] - So when I click the submit button this is the URL: staff_userlogs.php?user=14 This is what displays on the screen: This script requires an action. Quote Link to comment Share on other sites More sharing options...
Magictallguy Posted June 23, 2016 Share Posted June 23, 2016 Change form action="staff_userlogs.php?action=viewlogs" to form action="staff_userlogs.php?action=whatever_goes_here_to_access_the_original_form_function" 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.