Jump to content

Silence~

Members
  • Posts

    21
  • Joined

  • Last visited

Posts posted by Silence~

  1. I'm having trouble with getting the image in the right order. I'm trying to filter images gotten from the database based on the button link. I got the reference from http://www.evoluted.net/thinktank/web-development/jquery-filtering. I have about 20+- buttons and for each button, I am getting all the picture that is being under that filter button through database. (Not sure where to post this, but I think it's more suited to be under css). Basically, I have gotten the css all wrong (my css is basic too ><), so I hope you could help me(where i have gone wrong) and give some pointers.

    Here is css:

    /*- FILTER OPTIONS -*/ul#filterOptions {	width: auto;	height: auto;	margin-top: 60px ;	;	overflow: hidden;	list-style: none;}ul#filterOptions li {	height: 52px;	margin-right: 2px;	float: left;}ul#filterOptions li a {	height: 50px;	padding: 0 20px;	border: 1px solid #999;	background: #cfcfcf;	color: #fff;	font-weight: bold;	line-height: 50px;	text-decoration: none;	display: block;	list-style: none;}ul#filterOptions li a:hover {	background: #c9c9c9;	list-style: none;}ul#filterOptions li.active a {	background: #999;	list-style: none;}/*- -*//*- OUR DATA HOLDER -*/#filterBody {	width: 100%;	height: 100%;	overflow: hidden;	list-style: none;}#filterBody div.item {	width: 200px;	height: 200px;	float: left;	text-align: center;}#filterBody div.item h3 {	margin-top: 10px;	font-size: 16px;	line-height: 20px;}/*- -*/

    My html/php code looks like this (example of 1 button):

    <!----------------- The filter buttons will be these-------------------------->    <ul id="filterOptions">      <li class="active"><a href="#" class="all">All</a></li>      <li><a href="#" class="IS_1">C#</a></li>      <li><a href="#" class="IS_2">PHP/MySQL</a></li>      <li><a href="#" class="IS_3">HTML/CSS</a></li>      <li><a href="#" class="IS_4">Java Enterprise Development</a></li>      <li><a href="#" class="IS_5">Mobile Application Development</a></li>      <li><a href="#" class="IM_1">Web Design</a></li>      <li><a href="#" class="IM_2">3D Modelling & Animations</a></li>      <li><a href="#" class="IM_3">Graphic Design</a></li>      <li><a href="#" class="IM_4">Video Editing</a></li>      <li><a href="#" class="IM_5">Motion Graphics & Effects</a></li>      <li><a href="#" class="CNET_1">Network Security</a></li>      <li><a href="#" class="CNET_2">RB Network Design & Implementation</a></li>      <li><a href="#" class="CNET_3">Broadband Access & WAN</a></li>      <li><a href="#" class="CNET_4">ICT Infrastructure Management</a></li>      <li><a href="#" class="CNET_5">Technopreneurship Project</a></li>      <li><a href="#" class="ITSM_1">Virtualisation & Cloud Computing</a></li>      <li><a href="#" class="ITSM_2">IT Service Operation & Management</a></li>      <li><a href="#" class="ITSM_3">Server Administration & Security</a></li>      <li><a href="#" class="ITSM_4">Database Administration & Management</a></li>      <li><a href="#" class="ITSM_5">Internet of Things App Development</a></li>      <!--<li><a href="#" class=""><?php  ?></a></li>-->    </ul><!--------------Filtered contents to be through the button--------------------><div id="filterBody">    <!----Filter contecnt of C#------>      <div class="item IS_1">      <p> Hello everybody!</p><?php  try{  //connect to the database  require("Connections/database.php");  		// array to hold errors        $errors = array(); 		 if(empty($errors)){          //select portfolio picture from database        $query = "SELECT p.*, u.skillset FROM portfolio p INNER JOIN userProfile u ON p.user_id = u.user_id WHERE u.skillset LIKE '%C#%' ";		//var_dump($query);        $stmt = $database->query($query);		  foreach ($stmt as $row) {			  //print out the data				  ?>               <div id= "imagesPortfolio">              <img src="<?php print htmlspecialchars($row['imagePath']); ?>" width="100" height="100">	               </div>             <?php			  //print $row['imageName'] . "t";			  //print $row['Name'] . "t";			//foreach($row['picPath'] as $picURL) {			//$picURL = $row['picPath'];			//'<img src="'. $dir. '/'. $file. '" alt="'. $file. $			//}			 // print '<img src="'. $picPath. '/'. $file. '" alt="'. $file;			  //print $row['introduction'] . "n";		  }		 }  foreach($errors as $error)    {        printf("<li>%s</li>", $error);		//exit();    }  } //end of try block     catch(PDOException $e){ // end of database dependent code, handle any errors    $status = empty($query) ? 'Connection failed':" Query failed: $query";    // application message    trigger_error("$status, Error: {$e->getMessage()}, File: {$e->getFile()}, Line: {$e->getLine()}");    // user message    $errors[] = 'Sorry, this page is not working at this time.';}?>        <!---The like system implementation----><!--        <div class="like-btn">Like</div>        <div class="dislike-btn"></div>-->      </div><!------Other buttons same as this buttons, only filter name different--------></div>

    Is my concept wrong? >< I think i have misinterpreted somewhere, I just can't point out whether it's the css, the php or both ;-; I need to put 6 images in a row, and I'm not sure how to do this in the foreach loop too ><

     

  2. Well, it's not null anymore, what happens when you call prepare() on it?

    I'm not sure what you mean by this, I put var_dump($database) and var_dump($statement) and this is the results:

    object(PDOStatement)#2 (1) { ["queryString"]=> string(99) "SELECT * FROM userProfile WHERE user_id in ( select id from users where id = 1)" }

  3. Are you getting a "Connection failed" message on your page? That would explain $database being null.

     

    SQL injection happens when you put user data in a query, it doesn't have to do with how long you keep a connection open.

    Nope I didn't. I get the error message beside the one I stated above:

    if (!$row  = $statement->fetch(PDO::FETCH_ASSOC)) {   print_r ("No Data to show. Please add in your profile. Navigate your way through the left side of the page where the navigations are.");}

    Oh okay, thanks for the explanation :)

  4. It should work that way, yes, but I'm not sure what your database.php file looks like. There might be something in there causing the problem.

     

    Ideally, you should open the connection just once for the entire page. There's no need to manually close the connection, it closes automatically when the script stops running.

    My database file looks like this:

    try {$user = ""; //taken out just in case$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();}																						  

    When you mean open the connection, i just have to require the file right? Must I put it in the try catch?(because I already put it in the database file?) or like put the search code and the select code together? I close it because i thought that it can be sql inject(or something like that) ? ;-;

  5.  

    It means the database connection is null.

     

    It seems you're setting it to null right on this line:

    // done with the database, destroy any pdostatment resource and close connection$stmt = null;$database = null;

    Ah yes, thank you! This was one of the cause >< But why would that affect though? I thought by requiring the database connection again, it should be okay?Anyways, it gives this: object(PDO)#1 (0) { } for the vardump. I have data inside though?

  6.  

    Check to see if $database has what you think it does by checking its value

    //Prepare our SELECT statement.var_dump($database);$statement = $database->prepare($sql);

    Tried it and it says null. Does that mean my database connection being null or my query being null? It works though if i didn't put the search code in.. o.o

  7. I'm receiving this error 'Call to a member function prepare() on null' if I were to put this search code into the page. It works fine if i were to put at other pages(for inserting to database).Here's my search code that I've put before the html tags:

    <?php//echo '<pre>';//echo $_POST;//echo '</pre>';//declare the form name//$searchForm = htmlentities($_SERVER['PHP_SELF']);try {	//inserts database connections	require('Connections/database.php'); if (($_SERVER['REQUEST_METHOD'] == 'POST') &&  isset($_POST['search']))  {	// array to hold errors	$errorsSearch = array(); 	//create a bad word array	$badwords = array('######','damn','mother######er','###### you');	//Declare variables	$search = $_POST['search'];		//Validations for the $_POST	//check if it's blank	if (trim($search) == "" || !isset($search)) {		$errorsSearch[] = ("Search is blank!");	}	//Check if the text to search is too long	if (isset($search) && strlen(trim($search)) > 50) {	    $errorsSearch[] = ("The text to search is too long!");	}	//Check for any vulgarities	if (isset($search) && in_array($search,$badwords)) {		$errorsSearch[] = ("No vulgarities!");	}	if (empty($errorsSearch)) {	//Declare the sql query	$query = "SELECT * FROM portfolio WHERE nameOfPortfolio LIKE '%$search%'";	//var_dump($query);	$stmt = $database->query($query);	$number_of_rows = $stmt->fetchColumn();	if ($number_of_rows == 0) {		$errorsSearch[]= ("No results! Sorry, please try again!");	}	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.";	  header("Location:searchResults.php");	  exit;	}}	if (isset($errorsSearch) == true)	//foreach($errors as $error){	echo "<div id=search_errors>" .implode("<br>", $errorsSearch) . "</div>";	//printf("%s",$error);}} //end of form processing} //end of try methodcatch(PDOException $e){ // end of database dependent code, handle any errors    $status = empty($query) ? 'Connection failed':" Query failed: $query";    // application message    trigger_error("$status, Error: {$e->getMessage()}, File: {$e->getFile()}, Line: {$e->getLine()}");    // user message    $errorsSearch[] = 'Sorry, this page is not working at this time.';}// done with the database, destroy any pdostatment resource and close connection$stmt = null;$database = null; //the html document that uses any data from the above code starts here -?>

    This is my code for getting the data:

             <table width="379" border="0" cellspacing="0" cellpadding="0" style=" border-style: solid" >           <?php           try {          //connect to database          require_once('Connections/database.php');           //Selecting a single row!          $sql = "SELECT * FROM userProfile WHERE user_id in  (                  select id from users where id = ".($_SESSION['user_id']).")";                 //Prepare our SELECT statement.          $statement = $database->prepare($sql);                     //Execute our SELECT statement.          $statement->execute();		             if (!$row  = $statement->fetch(PDO::FETCH_ASSOC)) {               print_r ("No Data to show. Please add in your profile. Navigate your way through the left side of the page where the navigations are.");           }		  if (isset($errors) == true) {			echo "<div id=add_port_errors>" .implode("<br>", $errors) . "</div>";		  }// get method/display code (if any) - get/produce data that's needed to display the page// to edit existing data, if the $data array is empty at this point, retrieve any existing data from the database table?>           <tr>             <th width="auto" scope="row"><div align="left">Profile Picture:</div></th>             <td width="auto"><img src="<?php print htmlspecialchars($row['picPath']); ?>" width="82" height="72">             </td>             <td width="auto"><form name="editProfile" method="post" action="editProfile.php">               <input type="submit" name="edit" id="edit" value="Edit">               </form></td>             </tr>           <tr>             <th scope="row"><div align="left">Username:</div></th>             <td><label><?php print htmlspecialchars($row['username']); ?></label></td>             <td><form name="editProfile" method="post" action="editProfile.php">               <input type="submit" name="edit" id="edit" value="Edit">               </form></td>             </tr>           <tr>             <th scope="row"><div align="left">Name:</div></th>             <td><label><?php print htmlspecialchars($row['Name']); ?></label></td>             <td><form name="editProfile" method="post" action="editProfile.php">               <input type="submit" name="edit" id="edit" value="Edit">               </form></td>             </tr>           <tr>             <th scope="row"><div align="left">Email:</div></th>             <td><label><?php print htmlspecialchars($row['Email']); ?></label></td>             <td><form name="editProfile" method="post" action="editProfile.php">               <input type="submit" name="edit" id="edit" value="Edit">               </form></td>             </tr>           <tr>             <th scope="row"><div align="left">ContactNo:</div></th>             <td><label><?php print htmlspecialchars($row['ContactNo']); ?></label></td>             <td><form name="editProfile" method="post" action="editProfile.php">               <input type="submit" name="edit" id="edit" value="Edit">               </form></td>             </tr>           <tr>             <th scope="row"><div align="left">Skillset:</div></th>             <td><label><?php print htmlspecialchars($row['skillset']); ?></label></td>             <td><form name="editProfile" method="post" action="editProfile.php">               <input type="submit" name="edit" id="edit" value="Edit">               </form></td>             </tr>           <tr>             <th scope="row"><div align="left">Specialization:</div></th>             <td><label><?php print htmlspecialchars($row['Specialization']); ?></label></td>             <td><form name="editProfile" method="post" action="editProfile.php">               <input type="submit" name="edit" id="edit" value="Edit">               </form></td>             </tr>           <tr>             <th scope="row"><div align="left">Introduction:</div></th>             <td><label><?php print htmlspecialchars($row['introduction']); ?></label></td>             <td><form name="editProfile" method="post" action="editProfile.php">               <input type="submit" name="edit" id="edit" value="Edit">               </form></td><?php           } //catch(PDOException $e){ // end of database dependent code, handle any errors$status = empty($query) ? 'Connection failed':" Query failed: $query";// application messagetrigger_error("$status, Error: {$e->getMessage()}, File: {$e->getFile()}, Line: {$e->getLine()}");// user message$errors[] = 'Sorry, this page is not working at this time.';}// done with the database, destroy any pdostatment resource and close connection$stmt = null;$database = null;				                 ?>             </tr>         </table>

    My database is correct though, I'm using $database for all the connections, i didn't change the variable name. I'm not sure why it wouldn't initialized. Is my select query wrong? ;-;

  8. Okay, I found out the solution to that error.. I utterly embarrassed myself for not looking through thoroughly >< With the help of this post : http://w3schools.invisionzone.com/index.php?showtopic=47997&p=265892 , I realised I had moved my coding to the starting of html form and that what caused the error since the header location must be located before the html tag. Thanking Ingolme indirectly (Thanks a bunch :D) . Anyways, I still can't validate if the file is not image. It won't show the $errors[] either. >< I'm not sure where i go wrong o,o

  9.  

    There never going to match, one is checking against 'image/png' while the other checks for 'png', yes 'png' is in the earlier comparison but its not 'png'

     

     

    You need to compare mimetype AND extension, also 'jpg' can be 'jpeg', 'jpe' as well

      <?php        $errors = "";        $filename = "images/test.png";        $filetmp = "tmp/test.png";        $allowedTypes = array('image/jpg', 'image/png', 'image/gif');        $allowedExtensions = array('jpg', 'png', 'gif');        //$ext = explode(".", $filename);        // $extension = strtolower(end($ext));        $extension = pathinfo($filename, PATHINFO_EXTENSION);        $finfo = new finfo(FILEINFO_MIME_TYPE);        $mimetype = $finfo->file($filename); // or $filetmp        var_dump($mimetype);        if (!in_array($mimetype, $allowedTypes)) { // check mimetype            // if (!in_array($extension, $allowedExtensions)) {  // check extensions            $errors = 'File uploaded does not meet the Type criteria(PNG/JPG/GIF). Please check. #1<br />';        } else {//move_uploaded_file($filename,$uploadfile);            $errors = 'File uploaded DOES MEET the Type criteria(PNG/JPG/GIF). #1<br />';        }        echo $errors;        ?>  

     

    I'm not sure if i understand it correctly.

    This is what I've added in :

    	//Allowed typpes to pass through validation        $allowedTypes = array('image/jpg', 'image/jpeg', 'imagae/jpe', 'image/png', 'image/gif');	$allowedExtensions = array('jpg', 'jpeg', 'jpe' , 'png', 'gif');	//$ext = explode(".", $filename);	// $extension = strtolower(end($ext));    //gets the info of ther file, in this case, extension	$extension = pathinfo($filename, PATHINFO_EXTENSION);	//return the file mime type	$finfo = new finfo(FILEINFO_MIME_TYPE);	//check th file for the information (tmp or name)	$mimetype = $finfo->file($filetmp); 	var_dump($mimetype);	//Check mimetype and extensions	if ((!in_array($mimetype, $allowedTypes)) || (!in_array($extension, $allowedExtensions))) { 		$errors[] = 'File uploaded does not meet the Type criteria(PNG/JPG/GIF). Please check.';	} else {        if (!move_uploaded_file($filetmp,$uploadfile)) {		$errors[] = 'File uploaded DOES NOT move to another folder.';		}		if(move_uploaded_file($filetmp,$uploadfile)) {			return $uploadfile;		}	}

    Since I have to compare mimetype and extension, shouldn't this works too? You have put the commented validation $extension below the validation $mimetype, I'm just wondering why though, it can be put together in one line doesn't it? It still shows the $errors inside, still not getting it ><

     

    I also have a problem about the move_uploaded_file after playing with the codes(the one you give as an example. I uncomment it). It would trigger the cannot modify headers, headers not sent errors. I have 2 headers , one before validating the user's inputs and another one after inserting it to database:

            // if no errors at this point, redirect to the exact same url of this page to prevent the browser from resubmitting the data by causing a get request for the page        if(empty($errors)){            $host = $_SERVER['HTTP_HOST'];            $uri = $_SERVER['REQUEST_URI'];            header("Location:addProfile.php?success=1");            exit;        }

    It will always point out the error at the beginning of this code:

        <?php            //This must be out of that form validation.            //set error array            $errors = array();            if (( isset($_GET['success']) && $_GET['success'] == 1 ))            {              echo "Successfully added your profile! Please check out your updated profile page.";            //   if(empty($errors)){            //		include ('mailer.php');	            //			            //        }            }            if (( isset($_GET['failure']) && $_GET['failure'] == 1 )) {            echo "You have an existing record. Either delete your record, or update/edit your record.";            }            foreach($errors as $error)            {            printf("<li>%s</li>", $error);            //exit();            }        ?> 

    EDIT: I actually am able to save the picture name and path in the database and also in the relative folder. However, it keeps sends the error :" Warning: Cannot modify header information - headers already sent by (output started at... ". I'm not sure what had happen as I only changed this particular codes and the relative path to this:

    //create the relative folder$uploaddir = 'profilePics/';  //<-- Found a / in the front of /profilePics/ , which keeps giving error that could not move upload file.. (It's gone now though, after I fix it)$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);if ($_FILES['userfile']['error'] === UPLOAD_ERR_OK) {         $allowedTypes = array('image/jpg', 'image/jpeg', 'imagae/jpe', 'image/png');	$allowedExtensions = array('jpg', 'jpeg', 'jpe' , 'JPEG', 'JPG', 'JPE', 'PNG', 'png');	//$ext = explode(".", $filename);	// $extension = strtolower(end($ext));    //gets the info of ther file, in this case, extension	$extension = pathinfo($filename, PATHINFO_EXTENSION);		//return the file mime type	$finfo = new finfo(FILEINFO_MIME_TYPE);	//check th file for the information (tmp or name)	$mimetype = $finfo->file($filetmp); 	var_dump($mimetype);	//Check mimetype and extensions in the arrays.	if ((!in_array($mimetype, $allowedTypes)) || (!in_array($extension, $allowedExtensions))) { 		$errors[] = 'File uploaded does not meet the Type criteria(PNG/JPG). Please check.';	} 	else {               if (!move_uploaded_file($filetmp,$uploadfile)) {		$errors[] = 'File uploaded DOES NOT move to another folder.';		}		if(move_uploaded_file($filetmp,$uploadfile)) {			//get the destination now		$errors[] = 'File uploaded is '.$filetype.' to another folder.';			//return $uploadfile;		}	}}

    I've googled for answers (Here is the reference I checked :http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php/8028979#8028979 , but I am still clueless as ever. There were no missing ; or any whitespaces at the php tags as far as I've checked >< Could anyone tell me what is wrong here? I really suspect the error would've been the move_uploaded_file , but it did save it to the folder/database so I can't say that my suspicion is correct ><

  10. There are so many ways to do this, but pathiinfo() http://php.net/manual/en/function.pathinfo.php seems the better option.

    I did another try(before you posted this) and I'm stuck at the same place where they would not detect the extension. Here's my tries :

    //First Try//tried with 'jpg','png' and 'gif' for both too$allowedTypes = array('image/jpg', 'image/png', 'image/gif');  $ext = explode(".", $filename);$extension = strtolower(end($ext));$finfo = new finfo(FILEINFO_MIME_TYPE);$mimetype = $finfo->file($filetmp);var_dump($mimetype);if (!in_array($mimetype, $allowedTypes) || !in_array($extension, $allowedTypes)) {    $errors[] = ('File uploaded does not meet the types criteria(PNG/JPG/GIF). Please check.');}else {      move_uploaded_file($filename,$uploadfile);		 }//Second Try$allowedTypes = array('image/jpg', 'image/png', 'image/gif');$fileInfo = pathinfo($filename, PATHINFO_EXTENSION);if (!in_array($fileInfo,$allowedTypes)) {    $errors[] = ('File uploaded does not meet the types criteria(PNG/JPG/GIF). Please check.');}else {      move_uploaded_file($filename,$uploadfile);		 }

    I tried uploading a png file but I'm not sure where I go wrong, there's no errors except for the $errors I declared in that code. Perhaps I'm missing something logical? ><

  11. So, I tried coding for the image uploading and I have some difficulty on the MIME type. If I did not declare anything of that, I am able to insert to the database(the directory and the name of the file) but the picture would not be inserted to the folder. This are my code:

    		//Declare variables and start validation        $fileMaxSize = $_POST['MAX_FILE_SIZE'];	$filename = $_FILES['userfile']['name'];	$filetype = $_FILES['userfile']['type'];	$filesize = $_FILES['userfile']['size'];	$filetmp = $_FILES['userfile']['tmp_name'];	$fileError = $_FILES['userfile']['error'];	$uploaddir = '/profilePics/';	$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);//Check if file is uploaded/issetswitch ($fileError) {	case UPLOAD_ERR_OK:	//no error, so move on to the uploading process	break;	case UPLOAD_ERR_INI_SIZE:  //This is from the php max size	$errors[] = ('The file you attempt to upload exceeds the max size. Please upload a smaller size');	break;	case UPLOAD_ERR_FORM_SIZE: //This is from the html form max size we declared.	$errors[] = ('The file you attempt to upload exceeds the max size. Please upload a smaller size');	break;	case UPLOAD_ERR_PARTIAL:	$errors[] = ('The file is partially uploaded. Please try again.');	break;	case UPLOAD_ERR_NO_FILE: //no file is uploaded	$errors[] = ('File is not uploaded.');	break;	case UPLOAD_ERR_NO_TMP_DIR:	$errors[] = ('Temporary folder is missing or do not exist. Please contact administrator.');	break;	case UPLOAD_ERR_CANT_WRITE:	$errors[] = ('Unable to write into the folder. Please try again.');	break;	case UPLOAD_ERR_EXTENSION:	$errors[] = ('Unable to detect the cause of error. Please try again and if error persist, contact the administrator.');	break;}// if the upload is okay, proceed to move the file.if ($_FILES['userfile']['error'] === UPLOAD_ERR_OK) {       //check if the type is correct	  $finfo = finfo_open(FILEINFO_MIME); // return mime type ala mimetype extension//if not able to return mime typeif (!$finfo) {    $errors[] = ('Opening fileinfo database failed');}/* get mime-type for a specific file *///$filename = "/usr/local/something.txt";if (!finfo_file($finfo, $filename)) {	$errors[] = ('not sure what to do here.');		}else {         move_uploaded_file($filename,$uploadfile);		 }/* close connection */finfo_close($finfo);}//Insert statement after checking if no errors  if(empty($errors)){	$stmt = $database->prepare("INSERT INTO userProfile (picName,picPath,username, Name, introduction, Specialization,skillset, Email, ContactNo, user_Id) VALUES (:picName, :picPath,:username,:Name,:introduction,:Specialization,:skillset,:Email,:ContactNo,:user_Id)");$stmt->bindValue(':picName',$_FILES['userfile']['name']);$stmt->bindValue(':picPath', $uploadfile);$stmt->bindValue(':username',$username);$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->bindValue(':user_Id',$_SESSION['user_id']);$stmt->execute();

    I am not sure how to validate the type in line 51. Since this is for profile picture, I wanted it to validate PNG and JPG/jpeg only. I can't seem to achieve that either.

    My HTML Form:

                <tr>              <th scope="row"><div align="left">Profile Picture:</div></th>              <td><!-- MAX_FILE_SIZE must precede the file input field -->                                <input type="hidden" name="MAX_FILE_SIZE" value="100000" />                                <!-- Name of input element determines name in $_FILES array -->                 Send this file:                <input name="userfile" type="file" /></td>            </tr>

    (PS: I'm not sure if I should continue posting here since it will get lengthy, but my title already includes the image.. ;-; )

  12. There is no reason why a hidden input cannot be used to set default value for radio name group, messing about? You just place hidden input above radio name group, not much messing around there, it would save having to adjust php code to adjust default value which could be more decriptive value than a true/false value used here, you would just adjust hidden value and done!

    Ah, well this was just a testing out from the previous posts that's been suggested to use >< I have taken that down now and use justsomeguy's example in use. Thank you dsonesuk and justsomeguy! :D I didn't realised that the "[]" in the form plays the part too >< I managed to get them insert to the database now ^^ :good: I shall now work on the images, I will have to post that later after trying it out :)

  13. This is what I have tried using the case statement:

    	switch ($data['specialization'] == true) {    case 'specialization_1':	 $data['specialization']= print_r($data['specialization'],true);	 //$data['specialization']= print_r($_POST['specialization'], true);	 //declare skillset	// $skillset = extract($data['ISgrp1'].",".$data['ISgrp2'].",".$data['ISgrp3'].",".$data['ISgrp4'].",".$data['ISgrp5']);	 //$skillset = print_r($_POST['ISgrp1'].",".$_POST['ISgrp2'].",".$_POST['ISgrp3'].",".$_POST['ISgrp4'].",".$_POST['ISgrp5']);	 $skillset = implode(",", $_POST['ISgrp1'] .$_POST['ISgrp1']. $_POST['ISgrp1'] .$_POST['ISgrp1']. $_POST['ISgrp1'] );    case 'specialization_2':	$data['specialization']= print_r($data['specialization'],true);	 //declare skillset	 $skillset = implode(",",$data['IMgrp1'].$data['IMgrp2'].$data['IMgrp3'].$data['IMgrp4'].$data['IMgrp5']);    case 'specialization_3':	 $data['specialization']= print_r($data['specialization'],true);	  //declare skillset	 $skillset = print_r(",",$data['CNETgrp1'].$data['CNETgrp2'].$data['CNETgrp3'].$data['CNETgrp4'].$data['CNETgrp5']);	case 'specialization_4':	 $data['specialization']= print_r($data['specialization'],true);	  //declare skillset	 $skillset = print_r(",",$data['ITSMgrp1'].$data['ITSMgrp2'].$data['ITSMgrp3'].$data['ITSMgrp4'].$data['ITSMgrp5']);	  }

    The database now shows that the specialization is Array( [0]=>false, [1]=>IS ) while the skillset column shows 1. The problem is, I choose IS and all "3" for the $skillsets(ISgrp1, ISgrp2,ISgrp3, ISgrp4,ISgrp5). Where am I going wrong? Was it my form or my php? Below is my part of table html for IS :

    <!--- Specialization Radio Buttons--->                <td><table width="auto">                    <tr>                      <td>                      <input type="hidden" name="specialization[]" value="false">                      <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><!--- Skillsets Radio Buttons---><!--- IS Radio Buttons Radio Buttons--->                  <tr id="ISrow1">                    <td width="auto"><div align="left">C#</div></td>                    <td width="auto">                    <input type="hidden" name="ISgrp1[]" value="false">                    <label>                        <input name="ISgrp1[]" type="radio" id="IS_table_1" value="C#-0">                        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>                    <input type="hidden" name="ISgrp2[]" value="false">                    <label>                        <input name="ISgrp2[]" type="radio" id="IS_table_7" value="PHP/SQL-0">                        0</label></td>                    <td><input type="radio" name="ISgrp2[]" value="PHP/SQL-1" id="IS_table_8">                      1</td>                    <td><label>                        <input type="radio" name="ISgrp2[]" value="PHP/SQL-2" id="IS_table_9">                        2</label></td>                    <td><label>                        <input type="radio" name="ISgrp2[]" value="PHP/SQL-3" id="IS_table_10">                        3</label></td>                    <td><label>                        <input type="radio" name="ISgrp2[]" value="PHP/SQL-4" id="IS_table_11">                        4</label></td>                    <td><label>                        <input type="radio" name="ISgrp2[]" value="PHP/SQL-5" id="IS_table_12">                        5</label></td>                  </tr>                  <tr id="ISrow3">                    <td><div align="left">HTML/CSS</div></td>                    <td>                  <input type="hidden" name="ISgrp3[]" value="false">                    <label>                        <input name="ISgrp3[]" type="radio" id="IS_table_13" value="HTML/CSS-0">                        0</label></td>                    <td><input type="radio" name="ISgrp3[]" value="HTML/CSS-1" id="IS_table_14">                      1</td>                    <td><label>                        <input type="radio" name="ISgrp3[]" value="HTML/CSS-2" id="IS_table_15">                        2</label></td>                    <td><label>                        <input type="radio" name="ISgrp3[]" value="HTML/CSS-3" id="IS_table_16">                        3</label></td>                    <td><label>                        <input type="radio" name="ISgrp3[]" value="HTML/CSS-4" id="IS_table_17">                        4</label></td>                    <td><input type="radio" name="ISgrp3[]" value="HTML/CSS-5" id="IS_table_18">                      5</td>                  </tr>                  <tr id="ISrow4">                    <td><div align="left">Java Enterprise Development</div></td>                    <td>                    <input type="hidden" name="ISgrp4[]" value="false">                    <label>                        <input name="ISgrp4[]" type="radio" id="IS_table_19" value="Java Enterprise Development-0">                        0</label></td>                    <td><label>                        <input type="radio" name="ISgrp4[]" value="Java Enterprise Development-1" id="IS_table_20">                        1</label></td>                    <td><input type="radio" name="ISgrp4[]" value="Java Enterprise Development-2" id="IS_table_21">                      2</td>                    <td><label>                        <input type="radio" name="ISgrp4[]" value="Java Enterprise Development-3" id="IS_table_22">                        3</label></td>                    <td><label>                        <input type="radio" name="ISgrp4[]" value="Java Enterprise Development-4" id="IS_table_23">                        4</label></td>                    <td><input type="radio" name="ISgrp4[]" value="Java Enterprise Development-5" id="IS_table_24">                      5</td>                  </tr>                  <tr id="ISrow5">                    <td><div align="left">Mobile Application Development</div></td>                    <td>                    <input type="hidden" name="ISgrp5[]" value="false">                    <label>                        <input name="ISgrp5[]" type="radio" id="IS_table_25" value="Mobile Application Development-0">                        0</label></td>                    <td><label>                        <input type="radio" name="ISgrp5[]" value="Mobile Application Development-1" id="IS_table_26">                        1</label></td>                    <td><input type="radio" name="ISgrp5[]" value="Mobile Application Development-2" id="IS_table_27">                      2</td>                    <td><label>                        <input type="radio" name="ISgrp5[]" value="Mobile Application Development-3" id="IS_table_28">                        3</label></td>                    <td><label>                        <input type="radio" name="ISgrp5[]" value="Mobile Application Development-4" id="IS_table_29">                        4</label></td>                    <td><input type="radio" name="ISgrp5[]" value="Mobile Application Development-5" id="IS_table_30">                      5</td>                  </tr>

    That's going to print "The array is Array". When you try to use an array in a string, like a database query, it just uses the word "Array". So if your query has "Array" in it then that's what you're doing wrong. You didn't show the code that inserts data in the database though, so I don't know how the code you did show fits in. Where is the rest of your code?

    After googling more ways to make this array to string, I found out that this was due to the changes they made these changes in version 5.4 where the arrays will still be arrays? http://php.net/manual/en/migration54.incompatible.php So, most of the ones that using implode,extract etc are not valid anymore?

  14. This is what I mean:

    $ar = array(1, 2, 3);echo 'The array is ' . $ar;
    That's going to print "The array is Array". When you try to use an array in a string, like a database query, it just uses the word "Array". So if your query has "Array" in it then that's what you're doing wrong. You didn't show the code that inserts data in the database though, so I don't know how the code you did show fits in. Where is the rest of your code?

    Okay, I somewhat get what you mean by this but I don't think this is what I have in mind. I have about 12 radio groups and I thought using $_POST['radiobutton_groupname'] would already take in the value?(i declare this inside $data['radiobutton_groupname'] = $_POST['radiobutton_groupname']) I'm not sure why I would have to create this array when it will automatically get the value. But if this is the only way, i will post my codes later after i try implementing this.

    My codes before the insert query you see below(this is also what i meant by the $_POST['radiobutton_groupname']):

        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($data,'trim');          <-------------------cut out unneccessary codes----------------------------->        // 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		 <-------cut out unneccessary codes of other inputs------------>		 //taking relevant data only, below is all the radio buttons		 $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'];//$data['skillset'] =  "";$skillset = "";<--------------cut out unneccessary codes of other inputs-------------->//tried this out yesterday but they could find the variable declared//check if specialization is not checked (use the hidden input to access this)if ($data['specialization'] == "false") {$errors[] = ("Please select your specialization! Specialization is required!");}//	    //validate for IS//	if ((isset($data['specialization']) && $data['specialization'] == 'specialization_1')) {//		//$data['specialization'] = "IS";//		if (($data['ISgrp1'] == "false") || ($data['ISgrp2'] == "false") || ($data['ISgrp3'] == "false") || ($data['ISgrp4'] == "false") || ($data['ISgrp5'] == "false")) {//			$errors[] = ("Please select your skillsets!");//		}//		else {//		//set them to $skillset//		 $skillset = array_merge($data['ISgrp1'],$data['ISgrp2'],$data['ISgrp3'],$data['ISgrp4'],$data['ISgrp5']);//		// $skillset = ($data['ISgrp1'].",".$data['ISgrp2'].",".$data['ISgrp3'].",".$data['ISgrp4'].",".$data['ISgrp5']);//		}//		}//		//validate for IM//	if ((isset($data['specialization']) && $data['specialization'] == 'specialization_2')) {//		//$data['specialization'] = "IM";//		if (($data['IMgrp1'] == "false") || ($data['IMgrp2'] == "false") || ($data['IMgrp3'] == "false") || ($data['IMgrp4'] == "false") || ($data['IMgrp5'] == "false")) {//			$errors[] = ("Please select your skillsets!");//		}//		else {//		//set them to $skillset//		 $skillset = array_merge($data['IMgrp1'],$data['IMgrp2'],$data['IMgrp3'],$data['IMgrp4'],$data['IMgrp5']);//		// $skillset = ($data['IMgrp1'].",".$data['IMgrp2'].",".$data['IMgrp3'].",".$data['IMgrp4'].",".$data['IMgrp5']);//		}//		}//		//validate for CNET//	if ((isset($data['specialization']) && $data['specialization'] == 'specialization_3')) {//		// $data['specialization']= "CNET";//		if (($data['CNETgrp1'] == "false") || ($data['CNETgrp2'] == "false") || ($data['CNETgrp3'] == "false") || ($data['CNETgrp4'] == "false") || ($data['CNETgrp5'] == "false")) {//			$errors[] = ("Please select your skillsets!");//		}//		else {//		 $skillset = array_merge($data['CNETgrp1'],$data['CNETgrp2'],$data['CNETgrp3'],$data['CNETgrp4'],$data['CNETgrp5']);//		// $skillset = ($data['CNETgrp1'].",".$data['CNETgrp2'].",".$data['CNETgrp3'].",".$data['CNETgrp4'].",".$data['CNETgrp5']);//		}//		}//		//Check for ITSM//	if ((isset($data['specialization']) && $data['specialization'] == 'specialization_4')) {//		 //$data['specialization'] = "ITSM";//		if (($data['ITSMgrp1'] == "false") || ($data['ITSMgrp2'] == "false") || ($data['ITSMgrp3'] == "false") || ($data['ITSMgrp4'] == "false") || ($data['ITSMgrp5'] == "false")) {//			$errors[] = ("Please select your skillsets!");//		}//		else {		 //		 $skillset = array_merge($data['ITSMgrp1'],$data['ITSMgrp2'],$data['ITSMgrp3'],$data['ITSMgrp4'],$data['ITSMgrp5']);//		 //$skillset = ($data['ITSMgrp1'].",".$data['ITSMgrp2'].",".$data['ITSMgrp3'].",".$data['ITSMgrp4'].",".$data['ITSMgrp5']);//		}//		}					  <---codes before any changes--->	  //	//assign skillsets based on the specialization//	if (!$data['specialization'] = "" && isset($data['specialization'])) {//		if ($data['specialization']== "specialization_1") {//			$data['specialization'] = "IS";//		 $skillset = (implode(",",($data['ISgrp1']).",".($data['ISgrp2']).",".($data['ISgrp3']).",".($data['ISgrp4']).",".($data['ISgrp5'])));//		}//		if ($data['specialization']== "specialization_2") {//		 $data['specialization'] = "IM";//		 $skillset = (implode(",",($data['IMgrp1']).",".($data['IMgrp2']).",".($data['IMgrp3']).",".($data['IMgrp4']).",".($data['IMgrp5'])));//		}//		if ($data['specialization']== "specialization_3") {//		 $data['specialization']= "CNET";//		 $skillset = (implode(",",($data['CNETgrp1']).",".($data['CNETgrp2']).",".($data['CNETgrp3']).",".($data['CNETgrp4']).",".($data['CNETgrp5'])));//		}//		if ($data['specialization']== "specialization_4") {//		 $data['specialization'] = "ITSM";//		 $skillset = (implode(",",($data['ITSMgrp1']).",".($data['ITSMgrp2']).",".($data['ITSMgrp3']).",".($data['ITSMgrp4']).",".($data['ITSMgrp5'])));//		}		//	}        //try without implode	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']);		}		

     

     

    My insert data goes like this(after doing all validation):

            // 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 (username, Name, introduction, Specialization,skillset, Email, ContactNo, user_Id) VALUES 	  (:username,:Name,:introduction,:Specialization,:skillset,:Email,:ContactNo,:user_Id)");//$stmt->bindValue(':picName',$_FILES['image']['name']);//$stmt->bindValue(':picPath', $imgDir);$stmt->bindValue(':username',$data['username']);$stmt->bindValue(':Name', $data['name']);$stmt->bindValue(':introduction',$data['introduction']);$stmt->bindValue(':Specialization',$data['specialization']);$stmt->bindValue(':skillset',$skillset);$stmt->bindValue(':Email',$data['email']);$stmt->bindValue(':ContactNo',$data['contactNo']);$stmt->bindValue(':user_Id',$_SESSION['user_id']);$stmt->execute();        }       // if no errors at this point, redirect to the exact same url of this page to prevent the browser from resubmitting the data by causing a get request for the page        if(empty($errors)){            $host = $_SERVER['HTTP_HOST'];            $uri = $_SERVER['REQUEST_URI'];            header("Location:addProfile.php?success=1");            exit;        }        // if there were errors in any of the above form processing code, continue on this page, displaying any errors, redisplay form, (re)populate the form fields with data...foreach($errors as $error)    {        printf("<li>%s</li>", $error);//exit();    }    } // end of post method form processing        // get method/display code (if any) - get/produce data that's needed to display the page    // to edit existing data, if the $data array is empty at this point, retrieve any existing data from the database table} catch(PDOException $e){ // end of database dependent code, handle any errors    $status = empty($query) ? 'Connection failed':" Query failed: $query";    // application message    trigger_error("$status, Error: {$e->getMessage()}, File: {$e->getFile()}, Line: {$e->getLine()}");    // user message    $errors[] = 'Sorry, this page is not working at this time.';}// done with the database, destroy any pdostatment resource and close connection$stmt = null;$database = null;

     

    There aren't rules like that. You can use implode wherever you want, if using implode is the right thing to do. Why do you think you need to use it? Do you have an array of values that you're trying to join? You didn't use it correctly above, because you didn't pass it an array of values, you passed it 2 strings. Instead of asking if you're not supposed to use it, ask why you think you need to use it. If you can't answer that then you probably don't need to use it. Don't just try things without understanding what you're doing, if you're programming you need to understand what you're doing and why you're doing it. Look things up in the manual if you have questions about how they work.

    And make sure you're using the correct operators. In your original code it is not correct to use = inside those if statements.http://php.net/manual/en/language.operators.comparison.phpAlso, instead of a series of if statements which all check the same variable, you could use a switch statement instead.http://php.net/manual/en/control-structures.switch.php

     

    I believe I do need to implode it because I want to join 4 arrays(radio button groups) into 1(string) to store in one column in the database. What I am confused now is that implode joins all array values in each array, but I do not want that since I only need the value the user click. I will then create a new variable and have the 4 values from those 4 arrays, joining it together and then I can get it to store it in database.

    Pardon for my lack of knowledge and thank you for the link. I'll be sure to read it up :)

  15. You can use a hidden type input using same name attribute value placed above radio type inputs to give you a default value, when radio button selected it will be overridden by it value.

    I'm not sure if I understand but this is so I do not need to "checked" every one radio button of the group, am I right?

     

     

    What are $data and $skillset, how do you use $skillset?That happens when you try to use an array as a single value, you're not doing something right. You should show the code where that happens.As far as blank pages go, that's usually a fatal error that is going to a log or something instead of being displayed. If you're testing this on your own server then I would recommend going through php.ini and looking at the various config options, especially the options for error reporting. When you're developing it's common to set display_errors to 1 or on with error_reporting set to E_ALL. You don't want to hide error messages, you want to show them so you can fix them. You could also use the error logging settings to log all errors if you'd rather check a log file than see the error messages in the browser. You need to find the error messages though, you can't fix problems otherwise. To change error settings at runtime for a single script you can use ini_set and error_reporting, e.g.:

    ini_set('display_errors', 1);error_reporting(E_ALL);

     

    $data is actually an array for all my inputs to put through. It's just to trim all inputs actually.

    $data = array();//array_map('trim',$_POST); array_walk_recursive($data,'trim'); 

    $Skillset is a new variable that I declare where I want to assign to the selected radio group set, meaning if I chose specialization "IS", the radio buttons that are based on "IS" is the one I wanted to store in the database. I would like to clarify something though: radio buttons will store in the values am I right? If I did not declare the $data['specilaization'] inside the validation bracket (my first post), the id will be taken to store in the database. I am not sure what you meant by this: "That happens when you try to use an array as a single value, you're not doing something right. You should show the code where that happens. " Did this happen because I declare i declare the $data['specialization'] instead of getting the actual value? Now, it gives me undefined index for all the rows inside the $skillset. I'm kind of bummed now. Am i not suppose to use implode? How do i use implode in this case? ><

  16. The if conditions are currently setting variable when using a single '=' they not comparing when they should be using double '==' to compare value or triple '===' to compare value and type.

    I actually used the '==' but they do not take in the value(?), the word "array" is inserted into my database and not the value. Same for the '===' although I do not think the type matters in this case since they are a radio button group ><

  17. I have a hard time trying to make my radio buttons work. I know that radio buttons are a special case whereby if the user did not click on them, the value will not be taken in. Thus, i have made all my radio buttons to be set per group. However, i can't seem to get the validating right.

    This is my current validating code as of now:

    	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']);		}		

    I have set my specialization radio group to correspond together with my $skillset. However, my $specialization is somehow always set to "ITSM" although I click on IS" and $skillset is showing only ",,,," in the database. (it used to be nothing as i have to declare $skillset = "" for they can't read my $skillset inside the {} , I'm not sure what i have done to the piece of code o.o).

     

    I've heard about imploding (since it's in an array), and this is what I came up with:

    	//assign skillsets based on the specialization	if (!$data['specialization'] = "" && isset($data['specialization'])) {		if ($data['specialization']= "specialization_1") {			$data['specialization'] = "IS";		 $skillset = (implode(",",($data['ISgrp1']).",".($data['ISgrp2']).",".($data['ISgrp3']).",".($data['ISgrp4']).",".($data['ISgrp5'])));		}		if ($data['specialization']= "specialization_2") {		 $data['specialization'] = "IM";		 $skillset = (implode(",",($data['IMgrp1']).",".($data['IMgrp2']).",".($data['IMgrp3']).",".($data['IMgrp4']).",".($data['IMgrp5'])));		}		if ($data['specialization']= "specialization_3") {		 $data['specialization']= "CNET";		 $skillset = (implode(",",($data['CNETgrp1']).",".($data['CNETgrp2']).",".($data['CNETgrp3']).",".($data['CNETgrp4']).",".($data['CNETgrp5'])));		}		if ($data['specialization']= "specialization_4") {		 $data['specialization'] = "ITSM";		 $skillset = (implode(",",($data['ITSMgrp1']).",".($data['ITSMgrp2']).",".($data['ITSMgrp3']).",".($data['ITSMgrp4']).",".($data['ITSMgrp5'])));		}			}

    However, they are showing undefined $skillset and the $data[''] inside the $skillset. Please tell me where i've gone wrong, I have been searching for some examples but the examples are only those with male/female gender type of option (simple type). Why is it that they can't get the $skillset defined in that validation? Also, can someone give me a link to a good image uploading tutorial? I can't seem to get it right as it always goes to a blank page when i hit the submit><

    This is my page(my html form and my php codes ): addProfile.php

×
×
  • Create New...