Jump to content

digitalgod

Members
  • Posts

    374
  • Joined

  • Last visited

    Never

Everything posted by digitalgod

  1. but that won't always work... let's say you were born on september in 1980 that would mean that you're 25 and not 26 yet. So if I'm looking for people that are 25 years old it will only return everyone that was born in 1981
  2. does anyone know how I can make a drop down where the value is the year depending on the chosen age. For instance if I select 18 in the drop down the value would be 1988... Because the only thing I have in my database is the date of birth and I would like to search the database by selecting from age something to age something. Or would it be better to calculate the year after the form has been submitted?
  3. he guys, I have a dynamic form that displays users and their level of validation. I was wondering how would I add a checkbox to confirm the level of validation (which is in a drop down) so that I can select as many users as I want and when I click on validate, it validates their level? The checkbox needs to contain the username and the level that was chosen in the dropdown (I think) here's what I have so far [code] <form action="admin.php?a=viewusers&action=validate" method="post" name="validate" id="validate"> <input type="hidden" name="process_b" value="yes"> <div style="margin-left:8px; margin-top:10px; margin-right:8px; height:1px; background-image:url(images/dot.jpg) "><img src="images/spacer.gif"></div> <?php if (!isset($_SESSION['custom_browse']) && !isset($_GET['action'])) { $browse = mysql_query("SELECT * FROM mtlguest_users WHERE level='2' ORDER BY id DESC") or die(query_error()); } if (isset($_SESSION['custom_browse']) && !isset($_GET['action'])) { $browse = $_SESSION['custom_browse']; } if (!isset($_SESSION['custom_browse']) && isset($_GET['action'])) { $browse = $_SESSION['all_validate']; } while ( $row = mysql_fetch_array($browse)) { echo ' <div style="margin-left:9px; margin-top:7px; width:354px ">   <div>Username: <strong>'.$row['username'].'</strong></div>   <div>Last Name: <strong>'.ucfirst($row['lname']).'</strong></div>   <div>First Name: <strong>'.ucfirst($row['fname']).'</strong></div>   <div>Age: <strong>'.age($row['date_birth']).'</strong></div>   <div>Sexe: <strong>'.ucfirst($row['gender']).'</strong></div>   <div>Location: <strong>'.$row['city'].'</strong></div>   <div>Active: <strong>'.$row['active'].'</strong></div>';   if ($browse != $_SESSION['all_validate']) {   echo '<div>Level of validation: <strong>'.$row['validation'].'</strong></div>';   } else {   echo '<div>Level of validation: <select name="valid_lvl" id="valid_lvl" style="width:40px; height:12px; font-family:tahoma; font-size:10px; color:#9A400C ">   <option>Choose one</option>';       foreach ($aValid as $val) {       echo "<option value='$val'";       if ($val==$row['validation']) { echo " selected"; }       echo ">".$val;       } echo '</select> Validate: <input type="checkbox" name="validation[]" value=""> </div>';   }   echo '<div style="margin-top:7px " align="right"><a href="#" class="light_gray" style="text-decoration:none "><strong>view profile </strong></a></div> </div> <div style="margin-left:8px; margin-top:10px; margin-right:8px; height:1px; background-image:url(images/dot.jpg) "><img src="images/spacer.gif"></div>'; } ?> </form> [/code] I hope I was clear enough
  4. nevermind I think I solved it by doing [code] <?php $qtmp = array(); foreach($_POST as $k => $v)           switch ($k) {                     case 'sexe':                         $v = implode ("','", $v); if ($v != 'both') {                             $qtmp[] = "WHERE gender ='" . mysql_real_escape_string(trim(stripslashes($v))) . "' AND "; } else {     $qtmp[] = "WHERE ";     }                             break;                                 } $query = "SELECT * FROM " . $prefix . "users " . implode(', ', $qtmp) . "level='2' ORDER by ID"; $_SESSION['custom_browse'] = mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error()); ?> [/code] now my only problem is to keep the radio button selected... so if I select Male then after I submit the form, Male is still checked.. I think I know how to do it but it might be messy
  5. you can read up here to help you get started http://www.phpfreaks.com/tutorials/65/0.php
  6. hey guys, I'm trying to figure out how I can process a form that has several elements but might not all be "filled" for instance a user can select to search by sexe and/or age and/or location How can I make the query dynamic? so far I have this [code] <?php foreach($_POST as $k => $v) switch ($k) {          case 'sexe':                if (trim(stripslashes($v)) != '')                    $qtmp[] = "gender ='" . mysql_real_escape_string(trim(stripslashes(implode ("','", $v)))) . "'";                 break;                                        } $query = "SELECT * FROM " . $prefix . "users WHERE " . implode(', ', $qtmp) . ""; $_SESSION['custom_browse'] = mysql_query($query) or die("Problem with the query: $query<br>" . mysql_error());?> [/code] so how can I make it so that if other fields are filled it will add "AND" and the conditions that are required? And if the radio button Both is checked, then it doesn't need to add WHERE gender=... oh and I'm also getting this notice and was wondering if it's a bad thing or not Notice: Array to string conversion
  7. yeah I already have sessions, only problem now is that I have over 100 php files and I have to add a session check on each of them... thanks for your help
  8. not sure if this is what you're asking for but it might get you started [code] <?php $today = date('Y-m-d'); $result = mysql_query("SELECT * FROM yourTable WHERE FollowUpDate < DATE_SUB(NOW(), INTERVAL -5 DAY)") or die(mysql_error()); while($row=mysql_fetch_array($result) { if ($row['FollowUpDate'] < $today) { //display pic } else { //don't display pic } } ?> [/code]
  9. [quote author=pixy link=topic=102356.msg406142#msg406142 date=1154290615] Maybe you should store templates outside of the main public_html directory? That way they can't be accessed directly through the browser, but can be accessed through the direct path. [/quote] that sounds like a good idea, I'll give it a shot [quote author=marker5a link=topic=102356.msg406143#msg406143 date=1154290633] Whenever I do an admin script, I create a login.php script that authorizes a user.  I use login.php so I can distinguish between user's and their access levels as admins.  Some admins will have more control over the admin section than others.  This is helpful if you have several admins on your website, but you want to limit them to what they can do.  The way to implement this is to include the login script in every file in the admin folder and the admin/templates folder as well.  Also, you can just place htaccess files in the admin directories, giving a simpler way of restricting access.  PM me if you would like help developing a login.php script, I would be more than happy to help you out. Marker5a [/quote] I already have a login.php and every user type has his own level, so for example level 0 is superadmin and when he logs in he has access to everything. Wouldn't it become really annoying to have to login everytime you change pages? I think the htaccess files also sounds like a good idea
  10. hey guys, I've been working on a template system and just recently noticed that if you type the full location of a file, you can acess it even if you're not an admin. all templates are located in template/name_of_page/  so for example the default admin page is located here template/admin.php/default_main.php usually you'd have to sign in for that template to load and if you go on mysite.com/admin.php you'll be redirect to a login page if you're not logged on or not an admin. But if you type mysite.com/template/admin.php/default_main.php you'll be on the main page of the admin panel without logging in, a person that goes there can't really do anything because everything appears broken and the links don't work properly. My question is, what would be the best way of not letting someone go straight to a template file like that? There's no way for someone to find out where the template files are located but I rather be cautious
  11. hey guys, I have this pic upload system that creates the folder if it doesn't exist and makes a thumbail of the pic. It worked perfectly a while ago but now from time to time it won't upload a file saying that it doesn't have Permission and if I try to delete other folders it gives me a Bad File Descriptor error... is it because of my code or something?? here's an example [code] <?php function createthumb($name, $filename, $new_w, $new_h) {     $system = explode('.', $name);     if (preg_match('/jpg|jpeg/', $system[1])) {         $src_img = imagecreatefromjpeg($name);     }     if (preg_match('/png/', $system[1])) {         $src_img = imagecreatefrompng($name);     }     $old_x = imageSX($src_img);     $old_y = imageSY($src_img);     if ($old_x > $old_y) {         $thumb_w = $new_w;         $thumb_h = $old_y * ($new_h / $old_x);     }     if ($old_x < $old_y) {         $thumb_w = $old_x * ($new_w / $old_y);         $thumb_h = $new_h;     }     if ($old_x == $old_y) {         $thumb_w = $new_w;         $thumb_h = $new_h;     }     $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h);     imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y);     if (preg_match("/png/", $system[1])) {         imagepng($dst_img, $filename);     } else {         imagejpeg($dst_img, $filename);     }     imagedestroy($dst_img);     imagedestroy($src_img); } $upload_par = "img/clubs"; $upload_dir = $upload_par . "/" . $name . "/"; $upload_tdir = $upload_dir . "thumbnails/"; $num_files = 1; if (!is_dir("$upload_par")) {     mkdir($upload_par); } if (!is_dir("$upload_dir")) {     mkdir($upload_dir);     mkdir($upload_tdir); } $new_file = $_FILES['file']; $file_name = $new_file['name']; $file_tmp = $new_file['tmp_name']; if (move_uploaded_file($file_tmp, $upload_dir . $file_name)) {     array_push($names, $file_name);     createthumb($upload_dir . $file_name, $upload_tdir . $file_name, 125, 125); } else {     echo "File $i: Faild to upload.<br>"; } ?> [/code] anyone know why that happens to my folders/files?? It's really annoing
  12. hey guys, trying to figure out why this query is giving me an error.. [code] mysql_query("SELECT * FROM " . $prefix . "users WHERE created >= ".$_SESSION['last_login']." ORDER BY id") or die(query_error()); [/code] "created" is formatted in DATETIME and so is $_SESSION['last_login'] but I keep getting this error [quote]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '16:46:09 ORDER BY id' at line 1[/quote] any ideas?
  13. yes I do have document.form.night [code] <div id="article"> <form name="form" id="form" action="admin.php?a=delclubnight" method="post"> <input type="hidden" name="process" value="yes" />     <table border="0">       <tr>         <td>Club Name:</td>         <td><select name="club" id="club" onChange="Selectnight();">           <option>Choose one</option>                </select></td>       </tr>       <tr>         <td>Night::</td>         <td><select name="night" id="night">           <option>Choose one</option>         </select></td>       </tr>     </table> <br /> <input type="submit" value="Delete Night" /> </form> </div> [/code] but it's the first drop down that isn't displaying anything anymore, If I remove the part of code that populates the subcat the first drop down shows me the list of clubs available in the database
  14. I think we're getting somewhere, the page is displayed but there's nothing in the drop downs, it's giving me a javascript error saying that there's something wrong here selectbox.options.add(optn); what's wrong now? :( by the way is that part any good [code] <?php for ($i=0;$i<=$numRows;$i++) { $sql_nights='SELECT * FROM mtlguest_clubnights WHERE club = "'.$clubList[$i].'" ORDER BY night'; $req_nights=mysql_query($sql_nights) or die(query_error()); $night_data = mysql_fetch_assoc($req_nights); echo 'if (document.form.club.options[document.form.club.selectedIndex].value == "'.$clubList[$i].'"){  addOption(document.form.night,"'.$night_data['night'].'", "'.$night_data['night'].'"); }'; } ?>[/code] I have a feeling that it will only display 1 sub category...
  15. [quote author=ryanlwh link=topic=101844.msg403483#msg403483 date=1153866452] you have to check the selectedIndex for drop down lists [/quote] how do I do that?
  16. thanks thepip3r but it's still not working... *edit* I know it's this part that doesn't work because if I take it off the page is displayed... [code] <?php for ($i=0;$i<=$numRows;$i++) { $sql_nights='SELECT * FROM clubnights WHERE club = '.$clubList[$i].'ORDER BY night'; $req_nights=mysql_query($sql_nights) or die(query_error()); $night_data = mysql_fetch_assoc($req_nights); echo 'if(document.form.club.value == '.$clubList[$i].'){ addOption(document.form.night,"'.$night_data['night'].'", "'.$night_data['night'].'"); }'; }?> [/code] still can't find why though
  17. well I only placed the part that I know has errors in, the form itself is just 2 drop downs and a submit button... first drop down has a onChange="fillnight();" I think it's php related because I'm positive I'm doing something wrong in php, it works fine if I use predefined values and only javascript
  18. hey guys, I've been pulling my hair out trying to figure this out... I have 2 drop downs, first 1 is populated from a db, second one displays the sub categories of what has been selected in the first drop down here's what I got so far [code] <?php $sql_clubs='SELECT * FROM clubs ORDER BY name'; $req_clubs=mysql_query($sql_clubs) or die(query_error()); $numRows = mysql_num_rows($req_clubs); $clubList = array(); ?> <script type="text/javascript"> function fillclub(){ // this function is used to fill the club list on load <?php while($data = mysql_fetch_assoc($req)) { array_push($clubList,$data['name']); echo 'addOption(document.form.club, "'.$data['name'].'", "'.$data['name'].'", "");'; } ?> } function Selectnight(){ // ON selection of club this function will work removeAllOptions(document.form.night); addOption(document.form.night, "", "Choose one", ""); <?php for ($i=0;$i<=$numRows;$i++) { $sql_nights='SELECT * FROM clubnights WHERE club = '.$clubList[$i].'ORDER BY night'; $req_nights=mysql_query($sql_nights) or die(query_error()); $night_data = mysql_fetch_array($req_nights); echo 'if(document.form.club.value == '.$clubList[$i].'){ addOption(document.form.night,"'.$night_data['night'].'", "'.$night_data['night'].'"); }'; } ?> function removeAllOptions(selectbox) { var i; for(i=selectbox.options.length-1;i>=0;i--) { //selectbox.options.remove(i); selectbox.remove(i); } } function addOption(selectbox, value, text ) { var optn = document.createElement("OPTION"); optn.text = text; optn.value = value; selectbox.options.add(optn); } [/code] but it's not working... any ideas what's wrong?
  19. with windows media video??? you need a video editing app for that, someone correct me if I'm wrong but I'm positive that there's no way of doing it with php
  20. yeah that's exactly what I do [code] <?php if ($remember == "yes") {       $_SESSION['remember']=$uname;   setcookie("remember",$uname,time()+31449600,"/",$site_address);       }       else {       $_SESSION['remember']=$uname;       } ?> [/code]
  21. hey guys, I made this logout script but it doesn't seem to work, all I get is a blank page and if I press back on the browser I'm still logged in.. any clues why it's not working? [code] <?php include("includes/config.php"); if (isset($_COOKIE['remember'])) { setcookie("remember",$_COOKIE['remember'],time()-3600,"/",$site_address); print("<script> location=\"index.php\"; </script>"); } else {   if (isset($_SESSION['remember'])) {   session_destroy();   print("<script> location=\"index.php\"; </script>");   }   else {   print("<script> location=\"index.php\"; </script>");   } } ?> [/code]
  22. you mean not to overwrite the old image? just give it a new name, put that [code] imagejpeg($image, $filename); [/code] where $filename is the new name, you can make it a random name or just take the old name and add something at the end.
×
×
  • 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.