Jump to content

Monkuar

Members
  • Posts

    987
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Monkuar

  1. Here is my code if (isset($_GET['hide'])){ $id = intval($_GET['hide']); $explode = explode(",", $_COOKIE['hide']); if (in_array($id, $explode)) { } setcookie('hide', ''.$id.'',time()+32000000); header('Location: index.php'); exit; } My Explanation: If somone clicks ?hide=2 It will add the cookie hide, and the value to 2. Now, if somone clicks ?hide=1, I need it to add 2,1 how is that possible? Then if the in_array is correct, (Means if the value of the cookie is 2 and they clicked ?hide=2) how do I take that number "2" out of the it (Remove it) and make a new array that will be inserted to my $id variable?
  2. $cat_ids = (isset($_COOKIE['collapseprefs'])) ? explode(',', $_COOKIE['collapseprefs']) : array(); I have this code that reads arrays like 1,2,3,4 i need to get arrays like that stored in a cookie... but like what if somone clicked ?hide=4 then the array needs to become 1,2,3 how?
  3. Brain is absolutely trash today. I just need to set my cookie to 1,2 if the data is 1 and somone got ?hide=2, it needs to be 1,2. How to do this? Now if they do ?hide=2 it needs to be just 1, lol sorry but this is killing me
  4. if a user clicks ?hide=1 or ?hide=2 it does if (isset($_GET['hide'])){ $id = intval($_GET['hide']); setcookie('hide', ''.$id.'',time()+32000000); header('Location: index.php'); exit; } How do I make it so if they click ?hide=1 it ad's 1, but what if they do ?hide=2 also? it would need to be 1,2 not just 2.
  5. i edited to make it more easier $middle=array ( "Notes" => array ( "section" => $notes, "hide" => $display['1'], "left" => "0", "right" => "0", "middle" => "1" ), "Signature" => array ("section" => $signature, "hide" => $display['2'], "left" => "0", "right" => "0", "middle" => "1" ), "Friends" => array ("section" => $friends, "hide" => $display['4'], "left" => "0", "right" => "0", "middle" => "1" ), ); $order = array("Notes","Signature","Friends"); I will put a Arrow next to each section for them to click on, but dunno how I would update the row? lol i mean if they click up arrow on the friends tab, i need to move the friends behind the signature/etc so on, how Can I know what they're going to click and do a action for it? :shrug:
  6. $middle=array ( "0" => array ( "section" => $notes, "hide" => $display['1'], "left" => "0", "right" => "0", "middle" => "0" ), "1" => array ("section" => $signature, "hide" => $display['2'], "left" => "0", "right" => "0", "middle" => "0" ), "2" => array ("section" => $friends, "hide" => $display['4'], "left" => "0", "right" => "0", "middle" => "0" ), ); $order = array(0,1,2); echo serialize($order); foreach ($order as $index) { if ($middle[$index]['hide'] != 1){ if ($middle[$index]['left'] == 1){ $lside .= $middle[$index]['section']; } if ($middle[$index]['right'] == 1){ $rside .= $middle[$index]['section']; } if ($middle[$index]['middle'] == 1){ $mside .= $middle[$index]['section']; } } } See the $order = array(0,1,2); Is the ordered list of each users profile, I want them to beable to edit the $order = array (0,1,2) to any order they want (can only be 0 1 or 2 numbers, and numbers cannot be repeated, or it will just show 2 of the sections. I was looking into serialzed and was hoping it would be the best way to do this? i've Tried a simple varchar field with exploded 0,1,2 but there was no validation process I could think of to fit my needs, (0 1 or 2 and numbers cant be repated) i want my users to choose a order of the list in that $order variable, is serialized to much for this simple task? I am still stumped
  7. $order = array(0,1,2); echo serialize($order); Shows: a:3:{i:0;i:0;i:1;i:1;i:2;i:2;} which is fine, because I can use unserialized. But I need to let me users switch between 0,1,2 to be in what ever order they want it to!, how would I go about saving the data ?
  8. $notes = 'ABOUT ME SECTIOn HERE'; $signature = 'SIGNATURE STUFF HERE'; $friends = 'friends INFO HERE'; $middle=array ( "0" => array ( "section" => $notes, "hide" => $display['1'], "left" => "0", "right" => "0", "middle" => "0" ), "1" => array ("section" => $signature, "hide" => $display['2'], "left" => "0", "right" => "0", "middle" => "0" ), "2" => array ("section" => $friends, "hide" => $display['4'], "left" => "0", "right" => "0", "middle" => "0" ), ); $order = array(0,1,2); foreach ($order as $index) { if ($middle[$index]['hide'] != 1) echo '<br>'.$middle[$index]['section']; } Okay, so this code right here works fine, but how would I make the left/right/middle stuff correspond to right side of my table columns, middle or left? Do I need to add another demi array to make 3 in 1? or am I doing it okay with just the multi with the "left" "middle" "right" ? if 0 means false, will change them to 1 if true.
  9. ROFL Thank you lol i think i had a brain fart
  10. these are sections of my profile, just plain right now so easier for u to read: $notes = 'notes'; $signature = 'signatures'; $friends = 'friends'; $middle=array ( "0" => array ( "section" => $notes, "hide" => "0", "c" => "apple" ), "1" => array ("section" => $signature, "hide" => "0", "c" => "apple" ), "2" => array ("section" => $friends, "hide" => "0", "c" => "apple" ), ); $order = array(2,1,0); foreach ($order as $index) { echo '<br>'.$middle[$index]['section']; } If the hide = 1 how do i hide a array in my foreach?
  11. fixed it foreach($_POST['ranks'] as $index=>$value) { $ranks = mysql_real_escape_string(TRIM($_POST['ranks'][$index])); $ids = mysql_real_escape_string(TRIM($_POST['m'][$index])); $db->query('UPDATE friends set rank = '.$ranks.' WHERE friend_id = '.$ids.' AND user_id = '.$pun_user['id'].'') or error('Unable to remove users from online list', __FILE__, __LINE__, $db->error()); } redirect("s.php?section=Friends","Thanks, Ranks Updated"); }
  12. //Update the ranks if (isset($_POST['update'])){ $ids = implode(",", array_map('intval', $_POST['m'])); $ranks = implode(",", array_map('intval', $_POST['ranks'])); if ($ids < 1) message("Incorrect Data"); if ($ranks < 0) message("Incorrect Data"); foreach ($_POST['ranks'] as $muffins){ $db->query('UPDATE friends set rank = '.$muffins.' WHERE friend_id = '.$_POST['m'].' AND user_id = '.$pun_user['id'].'') or error('Unable to remove users from online list', __FILE__, __LINE__, $db->error()); } redirect("s.php?section=Friends","Thanks, Ranks Updated"); } friend_id = becomes blank? the $muffins work and each rank is showed respectivaly, but how can I join in another array in the loop? I tried another foreach in the loop, but it just made me run double the queries. Any idea? $muffins is working fine and $_POST['m'] is giving no results i need to have 2 dynamic arrays in that forloop, the $ranks and the $ids
  13. So if i want to achieve this, if a user has 20 friends and wants to update each 1 with the respective rank, it will run 20 queries? I will use a foreach to do this correct? If so, i dont care , 20 queries is nothing if it's just simple updates
  14. I have this code: if (isset($_POST['update'])){ $ids = implode(",", array_map('intval', $_POST['m'])); $ranks = implode(",", array_map('intval', $_POST['ranks'])); if ($ids < 1) message("Incorrect Data"); if ($ranks < 0) message("Incorrect Data"); echo $ids; echo "<br>"; echo $ranks; exit; $db->query('UPDATE friends set RANKS WHERE friend_id IN ('.$db->escape($ids).') AND user_id = '.$pun_user['id'].'') or error('Unable to remove users from online list', __FILE__, __LINE__, $db->error()); redirect("s.php?section=Friends","Thanks, Ranks Updated"); } I grab the id's from the rank This will spit out 3,4 for $ids and for $ranks, 1,2 as you can see, set for 1 and 2 respectivaly. My problem is how can I use MYSQL to update the data correspond to each id using a IN clause? $db->query('UPDATE friends set RANKS = "LOST $RANKS? HERE" WHERE friend_id IN ('.$db->escape($ids).') AND user_id = '.$pun_user['id'].'') or error('Unable to remove users from online list', __FILE__, __LINE__, $db->error());
  15. Would this work? $ids = implode(",", array_map('intval', $_POST['m']));
  16. $ids = implode(",", $_POST['m']); $db->query('DELETE FROM friends WHERE friend_id IN ('.$db->escape($ids).') AND user_id = '.$pun_user['id'].'') or error('Unable to remove users from online list', __FILE__, __LINE__, $db->error()); redirect("s.php?section=Friends","Thanks, Friends removed "); Is there any other way to secure it better? I feel like im missing something, i just don't want to get hacked also added $ids = implode(",", $_POST['m']); if ($ids < 1) message("Incorrect Data");
  17. True... I cant really stop it thank you
  18. Works exactly what I asked for. Now 1 more problem users are spamming sites " rofl . c o m " with spaces Way to fix that also ? Wildcard is working @ManiacDan,@Pikachu,@Aykay, thanks for ur codes and advice to Gotta love me some regex for the morning
  19. I meant to edit my post. but the site wont let me I got it to work: if (preg_match("/^[a-zA-Z0-9]*((-|\.)?[a-zA-Z0-9])*\.([a-zA-Z]{2,4})$/", $text)) { message("You cannot post links or urls unless you have made 10 Posts"); } But, if people enter ".com2" it still let's them, I need to add a wildcard to the .com so if they have any text characters after the .com or .net that it errors out, any idea fellas?
  20. if (preg_match('^[a-zA-Z0-9\-\.]+\.(com|org|net|mil|edu|COM|ORG|NET|MIL|EDU)$', $text)) { message("You cannot post links or urls unless you have made 10 Posts"); } $text is the users's input i try ".com" doesn't return true any idea?
  21. Haha, I got the roman numerals working man $numerals = array(1=>'I','II','III','IV','V','VI','VII','VIII'); for($col = 1; $col <= $numCols; $col++) { echo "<td><dl><dt>{$numerals['1']}{$numerals['2']}</dt><dd class=padding>"; There is just no way to echo them out dynamically based on that $numerals array because I am already inside a for loop, any help?
  22. Okay, here is my code, it's messy but i will show u what needs to be done if u can help me $uservalue=$user['max_stars']; $numCols = 8; $numPerCol = ceil(75 / $numCols); echo "<table class=tuble><tr>"; for($col = 1; $col <= $numCols; $col++) { $numerals = array(1=>'I','II','III','IV','V','VI','VII','VIII'); echo "<td><dl><dt>{$numerals}</dt><dd>"; for($row = 0; $row < $numPerCol; $row++) { $resultRow = 75; if ($i<=$uservalue) { if ($i == $selected) { $checked = 'checked'; }else{ $checked = ''; } echo '<label for="s'.$i.'"><input type="radio" id="s'.$i.'" onclick=\'showPreview('.$i.')\' value="'.$i.'" '.$checked.' name="form[star]"><img src=img/icons/'.$i.'.png></label><br>'; } else { if ($i > 75){ $lol = array("hey","hey2"); foreach ($lol as $lols){ $lol .= $lols; } echo '<font color=#f36f6f><span class=desc><b><img src=img/icons/'.$i.'.png> Confidential</span></b></font><label for="s'.$i.'"><input type="radio" id="s'.$i.'" onclick=\'showPreview('.$i.')\' value="'.$i.'" name="form[star]" disabled></label><img src=img/lock2.png><br>'; }else{ echo '<label for="s'.$i.'"><input type="radio" id="s'.$i.'" onclick=\'showPreview('.$i.')\' value="'.$i.'" name="form[star]" disabled><img src=img/icons/'.$i.'.png></label><img src=img/lock.png><br>'; } } $i++; } echo "</td>"; } This code here: $numerals = array(1=>'I','II','III','IV','V','VI','VII','VIII'); echo "<td><dl><dt>{$numerals}</dt><dd>"; for($row = 0; $row < $numPerCol; $row++) { I need to echo out that $numerals array onto my $numerals variable, but I cant because it's under a for loop, and if i try using a foreach it wont display correctly. because it's already under a forloop Any idea guys?
  23. if ($user['amount'] >= 15.00){ $user['max_stars'] = 3; } Ok and if ($user['amount'] >= 20.00){ $user['max_stars'] = 4; } How can I write a function that will loop through the 15,20,25,30,35, all the way up to 600$ or if the max_Stars get's up to 80? I really don't want to have 80 if functions in my code :\
  24. If I don't use $i=$i-1, and use the $i-- there is a 2nd delay lag when running the script Dunno why, but there is, I switched it back to $i=$i-1 and it's working fine. Thanks for your help
  25. Okay, this is my loop to show the birthday for Years. <?php for ($i=2006; $i>=1900; $i=$i-1) { echo "<option value='$i'>$i</option>"; } ?> It will show 2012 to 1900 as a dropdown menu.. in my select form. Now I want to check the user input against this loop. The form is: <select name="BirthDay[]"> <?php for ($i=2012; $i>=1900; $i=$i-1) { echo "<option value='$i'>$i</option>"; } ?> </select> Now, I want to use in_array function to check if it equals any of the values I looped, if it doesn't echo out "Hacker!" Here is my in_array $bday = array( NEED TO PUT THIS LOOP HERE SOMEHOW?!?! ); if (!in_array($_POST['BirthDay'], $bday)) { message("Please select a Correct Birthday, or u trying to hack"); } Thanks if u can help!
×
×
  • 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.