Jump to content

Chris Val Kef

Members
  • Posts

    25
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Chris Val Kef's Achievements

Member

Member (2/5)

0

Reputation

  1. i have files stored in a folder and i want user can download them. Mime-type and file-size have to be stored in database when i upload the file or it doesn't matter? are there any simple code examples with files for download or something? I want to return an icon for different type of files (ie the icon of Acrobat for .pdf) it's the first time i'm handling files so any help would be very very useful!
  2. SOLVED! the problem was somewhere else in the code... I'm not telling you where because you will laugh with me till xmas... ok ok after the isset($_POST... bla bla bla) i supposed to use explode() somewhere but i forgot to write --explode-- so i got something like this $var = (".",$var);... OOPS! sorry guys!  :-[ :-[ :-[
  3. still can't fix it! think i got problem with the name of the radio buttons and the way i handle them. <input type=radio name=rb1 value=0> <input type=radio name=rb1 value=1> . . . <input type=radio name=rbN value=0> <input type=radio name=rbN value=1> i handle them like this for ( $cnt=1; $cnt<N; $cnt++ ) {     if ( isset ( $_POST['rb$cnt'] ) )     {...} } should i do something like $_POST['rb$cnt']['$cnt'] like when having an array of checkboxes? p.s. Fallen Angel i got this habbit too. easy when coding but projectshifter is right...
  4. thanx for the advise! i tried it but i still get the blank page... i guess somewhere else i have wrongs too so the debugging goes on... thanx again  kenrbnsn
  5. got something like this: <input type="radio" name="1" value="0"> <input type="radio" name="1" value="1"> ... <input type="radio" name="2" value="0"> <input type="radio" name="2" value="1"> ... <input type="radio" name="3" value="0"> <input type="radio" name="3" value="1"> ... and so on... I got one submit button. how should i manage them with the $_POST? Now i got an increasing pointer and do something like this if (isset ( $_POST["$cnt"])) {       if ($_POST["$cnt"] == 0)       {       }       elseif ($_POST["$cnt"] == 1)       {       } } .... what am i doing wrong? i'm getting a blank page when i submit... thanx in advance!
  6. something is wrong with my code. All i want to do is a form with checkboxes where a student can update his lessons. if the checkbox is checked then the student send request to be registered (active=0). if the checkbox is empty and the student is registered (active=1) to the corresponding lesson then i want him to be deleted from it. here is a part of the form code [code]<td width="25"><div id="input"> <input type="hidden"   name="hiddenCheck[]" value="{CLASS_ID}"> <input type="checkbox" name="check[]" value="{CLASS_ID}.{CNT}" {CHECKED}></div></td>[/code] and here is the action code... [code]<?php session_start(); include '../config.php'; $con = mysql_connect($dbServer,$dbUser,$dbPass) or exit("Error Connecting to Database"); $sqlCLASSES = "SELECT id FROM classes"; $resCLASSES = mysql_db_query("elearning",$sqlCLASSES); for ($cnt=0; $cnt<count($_POST["check"]); $cnt++) { $checked = $_POST["check"]["$cnt"]; $cntChecked = explode(".", $checked); $classID = $cntChecked[0]; for ($cnt2=0; $cnt2<count($_POST["hiddenCheck"]); $cnt2++) { if ( $cntChecked[1] == $cnt2) { $sqlREGISTERED = "SELECT id FROM student_attends_class WHERE (student_id = '".$_SESSION["student_id"]."') AND (class_id = $classID) AND (active = 1) "; $resREGISTERED = mysql_db_query ("elearning", $sqlREGISTERED); $resultREGISTERED = mysql_fetch_array ($resREGISTERED); if ( $resREGISTERED && (mysql_num_rows ($resREGISTERED) == 0) ) { $sqlSEMESTER = "SELECT semester FROM classes WHERE id = $classID "; $resSEMESTER = mysql_db_query ("elearning",$sqlSEMESTER); $resultSEMESTER = mysql_fetch_array ($resSEMESTER); $sqlREQUEST = "INSERT INTO student_attends_class VALUES ('', '$classID', '".$_SESSION["student_id"]."', '', '".$resultSEMESTER["semester"]."' )"; $resREQUEST = mysql_db_query ("elearning", $sqlREQUEST); } } else { $sqlREGISTERED = "SELECT id FROM student_attends_class WHERE (student_id = '".$_SESSION["student_id"]."') AND (class_id = '".$_POST["hiddenCheck"]["$cnt2"]."')  AND (active='1')  "; $resREGISTERED = mysql_db_query ("elearning", $sqlREGISTERED); $resultREGISTERED = mysql_fetch_array ($resREGISTERED); if ( $resREGISTERED && mysql_num_rows ($resREGISTERED) { $sqlUNREGISTER = "DELETE FROM student_attends_class WHERE class_id = '".$_POST["hiddenCheck"]["$cnt2"]."' "; $resUNREGISTER = mysql_db_query ("elearning", $sqlUNREGISTER); } } } } header ('Location: main.php?message=updated_lessons'); ?>[/code] the student can send his requests to register (active=0) without any problem but when his unchecks a lesson so to be deleted from it then he is deleted from the lesson and all the other lessons that he is registered to, coming to a state with 'active=0'. i can't fix it so far... Can someone please help me???? (before i'll finally change the whole 'concept' of the interface)
  7. thanx for the advise! i think i'll change the interface and it will be much easier for the implementation too! thanx again Ken!
  8. can i POST all checked and unchecked ckeckboxes in one table somehow? i think that $_POST keeps a table only with the checked ones. i got this kind of form with multiple checkboxes: <input type="checkbox" name="check[]" value="{CLASS_ID}" {CHECKED}> all i want to do is to:     a. if is ckecked then insert somehing in db     d. is it was checked and user unchecked it then delete something from db hope someone got it!
  9. <?php session_start(); include '../config.php'; $con = mysql_connect($dbServer,$dbUser,$dbPass) or exit("Error Connecting to Database"); $sqlSTUDENT = "SELECT id FROM students WHERE user_id = '".$_SESSION["user_id"]."' "; $resSTUDENT = mysql_db_query ("elearning",$sqlSTUDENT); $resultSTUDENT = mysql_fetch_array ($resSTUDENT); for ($cnt=0; $cnt<count($_POST["check"]); $cnt++) { if ( isset($_POST["check"]["$cnt"]) ) { $sqlREGISTERED = "SELECT id FROM student_attends_class WHERE student_id = '".$resultSTUDENT["id"]."' AND class_id = '".$_POST["check"]["$cnt"]."' AND active = 1 "; $resREGISTERED = mysql_db_query ("elearning", $sqlREGISTERED); //$resultREGISTERED = mysql_fetch_array ($resREGISTERED); if ( mysql_num_rows ($resREGISTERED) == 0 ) { $sqlSEMESTER = "SELECT semester FROM classes WHERE id = '".$_POST["check"]["$cnt"]."' "; $resSEMESTER = mysql_db_query ("elearning",$sqlSEMESTER); $resultSEMESTER = mysql_fetch_array ($resSEMESTER); $sqlREQUEST = "INSERT INTO student_attends_class VALUES ( '', '".$_POST["check"]["$cnt"]."', '".$resultSTUDENT["id"]."', '0', '".$resultSEMESTER["semester"]."' )"; $resREQUEST = mysql_db_query ("elearning", $sqlREQUEST); } } else { $sqlREGISTERED = "SELECT id FROM student_attends_class WHERE student_id = '".$resultSTUDENT["id"]."' AND class_id = '".$_POST["check"]["$cnt"]."' AND active = 1 "; $resREGISTERED = mysql_db_query ("elearning", $sqlREGISTERED); $resultREGISTERED = mysql_fetch_array ($resREGISTERED); if ( mysql_num_rows ($resREGISTERED) == 1) { $sqlUNREGISTER = "DELETE FROM student_attends_class WHERE id = '".$resultREGISTERED["id"]."' "; $resUNREGISTER = mysql_db_query ("elearning", $sqlUNREGISTER); } } } header ('Location: main.php?message=updated_lessons'); } ?> this is my code! it seems fine to me but when i submit i get a white screen... after some tries i found that it doesn't like the outer  if...else
  10. i want to check if a checkbox was checked or not. if (isset($_POST["check"]["$cnt"] works fine but it seems that elseif (!isset($_POST["check"]["$cnt"])) is being skipped. i use this in the form <input type="checkbox" name="check[]" value="id"> does anyone knows if the check[] table POSTs only the checked checkboxes? any ideas to check the unchecked checkboxes? ;)                                  
  11. i don't want it. i'm building the system now so i noticed the problem while i was trying some functionalities and it's really pissing me off!
  12. any ideas how to solve the problem? i don't think it's very serious problem for me (what is the possibility two different users login to my website in the same instance of a browser???? ;-) ) but it's pissing me off when i think about it
  13. in different windows of ie/ff  i don't have the problem. if i got it right you are saying that one instance of the browser keeps one session, so when i open the second tab and login it overwrites the sessions. even if i don't got it right that is what happening... lol! is there any " new session_start()" function ? could this solve the problem? i've tried myself the unique name, unique id etc but still got the problem
×
×
  • 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.