Jump to content

beginnerProgrammer_96

Members
  • Posts

    19
  • Joined

  • Last visited

About beginnerProgrammer_96

  • Birthday 12/21/1996

Profile Information

  • Gender
    Female
  • Location
    SG

beginnerProgrammer_96's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for this, but seeing the codes, it doesn't have those error handling, which I would like to put in. Also, about the line 11, the html fieldset you put is located outside the form. This caused warning from dreamweaver. I usually put the fieldset inside the form tag, will this change anything? Also, this <?=$example?> , is this a short form tag of php? Or is it the combined comparison? I searched up on this and i found out that (if it is the combined comparison), it is available for php version 7, and my version is 5.6.8. Will this affect too? I have tried using the codes, and i'm getting this undefined offset error which I am confused about. while (list($id,$descrip) = $res->fetch(PDO::FETCH_ASSOC)) { //conditional statement: if id ===1, then set to check, else, leave empty $chk = $id==1 ? 'checked="checked"' : ''; $btns .= "<div class='spec'><label><input $chk type='radio' name='spec' value='$id' class='rbspec' data-spec='$id'>$descrip </label></div>"; if ($i%2==0) { $btns .= '<br>'; } $i++; } That error shows it to line 1, but I think it is more to the coding inside. I am not sure how to implement the checking like the one found in this http://stackoverflow.com/questions/17456325/php-notice-undefined-offset-1-with-array-when-reading-data I hope i could learn fast ><
  2. I see, I am implementing the database structure while looking through the codes. Could you explain more on the javascript on the skillset and the getSkillset function? I don't have a visual to see how this should works o.o It also seems that that piece of coding is to retrieve the data of skillsets and put it into the radiobuttons // GET PROFILE DATA IF EXISTS $sql = "SELECT u.name , IFNULL(up.userprofileid, 0) , up.introduction , up.contactno FROM user u LEFT JOIN user_profile up ON u.id = up.user_id WHERE u.id = $loggeduser"; $res = $database->query($sql); list($user_name, $userprofileid, $user_intro, $user_contactno) = $res->fetch_row(); $action = $userprofileid==0 ? 'Add' : 'Edit'; What does the line in bold do? Is that an add/edit button? I realised that this is a profile to show, rather than to add? the beginner_update.php is where i believe it is to add/edit/update? Also, the user_skillset table, I think you meant those two PK is the foreign key am i right? There should be another id(for that table) for the PK isn't it?
  3. Will this complicate my database? It seems i will need to reference alot (I'm not saying that this is not good or takes too much time to implement, because i know that I'm a newbie/lack of knowledge). I have another table which is portfolio, so basically i have 3 tables(user, userProfile, portfolio) as of right now. I would have to retrieve every user's picture in portfolio to show to the website so that it will link to the user's profile/portfolio. I hope i did not make it more complex
  4. im not sure why i can't edit my post but i just figure out that if i don't upload file, then it will give me blank page(sorry about that!) Now, i just need to get my $skillset working to do my image part ;-;
  5. Okay, after a few hours trying to fix those errors, there's just this one error i just couldn't solve. The error was that I didn't define $skillset(It's the same problem i had at the very first part of this topic too). I declare this $skillset inside the if statement in validation, so i'm guessing that's why it won't read my variable? if(empty($errors)){ // all your form field validation code would go here, using elements in the $data array (a trimmed copy of the $_POST data) //validate here after declaring them $data['name'] = $_POST['name']; $data['introduction'] = $_POST['description']; $data['email'] = $_POST['email']; $data['contactNo'] = $_POST['contactNo']; $data['specialization'] = $_POST['specialization']; $data['ISGrp1'] = $_POST['ISgrp1']; $data['ISGrp2'] = $_POST['ISgrp2']; $data['ISGrp3'] = $_POST['ISgrp3']; $data['ISGrp4'] = $_POST['ISgrp4']; $data['ISGrp5'] = $_POST['ISgrp5']; $data['IMGrp1'] = $_POST['IMgrp1']; $data['IMGrp2'] = $_POST['IMgrp2']; $data['IMGrp3'] = $_POST['IMgrp3']; $data['IMGrp4'] = $_POST['IMgrp4']; $data['IMGrp5'] = $_POST['IMgrp5']; $data['CNETGrp1'] = $_POST['CNETgrp1']; $data['CNETGrp2'] = $_POST['CNETgrp2']; $data['CNETGrp3'] = $_POST['CNETgrp3']; $data['CNETGrp4'] = $_POST['CNETgrp4']; $data['CNETGrp5'] = $_POST['CNETgrp5']; $data['ITSMGrp1'] = $_POST['ITSMgrp1']; $data['ITSMGrp2'] = $_POST['ITSMgrp2']; $data['ITSMGrp3'] = $_POST['ITSMgrp3']; $data['ITSMGrp4'] = $_POST['ITSMgrp4']; $data['ITSMGrp5'] = $_POST['ITSMgrp5']; //check if name is blank if ($data['name'] == "" || !$data['name']) { $errors[] = ("Name is required!"); } //check if introduction is blank if ($data['introduction'] == "" ||!$data['introduction']) { $errors[] = ("Introduction is required!"); } //check if introduction is blank if ($data['email'] == "" || !$data['email']) { $errors[] = ("Email is required!"); } //check if contactNo is blank if ($data['contactNo'] == "" || !$data['contactNo']) { $errors[] = ("Contact number is required!"); } //check if emailis valid if (filter_var($data['email'], FILTER_VALIDATE_EMAIL) === false) { $errors[] = ("Email is not valid."); } //validate if name is maxed number if (isset($data['name']) && strlen($data['name']) > 50) { $errors[] = ("Name is too long!"); } //validate if name is maxed number if (isset( $data['introduction']) && strlen($data['introduction']) > 50) { $errors[] = ("Introduction is too long!"); } //validate if name is maxed number if (isset($data['email']) && strlen($data['email']) > 50) { $errors[] = ("Email is too long!"); } //check if contactNo is valid //checks for numeric, then check for 8 digits if(isset($data['contactNo']) && !is_numeric ($data['contactNo'])) { $errors[] = ("Contact number is invalid! All must be in numerics!"); } if(strlen(trim($data['contactNo'])) != { $errors[] = ("Contact number must be of 8 digits!"); } if (isset($data['specialization']) && $data['specialization'] == 'Specialization_1') { $data['specialization'] = "IS"; $skillset = ($data['ISgrp1'].",".$data['ISgrp2'].",".$data['ISgrp3'].",".$data['ISgrp4'].",".$data['ISgrp5']); } if (isset($data['specialization']) && $data['specialization'] == 'Specialization_2') { $data['specialization'] = "IM"; $skillset = ($data['IMgrp1'].",".$data['IMgrp2'].",".$data['IMgrp3'].",".$data['IMgrp4'].",".$data['IMgrp5']); } if (isset($data['specialization']) && $data['specialization'] == 'Specialization_3') { $data['specialization']= "CNET"; $skillset = ($data['CNETgrp1'].",".$data['CNETgrp2'].",".$data['CNETgrp3'].",".$data['CNETgrp4'].",".$data['CNETgrp5']); } if (isset($data['specialization']) && $data['specialization'] == 'Specialization_4') { $data['specialization'] = "ITSM"; $skillset = ($data['ITSMgrp1'].",".$data['ITSMgrp2'].",".$data['ITSMgrp3'].",".$data['ITSMgrp4'].",".$data['ITSMgrp5']); } //image $fileError = $_FILES['image']['error']; //validate if there's any error if($fileError > 0){ // header("Location:".$returnURL."?err=imgUploadError"); $errors[] = ("Error on uploading image!"); exit; } $data['maxSize'] = 100000; $fileSize = $_FILES['image']['size']; //validate image size if($fileSize > $data['maxSize']){ $errors[] = ("Image size is too big!"); // exit; } //get the temporary location of the file $fileTempName = $_FILES['image']['tmp_name']; $trueFileType = exif_imagetype($fileTempName); $allowedFiles = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG); if (in_array($trueFileType, $allowedFiles)) { switch($trueFileType){ case 1 : $fileExt = ".gif"; break; case 2: $fileExt = ".jpg"; break; case 3 : $fileExt = ".png"; break; } }else{ //header("Location:".$returnURL."?err=WrongFileType"); $errors[] = ("The one you've uploaded is not supported! Please check that it is in the right format."); exit; } // Get the path to upload the image to $myPathInfo = pathinfo($_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']); $currentDir = $myPathInfo['dirname']; $imgDir = $currentDir . '/profilePic/'; } // done with validation, if no errors, use the data - if(empty($errors)){ // your code to insert the data and move the uploaded file would go here... $stmt = $database->prepare("INSERT INTO userProfile (picName, picPath, Name, introduction, Specialization,skillset, Email, ContactNo) VALUES (:picName,:picPath,:Name,:introduction,:Specialization,:skillset,:Email,:ContactNo)"); $stmt->bindValue(':picName',$_FILES['image']['name']); $stmt->bindValue(':picPath', $imgDir); $stmt->bindValue(':Name', serialize($data['name'])); $stmt->bindValue(':introduction',serialize($data['introduction'])); $stmt->bindValue(':Specialization', serialize($data['specialization'])); $stmt->bindValue(':skillset', $skillset); $stmt->bindValue(':Email',serialize($data['email'])); $stmt->bindValue(':ContactNo',serialize($data['contactNo'])); $stmt->execute(); } To make the matter worse, after a few tries of submitting, the page just gives a blank page(same page though) without no errors. Did the <pre> tag but all values fit perfectly..what had i done? I'm so confused
  6. Sorry about that, i realised i do need to declare, just that not in the place you mentioned on your previous post. $data['name'] = $_POST['name']; $data['introduction'] = $_POST['description']; $data['email'] = $_POST['email']; $data['contactNo'] = $_POST['contactNo']; I've now gotten another error but i'm trying to fix it first before i post again(i want to learn too ><). Thanks for your help, i really really thankful and grateful having you helping me out ^^
  7. Okay, thanks for your help! I've changed the codings to these: if ($_SERVER['REQUEST_METHOD'] == 'POST') { // array to hold errors $errors = array(); // copy and trim all post data (if the form has any arrays, you need to use a function like array_walk_recursive() instead of array_map()) //variables here $data= array();//array_map('trim',$_POST); array_walk_recursive($_POST,'trim'); // if you have multiple-forms, you would conditionally run the correct section of form processing code by testing for a form field or a field value that uniquely identifies which form was submitted // addprofileform form processing code - //check if there is an existing record in DB $query = "SELECT COUNT(*) FROM userProfile WHERE user_id = {$_SESSION['user_id']}"; var_dump($query); $stmt = $database->query($query); $number_of_rows = $stmt->fetchColumn(); if ($number_of_rows > 0) { $errors[] = "There is an existing record. You cannot insert another profile! Either update the old one, or delete to insert again."; } // if no errors at this point, continue with validation if(empty($errors)){ // all your form field validation code would go here, using elements in the $data array (a trimmed copy of the $_POST data) //validate here after declaring them //foreach ($_POST['specialization'] as $specialization) { // do stuff with $answerNum and $answer //} //validate the form inputs if ($data['name'] == "") { $errors[] = ("Name is required!"); } //check if introduction is blank if ($data['introduction'] == "") { $errors[] = ("Introduction is required!"); } //check if introduction is blank if ($data['email'] == "") { $errors[] = ("Email is required!"); } //check if contactNo is blank if ($data['contactNo'] == "") { $errors[] = ("Contact number is required!"); } //check if emailis valid if (filter_var($data['email'], FILTER_VALIDATE_EMAIL) === false) { $errors[] = ("Email is not valid."); } //validate if name is maxed number if (strlen($data['name']) > 50) { $errors[] = ("Name is too long!"); } //validate if name is maxed number if (strlen($data['introduction']) > 50) { $errors[] = ("Introduction is too long!"); } //validate if name is maxed number if (strlen($$data['email']) > 50) { $errors[] = ("Email is too long!"); } //check if contactNo is valid //checks for numeric, then check for 8 digits if(!is_numeric ($data['contactNo'])) { $errors[] = ("Contact number is invalid! All must be in numerics!"); } if(strlen(trim($data['contactNo'])) != { $errors[] = ("Contact number must be of 8 digits!"); } if (isset($data['specialization']) && $data['specialization'] == 'Specialization_1') { $data['specialization'] = "IS"; $skillset = ($selectedRBofISrow1.",".$selectedRBofISrow2.",".$selectedRBofISrow3.",".$selectedRBofISrow4.",".$selectedRBofISrow5); } if (isset($_POST['specialization']) && $_POST['specialization'] == 'Specialization_2') { $data['specialization'] = "IM"; $skillset = ($selectedRBofIMrow1.",".$selectedRBofIMrow2.",".$selectedRBofIMrow3.",".$selectedRBofIMrow4.",".$selectedRBofIMrow5); } if (isset($_POST['specialization']) && $_POST['specialization'] == 'Specialization_3') { $data['specialization']= "CNET"; $skillset = ($selectedRBofCNETrow1.",".$selectedRBofCNETrow2.",".$selectedRBofCNETrow3.",".$selectedRBofCNETrow4.",".$selectedRBofCNETrow5); } if (isset($_POST['specialization']) && $_POST['specialization'] == 'Specialization_4') { $data['specialization'] = "ITSM"; $skillset = ($selectedRBofITSMrow1.",".$selectedRBofITSMrow2.",".$selectedRBofITSMrow3.",".$selectedRBofITSMrow4.",".$selectedRBofITSMrow5); } //image $fileError = $_FILES['image']['error']; //validate if there's any error if($fileError > 0){ // header("Location:".$returnURL."?err=imgUploadError"); $errors[] = ("Error on uploading image!"); exit; } $data['maxSize'] = 100000; $fileSize = $_FILES['image']['size']; //validate image size if($fileSize > $data['maxSize']){ $errors[] = ("Image size is too big!"); // exit; } //get the temporary location of the file $fileTempName = $_FILES['image']['tmp_name']; $trueFileType = exif_imagetype($fileTempName); $allowedFiles = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG); if (in_array($trueFileType, $allowedFiles)) { switch($trueFileType){ case 1 : $fileExt = ".gif"; break; case 2: $fileExt = ".jpg"; break; case 3 : $fileExt = ".png"; break; } }else{ //header("Location:".$returnURL."?err=WrongFileType"); $errors[] = ("The one you've uploaded is not supported! Please check that it is in the right format."); exit; } // Get the path to upload the image to $myPathInfo = pathinfo($_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']); $currentDir = $myPathInfo['dirname']; $imgDir = $currentDir . '/profilePic/'; } I've tried to submit using an existing profile and it does show the error from the select query. However, when i log in to another user(no profile), the error "Undefined index:" for all the data[] is shown. I'm confused, hadn't i declare them? Or was that only validation? You pointed out that i shouldn't declare the variables on my post #12?
  8. Okay, i misinterpret before that i thought you said i should loop all the inputs inside the for each function. Okay so is this what you meant: $data = array_map('trim',$_POST); $name = $data[$name]; //= $_POST['name']; $description = $data[$description];// = $_POST['description']; $email = $data[$email]; // = $_POST['email']; $contactNo = $data[$contactNo]; // = $_POST['contactNo']; $dataArray = array_walk_recursive('trim', $_POST); $selectedRBofISrow1= $dataArray['ISGrp1']; //$_POST['ISgrp1']; I don't need to declare the $_POST? (Because i have put the name in the form as []). So, when i need to reference them , i just had to : if ($data['name'] == "") { $errors[] = ("Name is required!"); } could you explain me more on the array_walk_recursive? I'm not sure how to input the values in ><
  9. Pardon for my lack of knowledge( and my learning pace), but i'm still stuck on this array_map/array_walk_recursive(). i've went to the manual and even some of the forums but im still clueless as ever. Most of them uses array and declare the values, but how can i 'know' what the user will put in as value? I've been trial and error and it doesn't work.. Here are my trials: if ($_SERVER['REQUEST_METHOD'] == 'POST') { // array to hold errors $errors = array(); // copy and trim all post data (if the form has any arrays, you need to use a function like array_walk_recursive() instead of array_map()) //variables here $data = array_map('trim',$_POST); $data = array_map('trim',$_POST['name']); $data = array_map('trim',$_POST['description']); $data = array_map('trim',$_POST['email']); $data = array_map('trim',$_POST['contactNo']); $selectedRBofISrow1= $_POST['ISgrp1']; $selectedRBofISrow2= $_POST['ISgrp2']; $selectedRBofISrow3= $_POST['ISgrp3']; $selectedRBofISrow4= $_POST['ISgrp4']; $selectedRBofISrow5= $_POST['ISgrp5']; $selectedRBofIMrow1= $_POST['IMgrp1']; $selectedRBofIMrow2= $_POST['IMgrp2']; $selectedRBofIMrow3= $_POST['IMgrp3']; $selectedRBofIMrow4= $_POST['IMgrp4']; $selectedRBofIMrow5= $_POST['IMgrp5']; $selectedRBofCNETrow1= $_POST['CNETgrp1']; $selectedRBofCNETrow2= $_POST['CNETgrp2']; $selectedRBofCNETrow3= $_POST['CNETgrp3']; $selectedRBofCNETrow4= $_POST['CNETgrp4']; $selectedRBofCNETrow5= $_POST['CNETgrp5']; $selectedRBofITSMrow1= $_POST['ITSMgrp1']; $selectedRBofITSMrow2= $_POST['ITSMgrp2']; $selectedRBofITSMrow3= $_POST['ITSMgrp3']; $selectedRBofITSMrow4= $_POST['ITSMgrp4']; $selectedRBofITSMrow5= $_POST['ITSMgrp5']; array_walk_recursive($selectedRBofISrow1,"arrayValidate"); array_walk_recursive($selectedRBofISrow2,"arrayValidate"); array_walk_recursive($selectedRBofISrow3,"arrayValidate"); array_walk_recursive($selectedRBofISrow4,"arrayValidate"); array_walk_recursive($selectedRBofISrow5,"arrayValidate"); //$dataArray = array_walk_recursive('trim',$_POST); //$items = array(); foreach($key as $value) { $data[] = $name; $data[] = $description; $data[] = $email; $data[] = $contactNo; } print_r($data); //print_r($dataArray); //function validateTB() { // $name = array_map('trim', $_POST['name']); // $description = array_map('trim', $_POST['description']); // $email = array_map('trim', $_POST['email']); // $contactNo = array_map('trim', $_POST['contactNo']); // } // // $specialization = $_POST['specialization']; // $selectedRBofISrow1 = $_POST['ISgrp1']; // $selectedRBofISrow2 = $_POST['ISgrp2']; // $selectedRBofISrow3 = $_POST['ISgrp3']; // $selectedRBofISrow4 = $_POST['ISgrp4']; // $selectedRBofISrow5 = $_POST['ISgrp5']; // $selectedRBofIMrow1 = $_POST['IMgrp1']; // $selectedRBofIMrow2 = $_POST['IMgrp2']; // $selectedRBofIMrow3 = $_POST['IMgrp3']; // $selectedRBofIMrow4 = $_POST['IMgrp4']; // $selectedRBofIMrow5 = $_POST['IMgrp5']; // $selectedRBofCNETrow1 = $_POST['CNETgrp1']; // $selectedRBofCNETrow2 = $_POST['CNETgrp2']; // $selectedRBofCNETrow3 = $_POST['CNETgrp3']; // $selectedRBofCNETrow4 = $_POST['CNETgrp4']; // $selectedRBofCNETrow5 = $_POST['CNETgrp5']; // $selectedRBofITSMrow1 = $_POST['ITSMgrp1']; // $selectedRBofITSMrow2 = $_POST['ITSMgrp2']; // $selectedRBofITSMrow3 = $_POST['ITSMgrp3']; // $selectedRBofITSMrow4 = $_POST['ITSMgrp4']; // $selectedRBofITSMrow5 = $_POST['ITSMgrp5']; // $skillset = ""; // // // function arrayValidate($value,$key){ // $key = array_walk_recursive('trim', $value); // } // $selectedRBofISrow1=array("0"=>"C#-0","1"=>"C#-1","2"=>"C#-2","3"=>"C#-3","4"=>"C#-4","5"=>"C#-5"); // $selectedRBofISrow2=array("0"=>"PHP/SQL-0","1"=>"PHP/SQL-1","2"=>"PHP/SQL-2","3"=>"PHP/SQL-3","4"=>"PHP/SQL-4","5"=>"PHP/SQL-5"); // $selectedRBofISrow3=array("0"=>"HTML/CSS-0","1"=>"HTML/CSS-1","2"=>"HTML/CSS-2","3"=>"HTML/CSS-3","4"=>"HTML/CSS-4","5"=>"HTML/CSS-5"); // $selectedRBofISrow4=array("0"=>"Java Enterprise Development-0","1"=>"Java Enterprise Development-1","2"=>"Java Enterprise Development-2","3"=>"Java Enterprise Development-3","4"=>"Java Enterprise Development-4","5"=>"Java Enterprise Development-5"); // $selectedRBofISrow5=array("0"=>"Mobile Application Development-0","1"=>"Mobile Application Development-1","2"=>"Mobile Application Development-2","3"=>"Mobile Application Development-3","4"=>"Mobile Application Development-4","5"=>"Mobile Application Development-5"); // $selectedRBofISrow1=array("0"=>"Web Design-0","1"=>"Web Design-1","2"=>"Web Design-2","3"=>"Web Design-3","4"=>"Web Design-4","5"=>"Web Design-5"); // $selectedRBofIMrow2=array("0"=>"3D Modelling & Animations-0","1"=>"3D Modelling & Animations-1","2"=>"3D Modelling & Animations-2","3"=>"3D Modelling & Animations-3","4"=>"3D Modelling & Animations-4","5"=>"3D Modelling & Animations-5"); // $selectedRBofIMrow3=array("0"=>"PHP/SQL-0","1"=>"C#-1","2"=>"C#-2","3"=>"C#-3","4"=>"C#-4","5"=>"C#-5"); // $selectedRBofIMrow4=array("0"=>"PHP/SQL-0","1"=>"C#-1","2"=>"C#-2","3"=>"C#-3","4"=>"C#-4","5"=>"C#-5"); // $selectedRBofIMrow5=array("0"=>"PHP/SQL-0","1"=>"C#-1","2"=>"C#-2","3"=>"C#-3","4"=>"C#-4","5"=>"C#-5"); // $selectedRBofIMrow1=array("0"=>"PHP/SQL-0","1"=>"C#-1","2"=>"C#-2","3"=>"C#-3","4"=>"C#-4","5"=>"C#-5"); // $selectedRBofCNETrow2=array("0"=>"PHP/SQL-0","1"=>"C#-1","2"=>"C#-2","3"=>"C#-3","4"=>"C#-4","5"=>"C#-5"); // $selectedRBofCNETrow3=array("0"=>"PHP/SQL-0","1"=>"C#-1","2"=>"C#-2","3"=>"C#-3","4"=>"C#-4","5"=>"C#-5"); // $selectedRBofCNETrow4=array("0"=>"PHP/SQL-0","1"=>"C#-1","2"=>"C#-2","3"=>"C#-3","4"=>"C#-4","5"=>"C#-5"); // $selectedRBofCNETrow5=array("0"=>"PHP/SQL-0","1"=>"C#-1","2"=>"C#-2","3"=>"C#-3","4"=>"C#-4","5"=>"C#-5"); // $selectedRBofCNETrow1=array("0"=>"PHP/SQL-0","1"=>"C#-1","2"=>"C#-2","3"=>"C#-3","4"=>"C#-4","5"=>"C#-5"); // $selectedRBofITSMrow2=array("0"=>"PHP/SQL-0","1"=>"C#-1","2"=>"C#-2","3"=>"C#-3","4"=>"C#-4","5"=>"C#-5"); // $selectedRBofITSMrow3=array("0"=>"PHP/SQL-0","1"=>"C#-1","2"=>"C#-2","3"=>"C#-3","4"=>"C#-4","5"=>"C#-5"); // $selectedRBofITSMrow4=array("0"=>"PHP/SQL-0","1"=>"C#-1","2"=>"C#-2","3"=>"C#-3","4"=>"C#-4","5"=>"C#-5"); // $selectedRBofITSMrow5=array("0"=>"PHP/SQL-0","1"=>"C#-1","2"=>"C#-2","3"=>"C#-3","4"=>"C#-4","5"=>"C#-5"); // array_walk_recursive($selectedRBofISrow1,arrayValidate); // array_walk_recursive($selectedRBofISrow2,arrayValidate); // array_walk_recursive($selectedRBofISrow3,arrayValidate); // array_walk_recursive($selectedRBofISrow4,arrayValidate); // array_walk_recursive($selectedRBofISrow5,arrayValidate); // // array_walk_recursive($selectedRBofISrow1,arrayValidate); // array_walk_recursive($selectedRBofISrow2,arrayValidate); // array_walk_recursive($selectedRBofISrow3,arrayValidate); // array_walk_recursive($selectedRBofISrow4,arrayValidate); // array_walk_recursive($selectedRBofISrow5,arrayValidate); // // array_walk_recursive($selectedRBofISrow1,arrayValidate); // array_walk_recursive($selectedRBofISrow2,arrayValidate); // array_walk_recursive($selectedRBofISrow3,arrayValidate); // array_walk_recursive($selectedRBofISrow4,arrayValidate); // array_walk_recursive($selectedRBofISrow5,arrayValidate); // // array_walk_recursive($selectedRBofISrow1,arrayValidate); // array_walk_recursive($selectedRBofISrow2,arrayValidate); // array_walk_recursive($selectedRBofISrow3,arrayValidate); // array_walk_recursive($selectedRBofISrow4,arrayValidate); // array_walk_recursive($selectedRBofISrow5,arrayValidate); Did a few array on the some of the rows but i became confused.. Again, sorry if i took too long than i should
  10. Ah, thank you so much for this. I have a better picture on what's going on. It was stupid of me of not putting relations inside my database, sorry about that .-.
  11. Regarding this select query from your reply #4: // addprofileform form processing code - //check if there is an existing record in DB $query = "SELECT COUNT(*) FROM userProfile WHERE user_id = {$_SESSION['user_id']}"; I'm again confused myself. I have 2 tables actually, user( for login purposes), and userProfile(for the user profile). I have change my userProfile's primary key to be userProfileId, but how can this help to link to the session of my login? As far as i know, the id is auto incremented, so how can you tell if userProfileId is actually equal to the user_id of that particular user? They can be of different person, am i wrong? (This is probably also why i use username to identify). My user table has (id, name, email, username, password) while my userProfile has (userProfileId, username,picName, picPath, name, introduction,specialization, skillset, email, contactNo).
  12. Alright, i'm processing what you say as i move along with my codes. Currently,I have made changes to my database for the id to be the primary key. This is my database.php file: <?php //Use PDO statement try { $user = "root"; $pass = ""; $database = new PDO('mysql:host=localhost;dbname=final_year_project_1;charset=utf8', $user, $pass, array(PDO::ATTR_EMULATE_PREPARES => false,PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)); } catch (PDOException $ex) { echo 'Connection failed: ' . $ex->getMessage(); } ?> And the user login session/ logout session(the very top of my page before i put all the other codings) : <?php //initialize the session or import previous session session_start(); if(!isset($_SESSION['user_id']) || !isset($_SESSION['logged_in'])){ //User not logged in. Redirect them back to the login.php page. header('Location:AccountLogin.php'); exit; } else { $now = time(); // Checking the time now when home page starts. if ($now > $_SESSION['expire']) { session_destroy(); echo "<div style=\"color: red;\">Your session has expired!<br><a href = 'AccountLogin.php'>Login here</a></div>"; } } // else { // //if exist, show welcome thing // echo ("User: ".($_SESSION['MM_Username'])." ".($_SESSION['MM_UserGroup']). " has login successfully."); // } // ** Logout the current user. ** $logoutAction = $_SERVER['PHP_SELF']."?doLogout=true"; if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){ $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){ //to fully log out a visitor we need to clear the session varialbles $_SESSION['user_id'] = NULL; $_SESSION['logged_in'] = NULL; $_SESSION['PrevUrl'] = NULL; unset($_SESSION['user_id']); unset($_SESSION['logged_in']); unset($_SESSION['PrevUrl']); $logoutGoTo = "AccountLogin.php"; if ($logoutGoTo) { header("Location: $logoutGoTo"); exit; die; } } ?> Thanks again for your explanation. I will work on my code now and will update you what i've progressed soon.
  13. Thank you for your detailed explanation mac_gyver. I will get back to you after processing your explanation since my code is not saved in my current desktop i'm using. I would like to clarify about some things that you said. For #item 1: 1)I do have the login session for the user, but i didn't put that in here since the coding was already long and i was just wondering about the error i've gotten. Either way, i will post my code once i get to my other desktop since it's late here. 2)Yes, this form was actually in the request==$_POST (code line 32). The select statement before it was to check if the user has already have data in the database since this profile is limit to 1 per user. I'm not entirely sure as to what i should do as i wanted the user to be prompt an error message of some sort if the user landed on this add profile page when he/she already has a data inside. 3)Okay thanks, i had my database set to my username as the primary key >< i will take note of this. 4) Okay, i might have been confused with this. Am i right to say that select statement can be used as a normal query(?) because since there's no input, no one can hack (sql injection)? 5)Ahh..so that was why it didn't show the error in the first place! Thanks about this my database does have an error handling,but no try/catch. I will correct it tmr. 6)I initially thought i could just declare my $username because that was my primary key. Based on [3)], this also caused the problem. 7)I'm confused about this one. Basically, the user are not supposed to change the username, thus i leave that field out(even the form i did not declare this). The UPDATE query will have to be check tmr as I too am not sure about this one ><. 8)I see, thank you for pointing this out. So to clarify, fetchColumn does not take the column of the "WHERE....", just the first column? 9) May i ask as to where have i repeated the values? In this case, is it the radio group? 10)Okay, i'll take note of this too ^^ 11)Sorry, my bad. I used to do those brackets because it was a habit that my teacher used to say so that it will look neater in a way. I'll take note of this too! 12)I'm sorry, this was taken from an open source, but isn't the variables declared in?(line 605) For the username, it was my mistake for the primary key to be a username. 13)Thank you about that, i've forgotten to declare it >< 14)Okay, i will implement that array. Just to clarify, for this array, is it suppose to be all form fields? I have declare some error message starting from line 70.. Anyways, are the values the one that will be inserted to database for the radio buttons? I do want the radio button's value, but having a long value is quite troublesome o.o Thank you once again, i'm really grateful for your help i will let you know once i've changed my codes [One last noob question: Is it better to have php codes in different pages than the html page itself or all in one page? I am writing all in one page( except for the database.php) and i'm abit confused if i were to seperate them, do i need to declare the variables again or do i just need to include the file?]
  14. I am trying to insert my inputs of my profile to my database. I've some difficulties which are The php code ignores my select statement even though there is a data inside my database. My radio button group was somehow declared undefined.( and the 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'skillset' cannot be null' error') My image uploading isn't really working This is my php code: <?php //START OF ADDING FORM //connect to database require_once('Connections/database.php'); $addProfileForm = $_SERVER['PHP_SELF']; //Setup an empty array for errors $errors = array(); //check if there is an existing record in DB $query = "SELECT * FROM `userProfile` WHERE `username` in ( select username from users where id = ".($_SESSION['user_id']).")"; $statement = $database->prepare($query); if($statement === false){ print_r("Error executing the query"); exit(); } //The Primary Key of the row that we want to select. $username = 1; //Bind our value to the paramater :id. $statement->bindValue(':id', $username); //Execute our SELECT statement. $statement->execute(); //check if there is a row $number_of_rows = $statement->fetchColumn(); if ($number_of_rows > 1) { print_r ("There is an existing record. You cannot insert another profile! Either update the old one, or delete to insert again."); } else { //if (isset($_POST['Submit'])) { if ($_SERVER['REQUEST_METHOD'] == 'POST') { //check all $_POST echo '<pre>'; print_r($_POST); echo '<pre>'; //declare all variables first $name = $_POST['name']; //name of the radioGrp $specialization = $_POST['specialization']; $introduction = $_POST['introduction']; $email = $_POST['email']; $contactNo = $_POST['contactNo']; //Radio buttons // $selectedRBofISrow1 = $_POST['ISgrp1']; // $selectedRBofISrow2 = $_POST['ISgrp2']; // $selectedRBofISrow3 = $_POST['ISgrp3']; // $selectedRBofISrow4 = $_POST['ISgrp4']; // $selectedRBofISrow5 = $_POST['ISgrp5']; // $selectedRBofIMrow1 = $_POST['IMgrp1']; // $selectedRBofIMrow2 = $_POST['IMgrp2']; // $selectedRBofIMrow3 = $_POST['IMgrp3']; // $selectedRBofIMrow4 = $_POST['IMgrp4']; // $selectedRBofIMrow5 = $_POST['IMgrp5']; // $selectedRBofCNETrow1 = $_POST['CNETgrp1']; // $selectedRBofCNETrow2 = $_POST['CNETgrp2']; // $selectedRBofCNETrow3 = $_POST['CNETgrp3']; // $selectedRBofCNETrow4 = $_POST['CNETgrp4']; // $selectedRBofCNETrow5 = $_POST['CNETgrp5']; // $selectedRBofITSMrow1 = $_POST['ITSMgrp1']; // $selectedRBofITSMrow2 = $_POST['ITSMgrp2']; // $selectedRBofITSMrow3 = $_POST['ITSMgrp3']; // $selectedRBofITSMrow4 = $_POST['ITSMgrp4']; // $selectedRBofITSMrow5 = $_POST['ITSMgrp5']; //$fileImage = $_FILES['image']['tmp_name']; if ((trim($name)) == "") { $errors[] = ("Name is required!"); //exit(); } //check if introduction is blank if ((trim($introduction)) == "") { $errors[] = ("Introduction is required!"); //exit(); } //check if introduction is blank if ((trim($email)) == "") { $errors[] = ("Email is required!"); //exit(); } //check if emailis valid if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) { $errors[] = ("Email is not valid."); } //check if contactNo is blank if ((trim($contactNo)) == "") { $errors[] = ("Contact number is required!"); //exit(); } //check if contactNo is valid //checks for numeric, then check for 8 digits if(!is_numeric ($contactNo)) { $errors[] = ("Contact number is invalid! All must be in numerics!"); //exit(); } if(strlen(trim($contactNo)) != { $errors[] = ("Contact number must be of 8 digits!"); //exit(); } if (sizeof($errors) > 0) { foreach($errors as $error) { printf("<li>%s</li>", $error); //exit(); } } else { //declare specialization, it will NOT be blank as we have declare it to be checked. if (isset($_POST['specialization']) && $_POST['specialization'] == 'Specialization_1') { $specialization = "IS"; //Check for first row if($_POST['ISgrp1'] == 'C#-0') { $selectedRBofISrow1 = 'C#-0'; } else if ($_POST['ISgrp1'] == 'C#-1') { $selectedRBofISrow1 = 'C#-1'; } else if ($_POST['ISgrp1'] == 'C#-2') { $selectedRBofISrow1 = 'C#-2'; } else if ($_POST['ISgrp1'] == 'C#-3') { $selectedRBofISrow1 = 'C#-3'; } else if ($_POST['ISgrp1'] == 'C#-4') { $selectedRBofISrow1 = 'C#-4'; } else if ($_POST['ISgrp1'] == 'C#-5') { $selectedRBofISrow1 = 'C#-5'; } //Check for second row if($_POST['ISgrp2'] == 'php-0') { $selectedRBofISrow2 = 'php-0'; } else if ($_POST['ISgrp2'] == 'php-1') { $selectedRBofISrow2 = 'php-1'; } else if ($_POST['ISgrp2'] == 'php-2') { $selectedRBofISrow2 = 'php-2'; } else if ($_POST['ISgrp2'] == 'php-3') { $selectedRBofISrow2 = 'php-3'; } else if ($_POST['ISgrp2'] == 'php-4') { $selectedRBofISrow2 = 'php-4'; } else if ($_POST['ISgrp2'] == 'php-5') { $selectedRBofISrow2 = 'php-5'; } //Check for third row if($_POST['ISgrp3'] == 'HTML-0') { $selectedRBofISrow3 = 'HTML-0'; } else if ($_POST['ISgrp3'] == 'HTML-1') { $selectedRBofISrow3 = 'HTML-1'; } else if ($_POST['ISgrp3'] == 'HTML-2') { $selectedRBofISrow3 = 'HTML-2'; } else if ($_POST['ISgrp3'] == 'HTML-3') { $selectedRBofISrow3 = 'HTML-3'; } else if ($_POST['ISgrp3'] == 'HTML-4') { $selectedRBofISrow3 = 'HTML-4'; } else if ($_POST['ISgrp3'] == 'HTML-5') { $selectedRBofISrow3 = 'HTML-5'; } //Check for fourth row if($_POST['ISgrp4'] == 'Java-0') { $selectedRBofISrow4 = 'Java-0'; } else if ($_POST['ISgrp4'] == 'Java-1') { $selectedRBofISrow4 = 'Java-1'; } else if ($_POST['ISgrp4'] == 'Java-2') { $selectedRBofISrow4 = 'Java-2'; } else if ($_POST['ISgrp4'] == 'Java-3') { $selectedRBofISrow4 = 'Java-3'; } else if ($_POST['ISgrp4'] == 'Java-4') { $selectedRBofISrow4 = 'Java-4'; } else if ($_POST['ISgrp4'] == 'Java-5') { $selectedRBofISrow4 = 'Java-5'; } //Check for fifth row if($_POST['ISgrp5'] == 'MAD-0') { $selectedRBofISrow5 = 'MAD-0'; } else if ($_POST['ISgrp5'] == 'MAD-1') { $selectedRBofISrow5 = 'php-1'; } else if ($_POST['ISgrp5'] == 'MAD-2') { $selectedRBofISrow5 = 'MAD-2'; } else if ($_POST['ISgrp5'] == 'MAD-3') { $selectedRBofISrow5 = 'MAD-3'; } else if ($_POST['ISgrp5'] == 'MAD-4') { $selectedRBofISrow5 = 'MAD-4'; } else if ($_POST['ISgrp5'] == 'MAD-5') { $selectedRBofISrow5 = 'MAD-5'; } $skillset = ($selectedRBofISrow1 . $selectedRBofISrow2 . $selectedRBofISrow3 . $selectedRBofISrow4 . $selectedRBofISrow5); //put the skillsets code here? // $valueOfSkillsets = ($selectedRBofISrow1 .$selectedRBofISrow2 //.$selectedRBofISrow3 .$selectedRBofISrow4. $selectedRBofISrow5); } else if (isset($_POST['specialization']) && $_POST['specialization'] == 'Specialization_2') { $specialization = "IM"; //Check for first row if($_POST['IMgrp1'] == 'Web Design-0') { $selectedRBofIMrow1 = "Web Design-0"; } else if ($_POST['IMgrp1'] == "Web Design-1") { $selectedRBofIMrow1 = 'Web Design-1'; } else if ($_POST['IMgrp1'] == "Web Design-2") { $selectedRBofIMrow1 = 'Web Design-2'; } else if ($_POST['IMgrp1'] == "Web Design-3") { $selectedRBofIMrow1 = 'Web Design-3'; } else if ($_POST['IMgrp1'] == "Web Design-4") { $selectedRBofIMrow1 = "Web Design-4"; } else if ($_POST['IMgrp1'] == "Web Design-5") { $selectedRBofIMrow1 = "Web Design-5"; } //Check for second row if($_POST['IMgrp2'] == "3Dmodelling-0") { $selectedRBofIMrow1 = "3Dmodelling-0"; } else if ($_POST['IMgrp2'] == "3Dmodelling-1") { $selectedRBofIMrow1 = "3Dmodelling-1"; } else if ($_POST['IMgrp2'] == "3Dmodelling-2") { $selectedRBofIMrow1 = "3Dmodelling-2"; } else if ($_POST['IMgrp2'] == "3Dmodelling-3") { $selectedRBofIMrow1 = "3Dmodelling-3"; } else if ($_POST['IMgrp2'] == "3Dmodelling-4") { $selectedRBofIMrow1 = "3Dmodelling-4"; } else if ($_POST['IMgrp2'] == "3Dmodelling-5") { $selectedRBofIMrow1 = "3Dmodelling-5"; } //Check for third row if($_POST['IMgrp3'] == "Graphic Design-0") { $selectedRBofIMrow1 = "Graphic Design-0"; } else if ($_POST['IMgrp3'] == "Graphic Design-1") { $selectedRBofIMrow1 = "Graphic Design-1"; } else if ($_POST['IMgrp3'] == "Graphic Design-2") { $selectedRBofIMrow1 = "Graphic Design-2"; } else if ($_POST['IMgrp3'] == " Design-3") { $selectedRBofIMrow1 = "Graphic Design-3"; } else if ($_POST['IMgrp3'] == "Graphic Design-4") { $selectedRBofIMrow1 = "Graphic Design-4"; } else if ($_POST['IMgrp3'] == "Graphic Design-5") { $selectedRBofIMrow1 = "Graphic Design-5"; } //Check for fourth row if($_POST['IMgrp4'] == "VideoEditing-0") { $selectedRBofIMrow1 = "VideoEditing-0"; } else if ($_POST['IMgrp4'] == "VideoEditing-1") { $selectedRBofIMrow1 = "VideoEditing-1"; } else if ($_POST['IMgrp4'] == "VideoEditing-2") { $selectedRBofIMrow1 = "VideoEditing-2"; } else if ($_POST['IMgrp4'] == "VideoEditing-3") { $selectedRBofIMrow1 = "VideoEditing-3"; } else if ($_POST['IMgrp4'] == "VideoEditing-4") { $selectedRBofIMrow1 = "VideoEditing-4"; } else if ($_POST['IMgrp4'] == "VideoEditing-5") { $selectedRBofIMrow1 = "VideoEditing-5"; } //Check for fifth row if($_POST['IMgrp5'] == "motionGraphics-0") { $selectedRBofIMrow1 = "motionGraphics-0"; } else if ($_POST['IMgrp5'] == "motionGraphics-1") { $selectedRBofIMrow1 = "motionGraphics-1"; } else if ($_POST['IMgrp5'] == "motionGraphics-2") { $selectedRBofIMrow1 = "motionGraphics-2"; } else if ($_POST['IMgrp5'] == "motionGraphics-3") { $selectedRBofIMrow1 = "motionGraphics-3"; } else if ($_POST['IMgrp5'] == "motionGraphics-4") { $selectedRBofIMrow1 = "motionGraphics-4"; } else if ($_POST['IMgrp5'] == "motionGraphics-5") { $selectedRBofIMrow1 = "motionGraphics-5"; } $skillset = ($selectedRBofIMrow1 . $selectedRBofIMrow2 . $selectedRBofIMrow3 . $selectedRBofISrow4 . $selectedRBofISrow5); //put the skillsets code here? //$valueOfSkillsets =($selectedRBofIMrow1. $selectedRBofIMrow2 //.$selectedRBofIMrow3 .$selectedRBofIMrow4.$selectedRBofIMrow5); } else if (isset($_POST['specialization']) && $_POST['specialization'] == 'Specialization_3') { $specialization = "CNET"; //Check for first row if($_POST['CNETgrp1'] == "networkSecurity-0") { $selectedRBofCNETrow1 = "networkSecurity-0"; } else if ($_POST['CNETgrp1'] == "networkSecurity-1") { $selectedRBofCNETrow1 = "networkSecurity-1"; } else if ($_POST['CNETgrp1'] == "networkSecurity-2") { $selectedRBofCNETrow1 = "networkSecurity-2"; } else if ($_POST['CNETgrp1'] == "networkSecurity-3") { $selectedRBofCNETrow1 = "networkSecurity-3"; } else if ($_POST['CNETgrp1'] == "networkSecurity-4") { $selectedRBofCNETrow1 = "networkSecurity-4"; } else if ($_POST['CNETgrp1'] == "networkSecurity-5") { $selectedRBofCNETrow1 = "networkSecurity-5"; } //Check for second row if($_POST['CNETgrp2'] == "RBNetworkDesign-0") { $selectedRBofCNETrow1 = "RBNetworkDesign-0"; } else if ($_POST['CNETgrp2'] == "RBNetworkDesign-1") { $selectedRBofCNETrow1 = "RBNetworkDesign-1"; } else if ($_POST['CNETgrp2'] == "RBNetworkDesign-2") { $selectedRBofCNETrow1 = "RBNetworkDesign-2"; } else if ($_POST['CNETgrp2'] == "RBNetworkDesign-3") { $selectedRBofCNETrow1 = "RBNetworkDesign-3"; } else if ($_POST['CNETgrp2'] == "RBNetworkDesign-4") { $selectedRBofCNETrow1 = "RBNetworkDesign-4"; } else if ($_POST['CNETgrp2'] == "RBNetworkDesign-5") { $selectedRBofCNETrow1 = "RBNetworkDesign-5"; } //Check for third row if($_POST['CNETgrp3'] == "BroadbandAccess-0") { $selectedRBofCNETrow1 = "BroadbandAccess-0"; } else if ($_POST['CNETgrp3'] == "BroadbandAccess-1") { $selectedRBofCNETrow1 = "BroadbandAccess-1"; } else if ($_POST['CNETgrp3'] == "BroadbandAccess-2") { $selectedRBofCNETrow1 = "BroadbandAccess-2"; } else if ($_POST['CNETgrp3'] == "BroadbandAccess-3") { $selectedRBofCNETrow1 = "BroadbandAccess-3"; } else if ($_POST['CNETgrp3'] == "BroadbandAccess-4") { $selectedRBofCNETrow1 = "BroadbandAccess-4"; } else if ($_POST['CNETgrp3'] == "BroadbandAccess-5") { $selectedRBofCNETrow1 = "BroadbandAccess-5"; } //Check for fourth row if($_POST['CNETgrp4'] == "ICTInfrastructureManagement-0") { $selectedRBofCNETrow1 = "ICTInfrastructureManagement-0"; } else if ($_POST['CNETgrp4'] == "ICTInfrastructureManagement-1") { $selectedRBofCNETrow1 = "ICTInfrastructureManagement-1"; } else if ($_POST['CNETgrp4'] == "ICTInfrastructureManagement-2") { $selectedRBofCNETrow1 = "ICTInfrastructureManagement-2"; } else if ($_POST['CNETgrp4'] == "ICTInfrastructureManagement-3") { $selectedRBofCNETrow1 = "ICTInfrastructureManagement-3"; } else if ($_POST['CNETgrp4'] == "ICTInfrastructureManagement-4") { $selectedRBofCNETrow1 = "ICTInfrastructureManagement-4"; } else if ($_POST['CNETgrp4'] == "ICTInfrastructureManagement-5") { $selectedRBofCNETrow1 = "ICTInfrastructureManagement-5"; } //Check for fifth row if($_POST['CNETgrp5'] == "motionGraphics-0") { $selectedRBofCNETrow1 = "Technopreneurship-0"; } else if ($_POST['CNETgrp5'] == "Technopreneurship-1") { $selectedRBofCNETrow1 = "Technopreneurship-1"; } else if ($_POST['CNETgrp5'] == "Technopreneurship-2") { $selectedRBofCNETrow1 = "Technopreneurship-2"; } else if ($_POST['CNETgrp5'] == "Technopreneurship-3") { $selectedRBofCNETrow1 = "Technopreneurship-3"; } else if ($_POST['CNETgrp5'] == "Technopreneurship-4") { $selectedRBofCNETrow1 = "Technopreneurship-4"; } else if ($_POST['CNETgrp5'] == "Technopreneurship-5") { $selectedRBofCNETrow1 = "Technopreneurship-5"; } $skillset = ($selectedRBofCNETrow1 . $selectedRBofCNETrow2 . $selectedRBofCNETrow3 . $selectedRBofCNETrow4 . $selectedRBofCNETrow5); //put the skillsets code here? //$valueOfSkillsets =($selectedRBofCNETrow1. $selectedRBofCNETrow2 //.$selectedRBofCNETrow3 .$selectedRBofCNETrow4.$selectedRBofCNETrow5); } else if (isset($_POST['specialization']) && $_POST['specialization'] == 'Specialization_4') { $specialization = "ITSM"; //Check for first row if($_POST['ITSMgrp1'] == "virtualisation-0") { $selectedRBofITSMrow1 = "virtualisation-0"; } else if ($_POST['ITSMgrp1'] == "virtualisation-1") { $selectedRBofITSMrow1 = "virtualisation-1"; } else if ($_POST['ITSMgrp1'] == "virtualisation-2") { $selectedRBofITSMrow1 = "virtualisation-2"; } else if ($_POST['ITSMgrp1'] == "virtualisation-3") { $selectedRBofCNETrow1 = "networkSecurity-3"; } else if ($_POST['ITSMgrp1'] == "virtualisation-4") { $selectedRBofITSMrow1 = "virtualisation-4"; } else if ($_POST['ITSMgrp1'] == "virtualisation-5") { $selectedRBofITSMrow1 = "virtualisation-5"; } //Check for second row if($_POST['ITSMgrp2'] == "ITSM-0") { $selectedRBofITSMrow1 = "ITSM-0"; } else if ($_POST['ITSMgrp2'] == "ITSM-1") { $selectedRBofITSMrow1 = "ITSM-1"; } else if ($_POST['ITSMgrp2'] == "ITSM-2") { $selectedRBofITSMrow1 = "ITSM-2"; } else if ($_POST['ITSMgrp2'] == "ITSM-3") { $selectedRBofITSMrow1 = "ITSM-3"; } else if ($_POST['ITSMgrp2'] == "ITSM-4") { $selectedRBofITSMrow1 = "ITSM-4"; } else if ($_POST['ITSMgrp2'] == "ITSM-5") { $selectedRBofITSMrow1 = "ITSM-5"; } //Check for third row if($_POST['ITSMgrp3'] == "serverAdministration-0") { $selectedRBofITSMrow1 = "serverAdministration-0"; } else if ($_POST['ITSMgrp3'] == "serverAdministration-1") { $selectedRBofITSMrow1 = "serverAdministration-1"; } else if ($_POST['ITSMgrp3'] == "serverAdministration-2") { $selectedRBofITSMrow1 = "serverAdministration-2"; } else if ($_POST['ITSMgrp3'] == "serverAdministration-3") { $selectedRBofITSMrow1 = "serverAdministration-3"; } else if ($_POST['ITSMgrp3'] == "serverAdministration-4") { $selectedRBofITSMrow1 = "serverAdministration-4"; } else if ($_POST['ITSMgrp3'] == "serverAdministration-5") { $selectedRBofITSMrow1 = "serverAdministration-5"; } //Check for fourth row if($_POST['ITSMgrp4'] == "DatabaseAdministration&Management-0") { $selectedRBofITSMrow1 = "DatabaseAdministration&Management-0"; } else if ($_POST['ITSMgrp4'] == "DatabaseAdministration&Management-1") { $selectedRBofITSMrow1 = "DatabaseAdministration&Management-1"; } else if ($_POST['ITSMgrp4'] == "DatabaseAdministration&Management-2") { $selectedRBofITSMrow1 = "DatabaseAdministration&Management-2"; } else if ($_POST['ITSMgrp4'] == "DatabaseAdministration&Management-3") { $selectedRBofITSMrow1 = "DatabaseAdministration&Management-3"; } else if ($_POST['ITSMgrp4'] == "DatabaseAdministration&Management-4") { $selectedRBofITSMrow1 = "DatabaseAdministration&Management-4"; } else if ($_POST['ITSMgrp4'] == "DatabaseAdministration&Management-5") { $selectedRBofITSMrow1 = "DatabaseAdministration&Management-5"; } //Check for fifth row if($_POST['ITSMgrp5'] == "InternetofThingsAppDevelopment-0") { $selectedRBofITSMrow1 = "InternetofThingsAppDevelopment-0"; } else if ($_POST['ITSMgrp5'] == "InternetofThingsAppDevelopment-1") { $selectedRBofITSMrow1 = "InternetofThingsAppDevelopment-1"; } else if ($_POST['ITSMgrp5'] == "InternetofThingsAppDevelopment-2") { $selectedRBofITSMrow1 = "InternetofThingsAppDevelopment-2"; } else if ($_POST['ITSMrp5'] == "InternetofThingsAppDevelopment-3") { $selectedRBofCITSMrow1 = "InternetofThingsAppDevelopment-3"; } else if ($_POST['ITSMgrp5'] == "InternetofThingsAppDevelopment-4") { $selectedRBofITSMrow1 = "InternetofThingsAppDevelopment-4"; } else if ($_POST['ITSMgrp5'] == "InternetofThingsAppDevelopment-5") { $selectedRBofITSMrow1 = "InternetofThingsAppDevelopment-5"; } $skillset = ($selectedRBofITSMrow1 . $selectedRBofITSMrow2 . $selectedRBofITSMrow3 . $selectedRBofITSMrow4 . $selectedRBofITSMrow5); //put the skillsets code here? //$valueOfSkillsets = ($selectedRBofITSMrow1 .$selectedRBofITSMrow2 //.$selectedRBofITSMrow3 .$selectedRBofITSMrow4. $selectedRBofITSMrow5); } //value of skillsets to be put here?? //if(isset($_POST['specialization'])){ // if($_POST['specialization'] == 'Specialization_1') { // $specialization = "IS"; // //put the skillsets code here? // $valueOfSkillsets = ($selectedRBofISrow1 .$selectedRBofISrow2 // .$selectedRBofISrow3 .$selectedRBofISrow4. $selectedRBofISrow5); // } // else if($_POST['specialization'] == 'Specialization_2') { // $specialization = "IM"; // //put the skillsets code here? // $valueOfSkillsets =($selectedRBofIMrow1. $selectedRBofIMrow2 // .$selectedRBofIMrow3 .$selectedRBofIMrow4.$selectedRBofIMrow5); // } // else if($_POST['specialization'] == 'Specialization_3') { // $specialization = "ITSM"; // //put the skillsets code here? // $valueOfSkillsets =($selectedRBofCNETrow1. $selectedRBofCNETrow2 // .$selectedRBofCNETrow3 .$selectedRBofCNETrow4.$selectedRBofCNETrow5); // } // else if($_POST['specialization'] == 'Specialization_4') { // $specialization = "CNET"; // //put the skillsets code here? // $valueOfSkillsets =($selectedRBofITSMrow1. $selectedRBofITSMrow2 // .$selectedRBofITSMrow3 .$selectedRBofITSMrow4.$selectedRBofITSMrow5); // } // //} $fileError = $_FILES['image']['error']; //validate if there's any error if($fileError > 0){ // header("Location:".$returnURL."?err=imgUploadError"); $errors[] = ("Error on uploading image!"); exit; } $maxSize = 100000; $fileSize = $_FILES['image']['size']; //validate image size if($fileSize > $maxSize){ $errors[] = ("Image size is too big!"); // exit; } //get the temporary location of the file $fileTempName = $_FILES['image']['tmp_name']; $trueFileType = exif_imagetype($fileTempName); $allowedFiles = array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG); if (in_array($trueFileType, $allowedFiles)) { switch($trueFileType){ case 1 : $fileExt = ".gif"; break; case 2: $fileExt = ".jpg"; break; case 3 : $fileExt = ".png"; break; } }else{ //header("Location:".$returnURL."?err=WrongFileType"); $errors[] = ("The one you've uploaded is not supported! Please check that it is in the right format."); exit; } // Get the path to upload the image to $myPathInfo = pathinfo($_SERVER['DOCUMENT_ROOT'].$_SERVER['PHP_SELF']); $currentDir = $myPathInfo['dirname']; $imgDir = $currentDir . '/profilePic/'; // Insert the other data into the database, get the new ID and create the new filename $stmt = $database->prepare("INSERT INTO userProfile (picName, picPath, Name, introduction, Specialization,skillset, Email, ContactNo) VALUES (:picName,:picPath,:Name,:introduction,:Specialization,:skillset,:Email,:ContactNo)"); $stmt->bindValue(':picName',$_FILES['image']['name']); $stmt->bindValue(':picPath', $imgDir); $stmt->bindValue(':Name', $name); $stmt->bindValue(':introduction', $introduction); $stmt->bindValue(':Specialization', $specialization); $stmt->bindValue(':skillset', $skillset); $stmt->bindValue(':Email', $email); $stmt->bindValue(':ContactNo', $contactNo); $stmt->execute(); $newID = $stmt->insert_id; $newFileName = $newID . $fileExt; $stmt->close(); // Update the database with the new image filename $stmt = $database->prepare("UPDATE userProfile SET picName = :newFileName WHERE id = ".($_SESSION['user_id']).")"); //The Primary Key of the row that we want to select. $username = 1; //Bind our value to the paramater $statement->bindValue(':id', $username); $stmt->bindValue(':newFileName', $newFileName); $stmt->bindValue('id',$username); $stmt->execute(); if ($database->query($stmt) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $stmt . "<br>" . $database->error; } $stmt->close(); // Move the file and redirect $newImgLocation = $imgDir . $newFileName; if(move_uploaded_file($fileTempName, $newImgLocation)){ header("Location:".$returnURL); }else{ header("Location:".$returnURL."?err=UploadProb"); } } //$fileImage = $_FILES['imageField']['tmpName']; //Check if the user did upload image // if (isset($_FILES['imageField']) && $_FILES['imageField']['size'] > 0) { // // $image = addslashes(file_get_contents($_FILES['imageField']['tmpName'])); // $image_name = addslashes($_FILES['imageField']['name']); // // // Temporary file name stored on the server // $tmpName = $_FILES['imagefield']['tmp_name']; // // Read the file // $fp = fopen($tmpName, 'r'); // $data = fread($fp, filesize($tmpName)); // } // else { // try { // $msg = upload(); // function calling to upload an image // echo $msg; // } // catch(Exception $e) { // echo $e->getMessage(); // echo 'Sorry, Could not upload file'; // } // } // // function file_upload_error_message($error_code) { // switch ($error_code) { // case UPLOAD_ERR_INI_SIZE: // return 'The uploaded file exceeds the upload_max_filesize directive in php.ini'; // case UPLOAD_ERR_FORM_SIZE: // return 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'; // case UPLOAD_ERR_PARTIAL: // return 'The uploaded file was only partially uploaded'; // case UPLOAD_ERR_NO_FILE: // return 'No file was uploaded'; // case UPLOAD_ERR_NO_TMP_DIR: // return 'Missing a temporary folder'; // case UPLOAD_ERR_CANT_WRITE: // return 'Failed to write file to disk'; // case UPLOAD_ERR_EXTENSION: // return 'File upload stopped by extension'; // default: // return 'Unknown upload error'; // } // } // if (!isset ($file)) { // $errors[] = "Please select an image"; // } // //check if the user has uploaded image // else if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) { // $image = addslashes(file_get_contents($_FILES['image']['tmp_name'])); // $image_name = addslashes($_FILES ['image']['name']); // $image_size = getimagesize ($_FILES ['image']['tmp_name']); // $image_path = "profilePic/".basename($image_name); // File destination // // if ($image_size == FALSE) // print "That's not an image"; // // else // { // //uploading the image file with the image file name into the directory. // if(move_uploaded_file($image_name, $image_path)) // echo "File uploaded"; // // if (!$stmt = $database->prepare("INSERT picName,picPath INTO userProfile VALUES('$image_name', '$image_path')")) { // print "Problem uploading image"; // exit(); // } // // } // // } //check if name is blank //put in the query. No need to connect to database as database alr declared at the top. // $sql = "INSERT INTO userProfile (picName, picPath, Name, introduction, Specialization,skillset, Email, ContactNo) VALUES // ($image_name,$image_path,$name,$introduction,$specialization, $skillset, $email, $contactNo)"; // //if ($database->query($sql) === TRUE) { // echo "New record created successfully"; //} else { // echo "Error: " . $sql . "<br>" . $database->error; //} // //$database->close(); //close bracket of select statement } //close bracket for request post } ?> Here's my html form: <!doctype html> <html> <head> <meta charset="utf-8"> <title>Add Profile</title> <link href="css/profile.css" rel="stylesheet" type="text/css"> <link rel="stylesheet" href="css/ajxmenu-profile.css" type="text/css"> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> //For toggling the radio buttons. //Cant toggle between rows, so have to set up <tr> manually $(document).ready(function () { //start straightaway for IS rb checked $("#specialization_1").trigger("click"); //hide the other rows and show only the IS rows $('#IMrow1,#IMrow2,#IMrow3,#IMrow4,#IMrow5,#CNETrow1,#CNETrow2,#CNETrow3,#CNETrow4, #CNETrow5,#ITSMrow1,#ITSMrow2,#ITSMrow3,#ITSMrow4,#ITSMrow5').hide(); //When IS rb is clicked,only show IS $('#specialization_1').click(function () { //add 'fast' if want see action $('#ISrow1').show(); $('#ISrow2').show(); $('#ISrow3').show(); $('#ISrow4').show(); $('#ISrow5').show(); $('#IMrow1').hide(); $('#IMrow2').hide(); $('#IMrow3').hide(); $('#IMrow4').hide(); $('#IMrow5').hide(); $('#CNETrow1').hide(); $('#CNETrow2').hide(); $('#CNETrow3').hide(); $('#CNETrow4').hide(); $('#CNETrow5').hide(); $('#ITSMrow1').hide(); $('#ITSMrow2').hide(); $('#ITSMrow3').hide(); $('#ITSMrow4').hide(); $('#ITSMrow5').hide(); }); //When IM rb is clicked,only show IS $('#specialization_2').click(function () { $('#ISrow1').hide(); $('#ISrow2').hide(); $('#ISrow3').hide(); $('#ISrow4').hide(); $('#ISrow5').hide(); $('#IMrow1').show(); $('#IMrow2').show(); $('#IMrow3').show(); $('#IMrow4').show(); $('#IMrow5').show(); $('#CNETrow1').hide(); $('#CNETrow2').hide(); $('#CNETrow3').hide(); $('#CNETrow4').hide(); $('#CNETrow5').hide(); $('#ITSMrow1').hide(); $('#ITSMrow2').hide(); $('#ITSMrow3').hide(); $('#ITSMrow4').hide(); $('#ITSMrow5').hide(); }); //When CNET rb is clicked,only show IS $('#specialization_3').click(function () { $('#ISrow1').hide(); $('#ISrow2').hide(); $('#ISrow3').hide(); $('#ISrow4').hide(); $('#ISrow5').hide(); $('#IMrow1').hide(); $('#IMrow2').hide(); $('#IMrow3').hide(); $('#IMrow4').hide(); $('#IMrow5').hide(); $('#CNETrow1').show(); $('#CNETrow2').show(); $('#CNETrow3').show(); $('#CNETrow4').show(); $('#CNETrow5').show(); $('#ITSMrow1').hide(); $('#ITSMrow2').hide(); $('#ITSMrow3').hide(); $('#ITSMrow4').hide(); $('#ITSMrow5').hide(); }); //When ITSM rb is clicked,only show IS $('#specialization_4').click(function () { $('#ISrow1').hide(); $('#ISrow2').hide(); $('#ISrow3').hide(); $('#ISrow4').hide(); $('#ISrow5').hide(); $('#IMrow1').hide(); $('#IMrow2').hide(); $('#IMrow3').hide(); $('#IMrow4').hide(); $('#IMrow5').hide(); $('#CNETrow1').hide(); $('#CNETrow2').hide(); $('#CNETrow3').hide(); $('#CNETrow4').hide(); $('#CNETrow5').hide(); $('#ITSMrow1').show(); $('#ITSMrow2').show(); $('#ITSMrow3').show(); $('#ITSMrow4').show(); $('#ITSMrow5').show(); }); }); </script> </head> <body> <div id = "Wrapper"> <div id = "content"> <header id="Header Profile"> <img src="photos/download.jpg" width="40" height="40" float="left"> </header> <nav id = "sidebarProfile"> <!--For the navigation buttons--> <div class="AJXCSSMenuNDPZHYA"><!-- AJXFILE:css/ajxmenu-profile.css --> <ul> <li><a class="ajxsub" href="Profile.php" target="_parent" title="Profile">Profile</a> <ul> <li><a href="addProfile.php" target="_parent" title="addProfile">Add Profile</a></li> <li><a href="EditProfile.php" target="_parent" title="editProfile">Edit Profile</a></li> <li><a href="deleteProfile.php" target="_parent" title="deleteProfile">Delete Profile</a></li> </ul> </li> <li><a class="ajxsub" href="Portfolio.php" target="_parent" title="portfolio">Portfolio</a> <ul> <li><a href="addPortFolio.php" target="_parent" title="addPortfolio">Add Portfolio</a></li> <li><a href="editPortfolio.php" target="_parent" title="editPortfolio">Edit Portfolio</a></li> <li><a href="deletePortfolio.php" target="_parent" title="deletePortfolio">deletePortfolio</a></li> </ul> </li> </ul> </div> </nav> <aside id = "ContentProfile"> <!--For the form and other contents--> <form action="<?php $addProfileForm ?>" method="post" enctype="multipart/form-data" name="addingProfile"> <fieldset> <legend>Add Profile</legend> <table width="auto" height="auto" border="0"> <tr> <th scope="row"><div align="left">Profile Picture:</div></th> <td><input name="MAX_FILE_SIZE" type="hidden" value=""><input type="file" name="image"></td> </tr> <tr> <th scope="row"><div align="left">Name:</div></th> <td><input name="name" type="text" value=''></td> </tr> <tr> <th scope="row"><div align="left">Description:</div></th> <td><input name="introduction" type="text" value=''></td> </tr> <tr> <th scope="row"><div align="left">Email:</div></th> <td><input name="email" type="text" value=''></td> </tr> <tr> <th scope="row"><div align="left">Contact No:</div></th> <td><input name="contactNo" type="text" value=''></td> </tr> <tr> <th scope="row"><div align="left">Specialization:</div></th> <div> <td><table width="auto"> <tr> <td><input name="specialization" type="radio" id="specialization_1" value="IS" checked="CHECKED"> IS</td> <td><input type="radio" name="specialization" value="IM" id="specialization_2"> IM</td> </tr> <tr> <td><input type="radio" name="specialization" value="CNET" id="specialization_3"> CNET</td> <td><input type="radio" name="specialization" value="ITSM" id="specialization_4"> ITSM</td> </tr> </table></td> </div> </tr> <tr> <td colspan="7" align="left"><p><strong>Skillset:<br> Please rank the skillset below..<br> (5- expert, 3- average , 0-not applicable)</strong></p></td> </tr> <th height="auto" colspan="2" scope="row"><table width="auto"> <tr id="ISrow1"> <td width="auto"><div align="left">C#</div></td> <td width="auto"><label> <input name="ISgrp1" type="radio" id="IS_table_1" value="C#-0" checked="CHECKED" > 0</label></td> <td width="auto"><label> <input type="radio" name="ISgrp1" value="C#-1" id="IS_table_2"> 1</label></td> <td width="auto"><label> <input type="radio" name="ISgrp1" value="C#-2" id="IS_table_3"> 2</label> <label></label></td> <td width="auto"><label> <input type="radio" name="ISgrp1" value="C#-3" id="IS_table_4"> 3</label></td> <td width="auto"><label> <input type="radio" name="ISgrp1" value="C#-4" id="IS_table_5"> 4</label></td> <td width="auto"><label> <input type="radio" name="ISgrp1" value="C#-5" id="IS_table_6"> 5</label></td> </tr> <tr id="ISrow2"> <td><div align="left">PHP/SQL</div></td> <td><label> <input name="ISgrp2" type="radio" id="IS_table_7" value="PHP-0" checked="CHECKED"> 0</label></td> <td><input type="radio" name="ISgrp2" value="PHP-1" id="IS_table_8"> 1</td> <td><label> <input type="radio" name="ISgrp2" value="PHP-2" id="IS_table_9"> 2</label></td> <td><label> <input type="radio" name="ISgrp2" value="PHP-3" id="IS_table_10"> 3</label></td> <td><label> <input type="radio" name="ISgrp2" value="PHP-4" id="IS_table_11"> 4</label></td> <td><label> <input type="radio" name="ISgrp2" value="PHP-5" id="IS_table_12"> 5</label></td> </tr> <tr id="ISrow3"> <td><div align="left">HTML/CSS</div></td> <td><label> <input name="ISgrp3" type="radio" id="IS_table_13" value="HTML-0" checked="CHECKED"> 0</label></td> <td><input type="radio" name="ISgrp3" value="HTML-1" id="IS_table_14"> 1</td> <td><label> <input type="radio" name="ISgrp3" value="HTML-2" id="IS_table_15"> 2</label></td> <td><label> <input type="radio" name="ISgrp3" value="HTML-3" id="IS_table_16"> 3</label></td> <td><label> <input type="radio" name="ISgrp3" value="HTML-4" id="IS_table_17"> 4</label></td> <td><input type="radio" name="ISgrp3" value="HTML-5" id="IS_table_18"> 5</td> </tr> <tr id="ISrow4"> <td><div align="left">Java Enterprise Development</div></td> <td><label> <input name="ISgrp4" type="radio" id="IS_table_19" value="Java-0" checked="CHECKED"> 0</label></td> <td><label> <input type="radio" name="ISgrp4" value="Java-1" id="IS_table_20"> 1</label></td> <td><input type="radio" name="ISgrp4" value="Java-2" id="IS_table_21"> 2</td> <td><label> <input type="radio" name="ISgrp4" value="Java-3" id="IS_table_22"> 3</label></td> <td><label> <input type="radio" name="ISgrp4" value="Java-4" id="IS_table_23"> 4</label></td> <td><input type="radio" name="ISgrp4" value="Java-5" id="IS_table_24"> 5</td> </tr> <tr id="ISrow5"> <td><div align="left">Mobile Application Development</div></td> <td><label> <input name="ISgrp5" type="radio" id="IS_table_25" value="MAD-0" checked="CHECKED"> 0</label></td> <td><label> <input type="radio" name="ISgrp5" value="MAD-1" id="IS_table_26"> 1</label></td> <td><input type="radio" name="ISgrp5" value="MAD-2" id="IS_table_27"> 2</td> <td><label> <input type="radio" name="ISgrp5" value="MAD-3" id="IS_table_28"> 3</label></td> <td><label> <input type="radio" name="ISgrp5" value="MAD-4" id="IS_table_29"> 4</label></td> <td><input type="radio" name="ISgrp5" value="MAD-5" id="IS_table_30"> 5</td> </tr> <tr id="IMrow1"> <td><div align="left">Web Design</div></td> <td><label> <input name="IMgrp1" type="radio" id="IM_table_1" value="Web Design-0" checked="CHECKED"> 0</label></td> <td><label> <input type="radio" name="IMgrp1" value="Web Design-1" id="IM_table_2"> 1</label></td> <td><label> <input type="radio" name="IMgrp1" value="Web Design-2" id="IM_table_3"> 2</label></td> <td><label> <input type="radio" name="IMgrp1" value="Web Design-3" id="IM_table_4"> 3</label></td> <td><label> <input type="radio" name="IMgrp1" value="Web Design-4" id="IM_table_5"> 4</label></td> <td><label> <input type="radio" name="IMgrp1" value="Web Design-5" id="IM_table_6"> 5</label></td> </tr> <tr id="IMrow2"> <td><div align="left">3D Modelling & Animations</div></td> <td><label> <input name="IMgrp2" type="radio" id="IM_table_7" value="3Dmodelling-0" checked="CHECKED"> 0</label></td> <td><label> <input type="radio" name="IMgrp2" value="3Dmodelling-1" id="IM_table_8"> 1</label></td> <td><label> <input type="radio" name="IMgrp2" value="3Dmodelling-2" id="IM_table_9"> 2</label></td> <td><label> <input type="radio" name="IMgrp2" value="3Dmodelling-3" id="IM_table_10"> 3</label></td> <td><label> <input type="radio" name="IMgrp2" value="3Dmodelling-4" id="IM_table_11"> 4</label></td> <td><label> <input type="radio" name="IMgrp2" value="3Dmodelling-5" id="IM_table_12"> 5</label></td> </tr> <tr id="IMrow3"> <td><div align="left">Graphic Design</div></td> <td><label> <input name="IMgrp3" type="radio" id="IM_table_13" value="Graphic Design-0" checked="CHECKED"> 0</label></td> <td><label> <input type="radio" name="IMgrp3" value="Graphic Design-1" id="IM_table_14"> 1</label></td> <td><label> <input type="radio" name="IMgrp3" value="Graphic Design-2" id="IM_table_15"> 2</label></td> <td><label> <input type="radio" name="IMgrp3" value="Graphic Design-3" id="IM_table_16"> 3</label></td> <td><label> <input type="radio" name="IMgrp3" value="Graphic Design-4" id="IM_table_17"> 4</label></td> <td><label> <input type="radio" name="IMgrp3" value="Graphic Design-5" id="IM_table_18"> 5</label></td> </tr> <tr id="IMrow4"> <td><div align="left">Video Editing</div></td> <td><label> <input name="IMgrp4" type="radio" id="IM_table_19" value="videoEditing-0" checked="CHECKED"> 0</label></td> <td><label> <input type="radio" name="IMgrp4" value="videoEditing-1" id="IM_table_20"> 1</label></td> <td><label> <input type="radio" name="IMgrp4" value="videoEditing-2" id="IM_table_21"> 2</label></td> <td><label> <input type="radio" name="IMgrp4" value="videoEditing-3" id="IM_table_22"> 3</label></td> <td><label> <input type="radio" name="IMgrp4" value="videoEditing-4" id="IM_table_23"> 4</label></td> <td><label> <input type="radio" name="IMgrp4" value="videoEditing-5" id="IM_table_24"> 5</label></td> </tr> <tr id="IMrow5"> <td><div align="left">Motion Graphics & Effects</div></td> <td><label> <input name="IMgrp5" type="radio" id="IM_table_25" value="motionGraphics-0" checked="CHECKED"> 0</label></td> <td><label> <input type="radio" name="IMgrp5" value="motionGraphics-1" id="IM_table_226"> 1</label></td> <td><label> <input type="radio" name="IMgrp5" value="motionGraphics-2" id="IM_table_27"> 2</label></td> <td><label> <input type="radio" name="IMgrp5" value="motionGraphics-3" id="IM_table_28"> 3</label></td> <td><label> <input type="radio" name="IMgrp5" value="motionGraphics-4" id="IM_table_29"> 4</label></td> <td><label> <input type="radio" name="IMgrp5" value="motionGraphics-5" id="IM_table_30"> 5</label></td> </tr> <tr id="CNETrow1"> <td><div align="left">Network Security</div></td> <td><label> <input name="CNETgrp1" type="radio" id="CNET_table_1" value="networkSecurity-0" checked="CHECKED"> 0</label></td> <td><label></label> <label> <input type="radio" name="CNETgrp1" value="networkSecurity-1" id="CNET_table_2"> 1</label></td> <td><label></label> <label> <input type="radio" name="CNETgrp1" value="networkSecurity-2" id="CNET_table_3"> 2</label></td> <td><label> <input type="radio" name="CNETgrp1" value="networkSecurity-3" id="CNET_table_4"> 3</label></td> <td><label> <input type="radio" name="CNETgrp1" value="networkSecurity-4" id="CNET_table_5"> 4</label></td> <td><label> <input type="radio" name="CNETgrp1" value="networkSecurity-5" id="CNET_table_6"> 5</label></td> </tr> <tr id="CNETrow2"> <td><div align="left">RB Network Design & Implementation</div></td> <td><label> <input name="CNETgrp2" type="radio" id="CNET_table_7" value="RBNetworkDesign-0" checked="CHECKED"> 0</label></td> <td><label></label> <label> <input type="radio" name="CNETgrp2" value="RBNetworkDesign-1" id="CNET_table_8"> 1</label></td> <td><label></label> <label> <input type="radio" name="CNETgrp2" value="RBNetworkDesign-2" id="CNET_table_9"> 2</label></td> <td><label> <input type="radio" name="CNETgrp2" value="RBNetworkDesign-3" id="CNET_table_10"> 3</label></td> <td><label> <input type="radio" name="CNETgrp2" value="RBNetworkDesign-4" id="CNET_table_11"> 4</label></td> <td><label> <input type="radio" name="CNETgrp2" value="RBNetworkDesign-5" id="CNET_table_12"> 5</label></td> </tr> <tr id="CNETrow3"> <td><div align="left">Broadband Access & WAN</div></td> <td><label> <input name="CNETgrp3" type="radio" id="CNET_table_13" value="BroadbandAccess-0" checked="CHECKED"> 0</label></td> <td><label></label> <label> <input type="radio" name="CNETgrp3" value="BroadbandAccess-1" id="CNET_table_14"> 1</label></td> <td><label></label> <label> <input type="radio" name="CNETgrp3" value="BroadbandAccess-2" id="CNET_table_15"> 2</label></td> <td><label> <input type="radio" name="CNETgrp3" value="BroadbandAccess-3" id="CNET_table_16"> 3</label></td> <td><label> <input type="radio" name="CNETgrp3" value="BroadbandAccess-4" id="CNET_table_17"> 4</label></td> <td><label> <input type="radio" name="CNETgrp3" value="BroadbandAccess-5" id="CNET_table_18"> 5</label></td> </tr> <tr id="CNETrow4"> <td><div align="left">ICT Infrastructure Management</div></td> <td><label> <input name="CNETgrp4" type="radio" id="CNET_table_19" value="ICTInfrastructureManagement-0" checked="CHECKED"> 0</label></td> <td><label></label> <label> <input type="radio" name="CNETgrp4" value="ICTInfrastructureManagement-1" id="CNET_table_20"> 1</label></td> <td><label></label> <label> <input type="radio" name="CNETgrp4" value="ICTInfrastructureManagement-2" id="CNET_table_21"> 2</label></td> <td><label> <input type="radio" name="CNETgrp4" value="ICTInfrastructureManagement-3" id="CNET_table_22"> 3</label></td> <td><label> <input type="radio" name="CNETgrp4" value="ICTInfrastructureManagement-4" id="CNET_table_23"> 4</label></td> <td><label> <input type="radio" name="CNETgrp4" value="ICTInfrastructureManagement-5" id="CNET_table_24"> 5</label></td> </tr> <tr id="CNETrow5"> <td><div align="left">Technopreneurship Project</div></td> <td><label> <input name="CNETgrp5" type="radio" id="CNET_table_25" value="Technopreneurship-0" checked="CHECKED"> 0</label></td> <td><label></label> <label> <input type="radio" name="CNETgrp5" value="Technopreneurship-1" id="CNET_table_26"> 1</label></td> <td><label></label> <label> <input type="radio" name="CNETgrp5" value="Technopreneurship-2" id="CNET_table_27"> 2</label></td> <td><label> <input type="radio" name="CNETgrp5" value="Technopreneurship-3" id="CNET_table_28"> 3</label></td> <td><label> <input type="radio" name="CNETgrp5" value="Technopreneurship-4" id="CNET_table_29"> 4</label></td> <td><label> <input type="radio" name="CNETgrp5" value="Technopreneurship-5" id="CNET_table_30"> 5</label></td> </tr> <tr id="ITSMrow1"> <td><div align="left">Virtualisation & Cloud Computing</div></td> <td height="24"><label> <input name="ITSMgrp1" type="radio" id="ITSM_table_1" value="virtualisation_0" checked="CHECKED"> 0</label></td> <td><label> <input type="radio" name="ITSMgrp1" value="virtualisation_1" id="ITSM_table_2"> 1</label></td> <td><label> <input type="radio" name="ITSMgrp1" value="virtualisation_2" id="ITSM_table_3"> 2</label></td> <td><label> <input type="radio" name="ITSMgrp1" value="virtualisation_3" id="ITSM_table_4"> 3</label></td> <td><label> <input type="radio" name="ITSMgrp1" value="virtualisation_4" id="ITSM_table_5"> 4</label></td> <td><input type="radio" name="ITSMgrp1" value="virtualisation_5" id="ITSM_table_6"> 5</td> </tr> <tr id="ITSMrow2"> <td><div align="left">IT Service Operation & Management </div></td> <td height="24"><label> <input name="ITSMgrp2" type="radio" id="ITSM_table_7" value="ITSM_0" checked="CHECKED"> 0</label></td> <td><label> <input type="radio" name="ITSMgrp2" value="ITSM_1" id="ITSM_table_8"> 1</label></td> <td><label> <input type="radio" name="ITSMgrp2" value="ITSM_2" id="ITSM_table_9"> 2</label></td> <td><label> <input type="radio" name="ITSMgrp2" value="ITSM_3" id="ITSM_table_10"> 3</label></td> <td><label> <input type="radio" name="ITSMgrp2" value="ITSM_4" id="ITSM_table_11"> 4</label></td> <td><input type="radio" name="ITSMgrp2" value="ITSM_5" id="ITSM_table_12"> 5</td> </tr> <tr id="ITSMrow3"> <td><div align="left">Server Administration & Security</div></td> <td height="24"><label> <input name="ITSMgrp3" type="radio" id="ITSM_table_13" value="serverAdministration_0" checked="CHECKED"> 0</label></td> <td><label> <input type="radio" name="ITSMgrp3" value="serverAdministration_1" id="ITSM_table_14"> 1</label></td> <td><label> <input type="radio" name="ITSMgrp3" value="serverAdministration_2" id="ITSM_table_15"> 2</label></td> <td><label> <input type="radio" name="ITSMgrp3" value="serverAdministration_3" id="ITSM_table_16"> 3</label></td> <td><label> <input type="radio" name="ITSMgrp3" value="serverAdministration_4" id="ITSM_table_17"> 4</label></td> <td><input type="radio" name="ITSMgrp3" value="serverAdministration_5" id="ITSM_table_18"> 5</td> </tr> <tr id="ITSMrow4"> <td><div align="left">Database Administration & Management</div></td> <td height="24"><label> <input name="ITSMgrp4" type="radio" id="ITSM_table_19" value="DatabaseAdministration&Management_0" checked="CHECKED"> 0</label></td> <td><label> <input type="radio" name="ITSMgrp4" value="DatabaseAdministration&Management_1" id="ITSM_table_20"> 1</label></td> <td><label> <input type="radio" name="ITSMgrp4" value="DatabaseAdministration&Management_2" id="ITSM_table_21"> 2</label></td> <td><label> <input type="radio" name="ITSMgrp4" value="DatabaseAdministration&Management_3" id="ITSM_table_22"> 3</label></td> <td><label> <input type="radio" name="ITSMgrp4" value="DatabaseAdministration&Management_4" id="ITSM_table_23"> 4</label></td> <td><input type="radio" name="ITSMgrp4" value="DatabaseAdministration&Management_5" id="ITSM_table_24"> 5</td> </tr> <tr id="ITSMrow5"> <td><div align="left">Internet of Things App Development</div></td> <td height="24"><label> <input name="ITSMgrp5" type="radio" id="ITSM_table_25" value="InternetofThingsAppDevelopment_0" checked="CHECKED"> 0</label></td> <td><label> <input type="radio" name="ITSMgrp5" value="InternetofThingsAppDevelopment_1" id="ITSM_table_26"> 1</label></td> <td><label> <input type="radio" name="ITSMgrp5" value="InternetofThingsAppDevelopment_2" id="ITSM_table_27"> 2</label></td> <td><label> <input type="radio" name="ITSMgrp5" value="InternetofThingsAppDevelopment_3" id="ITSM_table_28"> 3</label></td> <td><label> <input type="radio" name="ITSMgrp5" value="InternetofThingsAppDevelopment_4" id="ITSM_table_29"> 4</label></td> <td><input type="radio" name="ITSMgrp5" value="InternetofThingsAppDevelopment_5" id="ITSM_table_30"> 5</td> </tr> </table></th> </tr> <tr> <th scope="row"></th> <th scope="row"> <input type="submit" name="submit" id="submit" value="Submit"></th> </tr> </table> </fieldset> </form> <form action="" method="post" name="LogOutForm" > <a href="<?php echo $logoutAction ?>" >LOG OUT</a> </form> </aside> </div> <footer id="footer"> <p>Footer goes here.</p> </footer> </div> </body> </html> I have to add in that I'm showing the radio buttons of skillsets based on the specialization(radio buttons)[look at the javascript]. I would like to know that if this is the right way, as i compile this from open source and in the correct format. I'm slow in learning , so i hope you can tell me in detail as to why my work hasnt been working the way i wanted to. I have set checked to every of the radio buttons in skillsets as i know that radio buttons are special cases where the form will still submit if the user didn't press it, and my database i've declared it as varchar, but I'm still wondering why would it be integrity constraint? Is it because i declared it wrongly? Im so sorry if my coding is too long( also because of the commented trial and error code) ><
  15. Well, i'm using the password code(passwordHash.php) from this website http://www.openwall.com/phpass/ . So i tried configuring that (thanks for pointing the mistake!) but i get an error whereby Class 'PasswordHash' not found.( the same from the previous reply i gave) . Here's the code: <?php require_once('Connections/database.php'); ?> <?php // *** Validate request to login to this site. if (!isset($_SESSION)) { session_start(); } //locate the form to it's own php script $loginTestAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } //Check if request method is post //Do no use (isset($_POST['submit'])) if ($_SERVER["REQUEST_METHOD"] == "POST"){ //protect and store them to database $username = $_POST['username']; $password = $_POST['password']; $hash_obj = new PasswordHash(8, false); $storedhash = $hash_obj->HashPassword($password); $check = $hash_obj->CheckPassword( $password, $stored_hash ); //Create the sql satatement query $sql = "SELECT * FROM user WHERE username=:username"; $query = $database->prepare( $sql ); $query->execute( array( ':username'=>$username ) ); $results = $query->fetchAll( PDO::FETCH_ASSOC ); foreach( $results as $row ){ $stored_hash = $row[ 'Password' ]; print_r( $password_hash ); } include ('pHPasswordEncrypt/Passwordhash.php'); if ( $check ){ print_r( "This is a valid user" ); $_SESSION[ 'logged_in' ] = true; } else { print_r( "Authentication failed, please Try again."); } if ($_SESSION[ 'logged_in' ] == true ){ header('Location:Profile.php'); } else { header('Location:login_testing.php'); } } ?> If i were to put the include (passwordhash.php) before declaring the $hash_obj, my page will keep refreshing. Same for this code(my version is 5.6.8, so this is a newly made login, trying out the PHP default password): <?php require_once('Connections/database.php'); // *** Validate request to login to this site. echo 'Current PHP version: ' . phpversion(); error_reporting(E_ALL); if (!isset($_SESSION)) { session_start(); } //locate the form to it's own php script $loginTestAction = $_SERVER['PHP_SELF']; if (isset($_GET['accesscheck'])) { $_SESSION['PrevUrl'] = $_GET['accesscheck']; } //Check if request method is post //Do no use (isset($_POST['submit'])) as this can be hacked. if ($_SERVER["REQUEST_METHOD"] == "POST"){ //protect and store them to database $username = $_POST['username']; $password = password_hash($_POST['password'], PASSWORD_BCRYPT); //$hash_obj = new PasswordHash(8, false); //make the password encrypted. //$stored_hash = $hash_obj->HashPassword($password); //check the password //$check = $hash_obj->CheckPassword( $password, $stored_hash ); //Create the sql satatement query $sql = "SELECT * FROM user WHERE username=:username"; $query = $database->prepare( $sql ); $query->execute( array( ':username'=>$username ) ); $results = $query->fetchAll( PDO::FETCH_ASSOC ); if ($results === true) { foreach( $results as $row ){ //get the database column name $passwordDb = $row[ 'Password' ]; } //Check if the password in database is different then the configuration if(password_needs_rehash($passwordDb, PASSWORD_BCRYPT)&& md5($password)=== $passwordDb) { //store new password $stored_password= password_hash($spasswordDb, PASSWORD_BCRYPT); //sign user in header('Location: Profile.php'); } else { if (password_verify($password,$passwordDb)) { //sign user in header('Location: Profile.php'); } } } else { //show errors? if (!$results) { echo ("Username and password are not found in database.Please try again."); } } } ?> For the second code, if I remove the if statement (end of the code) , it will show the echo "Username and passwor.." statement but I do not know how to solve it. Also, I don't understand why they show this error: password_hash() expects parameter 3 to be array, integer given , when I follow the same with the one in phpManual. I decided to take out the 10 because if I didn't declare, the default is 10 isn't it?
×
×
  • 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.