Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Everything posted by Ch0cu3r

  1. Well this line if($row['password'] == $passwd) Is checking to see if the password in the database matches the password the user entered. Is the passwords in your database encrypted (eg md5, sha1 etc)? If you're storing the passwords in their encrypted form, then you'll have to encrypt the password the user entered when comparing the passwords, example if($row['password'] == md5($passwd))
  2. The reason why your dynamic script doesn't contain the login slider is because you have not included it in your script! demo.php is completely separate to dynamic.php. You need to find the html/php code in demo.php that makes the login slider and put in the header.html for your dynamic site.
  3. It doesn't stack the forms, it'll display one or the other. Do you understand how the if/else control structure works? php.net/if php.net/else Example code <?php // check if form has been submitted if(isset($_POST['submit'])) { // display what was entered echo 'You entered: ' . $_POST['entry']; } else { // form hasn't been submitted display form echo '<form action="" method="post"> <input type="text" name="entry" placeholder="Type Something here" /> <input type="submit" name="submit" value="GO" /> </form>'; } ?>
  4. You'll want to add more logic to your code. Only display the reset password form when the form has not been submitted Something like if(isset($_POST['newpass1')) { // update password // and display new form or page } else { // display form for resetting password }
  5. Well we have no clue either without seeing your code. it seems when you load the dynamic pages with PHP you're not including the JQuery panel code with it, I cant confirm that until see some code.
  6. No Idea? What is this dynamic page script you're using? What have you done to try and solve the problem.
  7. JOINS allow you to query more than one table at a time. There are many different variations of joins. In my query example the left join will include the forum id and title in the result if it has the same category_id as the category's id. If it cant find a matching forum it'll return null. The following article will explain it a lot clearer http://www.mysqltutorial.org/mysql-left-join.aspx
  8. For each checkbox name and domain you also need to assign them the same unique key. If you don't do this then the checkbox values will not pair up with the hidden fields keys,and you'll get miss matched results. When you generate the checkboxes do echo '<tr><td>'.$row['Domain'].'</td> <td> <input type="hidden" name="a['.$i.']" value="'.$row['Domain'].'"> <input type="hidden" name="b['.$i.']" value="N"> <input type="checkbox" name="b['.$i.']" value="Y"> </td></tr>'; $i++; // increment unique id Before the loop that echo's the hidden fields/checkboxes add $i = 0; to instantiate the counter Now your foreach loop should work as expected
  9. Before the while loop setup an array which contains the columns you want to get from $data. $targetColumns = array(0, 3, 14); // get data from the 1st, 4th and 15th column Now replace # Count the total keys in the row. $c = count($data); # Populate the multidimensional array. for ($x=0;$x<$c;$x++) { $csvarray[$nn][$x] = $data[$x]; } With $targetData = array(); // array that hold target data foreach($targetColumns as $column) // loop throught the targeted columns array $targetData[] = $data[$column]; // get the data from the column # Populate the multidimensional array. $csvarray[$nn] = $targetData; // add target data to csvarray Now $csvarray should contain just your targeted data. For array_unique are you wanting to apply it to the three columns ($targetData) or to the whole of $csvarray?
  10. Somewhere in the $options array there is a disabled flag for each option. You need to set it to true This code is loop through all the configurable settings for each option in the list foreach($options as $k=>$option) { if(in_array( $option->value, $groupRestrictions[$gid] )) { unset($options[$k]); } } it is removing options, which are restricted. maybe change unset($options[$k]); to if($k == 'disable') { $options[$k] = true; // set the disable setting to true } else { unset($options[$k]); }
  11. So want the add up the subtotals of $testtotal. You'll wan't to have another variable, call this variable $total_sum. So after $testtotal=$test1+$test2+$test3+$test4; add $total_sum += $testtotal; Then before the </table> add <tr><td colspan="5"></td><td><?php echo $total_sum; ?></td></tr>
  12. trg's response was to this That what he meant by his comment
  13. Why the need to get 600 webpages all in one go? Is the data you're getting copyrighted?
  14. I guess not no. As the reason for the confirmation would be for privacy. if you are tracking geolocation you should tell the user.
  15. echo'<table border="1">'; $col = 0; // column counter $max_cols = 5; // how many columns per row $tresults = 0; // results counter $max_results = $ret->numRows(); // total number of results while($row = $ret->fetchArray(SQLITE3_ASSOC)) { if($col == 0) // if col is 0, start new table row echo '<tr>'; echo '<td>' .$row['Domain'].'</td><td><input type="checkbox" name="a[]" value="n"></td>'; // echo a column $col++; // increment column counter $tresults++; // increment results counter if($col == $max_cols) { // if col equals to max columns echo '</tr>'; // end table row $col = 0; // reset column counter } elseif($tresults == $max_results && $col < $max_cols) // if we have processed all results, but $col is still less than max number of columns echo str_repeat('<td></td>', $max_cols - $col) . '</tr>'; // then clean up table, output empty columns and end table row } echo'</table>';
  16. NO the error suppression should never be used, it does not ignore the error either. It will prevent the error from displaying, but PHP will also log the error too. Before using mysl_fetch_assoc you need to first check the query returned any results using mysql_num_rows.
  17. You'll want to look into using joins. An example query would be like SELECT c.category_id, c.category_title, etc... # gets the category id and title f.forum_id, f.forum_title, etc... # gets the forum id and title FROM forum_categories AS c LEFT JOIN forums f ON c.category_id = f.category_id # selects forums that matches category id ORDER BY c.category_id, f.forum_id # order results by category id and forum id You'd process the above query using $stmt = $mysqli->query($sql); $forum_categories = array(); while($row = $stmt->fetch_array(FETCH_ASSOC)) { // define forum category $forum_categories[$row['id']] = array( 'title' => $row['category_title'], ); // add forums to category $forum_categories[$row['id']]['forums'][] = array( 'id' => $row['forum_id'], 'title' => $row['forum_title'] ); } To display the categories and forums you'd do something like <?php //display forums caregories foreach($forum_categories as $category_id => $category): ?> <table> <tr> <th><a href="forum.php?cat=<?php echo $category_id; ?>"><?php echo $category['title']; ?></a></th> </tr> <?php // diplay category forums foreach($category as $forums): ?> <tr> <td><a href="forum.php?cat=<?php echo $category_id; ?>&id=<?php echo $forum['id']; ?>"><?php echo $forum['title']; ?></a></td> </tr> <?php endforeach; ?> </table> <?php endforeach; ?>
  18. First problem is you're not echo'ing the dropdown menu inside your form. The second problem is you're not echo'ing the submit button '<input type="submit" value="Get Results"> </form>'; You have just defined a string. Your code cleaned up <?php //create_cat.php include 'connect.php'; include 'header.php'; echo '<h2>Update Rewards</h2>'; if($_SESSION['signed_in'] == false | $_SESSION['user_level'] != 1 ) { //the user is not an admin echo 'Sorry, you do not have sufficient rights to access this page.'; } else { $sql = "Select user_name from users"; $result = mysql_query($sql); if(!$result) { //the query failed, uh-oh :-( echo 'Error while selecting from database. Please try again later.'; } else { $dropdown = "<select name='mem'>"; while($row = mysql_fetch_assoc($result)) { $dropdown .= "\r\n<option value='{$row['user_name']}'>{$row['user_name']}</option>"; } $dropdown .= "\r\n</select>"; echo ' <form action="" method="post">' . $dropdown . ' <input type="submit" value="Get Results"> </form>'; } // only qeury the rewards table when the form above has been submitted if(isset($_POST['mem'])) { $post_sql = "select cat_name, point_earn, max_point from rewards where member = '" . mysql_real_escape_string($_POST['mem']) . "'"; $result_post = mysql_query($post_sql); if(!$result_post) { //the query failed, uh-oh :-( echo 'Error while selecting rewards from database. Please try again later.'; } else { echo '<table border="1"> <tr> <th>Category</th> <th>Points Earned</th> <th>Max Points</th> </tr>'; while($row = mysql_fetch_assoc($result_post)) { echo '<tr>'; echo '<td>' . $row['cat_name'] . '</td>'; echo '<td>'. $row['point_earn']. '</td>'; echo '<td>' . $row['max_point']. '</td>'; echo '</tr>'; } echo '</table>'; } } } ?>
  19. Get rid of the quotes url: <?php echo $_SERVER['PHP_SELF']; ?> Oh and you can remove this $('#edit-form-container').html(formHTML); // add response to the #edit-form-container container
  20. Been testing the javascript Change var eventForm = $(this).form to var eventForm = $(this).closest( "form" ) Change cache: false, }).done(function (response) { formHTML = response; // get the response }).fail(function () { formHTML = 'Oops something went wrong'; // display an error message in modal }) to cache: false, context: $('#edit-form-container') }).done(function (response) { $(this).html(response); // get the response }).fail(function () { $(this).html('Oops something went wrong'); // display an error message in modal })
  21. The javasript code be like this (I have not tested this code) $(document).ready(function() { $("form .edit-event").click(function(e) { e.preventDefault(); var eventForm = $(this).form; // get the parent form $.ajax({ url: 'http://example.com/file_that_processes_form.php', // or $_SERVER['PHP_SELF'] type: 'POST', data: $(eventForm).serialize(), cache: false, }).done(function (response) { formHTML = response; // get the response }).fail(function () { formHTML = 'Oops something went wrong'; // display an error message in modal }) }); $('#edit-form-container').html(formHTML); // add response to the #edit-form-container container $("form.event_edit_form").easyModal({ autoOpen: true, overlayOpacity: 0.2, overlayColor: "#666360", overlayClose: true, closeOnEscape: true }); }); }); The url: segment needs to be whatever $_SERVER['PHP_SELF'] is.
  22. That is down to you. In PHP you can detect an ajax request by checking the HTTP_X_REQUESTED_WITH $_SERVER variable. Example code to handle the request if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') { // ajax request detected // check that the event_id has been posted if(isset($_POST['event_id'])) { // get the event from database $row = $event_class_object->method_that_gets_the_event_from_db($_POST['event_id']); // return the html form for editing the event echo ' <form action="'.$_SERVER['PHP_SELF'].'" method="post" class="event_edit_form"> <input type="hidden" name="event_id" value="' .$row['event_id']. '" /> ... rest of form... </form>'; } exit(); // stop the script if needed. }
  23. The following line @ImageJpeg($thumb); will return the raw binary data for the resized image. You cannot mix raw image data with html. What you need to do is save this php code in a seperate file, say call this zimages.php and make it server the correct content type for jpg images <?hpp header('Content-type: image/jpeg'); // <-- added header content type $thumb = ImageCreateTrueColor($finalwidth, $finalheight); $source = @ImageCreateFromJpeg('test/zimages.jpg'); ImageCopyResized($thumb, $source, 0, 0, 0, 0, $finalwidth, $finalheight, $width, $height); @ImageJpeg($thumb); ?> Then in your html you'll call this script using echo "<img src='zimages.php'>"; Which should display the resized image of test/zimages.jpg
  24. Yea, using JQuery's $.ajax() method will be fine. What you want to do first is wrap your existing edit form into a container div, eg <div id="edit-form-container"> <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" class="event_edit_form"> ... rest of form... </form> </div> When the edit-event button is pressed you want to submit then parent form (the one that belongs to the button) using JQuery $.ajax method, so your script receives the event_id. Now the important part is how your existing script handles this ajax request. You only want your php script to return the html form code for editing the event, you don't want the whole webpage back. When you get the response from the ajax request you will then add the returned form into the edit-form-container div container, using something like $('#edit-form-container).html(ajaxRresponseTextVariable). Then your existing modal code for displaying the form should work. You still want to maintain backwards compatibility if someone disables javascript. So you will want to make sure your script works without javascript too.
×
×
  • 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.