Jump to content

phpNOvice

Member
  • Posts

    44
  • Joined

  • Last visited

Posts posted by phpNOvice

  1. Hello killers,

    I have manage to create codes that could upload a image that is purposely to serve as profile picture of a certain student. My problem is how to rename it to aN AUTO COLLATE UNIQUE ID NUMBER so that i can display it specifically to a certain student account which bears the unique id number. The variable is $student_id.

    <?php
        session_start();
        $session_id = $_SESSION['user_id'];
        if($session_id == null){
           header("location:Student_Edit.php");
           die();
        }
        include 'Connect.php';
        $flag = "";
        $result = mysql_query("SELECT * FROM student_information where student_id='{$_SESSION['user_id']}'",$link_id);;
        $data = mysql_fetch_array($result);
    ?>     
    <div class="style3" >
        <?php
        $uploadpath = 'upload/';     
        $max_size = 2000;         
        $alwidth = 900;           
        $alheight = 800;          
        $allowtype = array('bmp', 'gif', 'jpg', 'jpe', 'png','psd');       
        if(isset($_FILES['fileup']) && strlen($_FILES['fileup']['name']) > 1) {
        $uploadpath = $uploadpath . basename( $_FILES['fileup']['name']);      
        $sepext = explode('.', strtolower($_FILES['fileup']['name']));
        $type = end($sepext);      
        list($width, $height) = getimagesize($_FILES['fileup']['tmp_name']);     
        $err = '';         
        if(!in_array($type, $allowtype)) $err .= 'The file: <b>'. $_FILES['fileup']['name']. '</b> not has the allowed extension type.';
        if($_FILES['fileup']['size'] > $max_size*1000) $err .= '<br/>Maximum file size must be: '. $max_size. ' KB.';
        if(isset($width) && isset($height) && ($width >= $alwidth || $height >= $alheight)) $err .= '<br/>The maximum Width x Height must be: '. $alwidth. ' x '. $alheight;
        if($err == '') {
        if(move_uploaded_file($_FILES['fileup']['tmp_name'], $uploadpath)) { 
          echo 'File: <b>'. basename( $_FILES['fileup']['name']). '</b> successfully uploaded:';
          echo '<br/>File type: <b>'. $_FILES['fileup']['type'] .'</b>';
          echo '<br />Size: <b>'. number_format($_FILES['fileup']['size']/1024, 3, '.', '') .'</b> KB';
          if(isset($width) && isset($height)) echo '<br/>Image Width x Height: '. $width. ' x '. $height;
          echo '<br/><br/>Image address: <b>http://'.$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['REQUEST_URI']), '\\/').'/'.$uploadpath.'</b>';
        }
        else echo '<b>Unable to upload the file.</b>';
      }
      else echo $err;
    }
    ?>
    

    Please modify my codes to rename the uploaded file to the student id of the student who is uploading it.

  2. Hello Ben, i have solved the flag part but still the problem of uploading image is there even i have followed your advise in enctype="multipart/form-data" 

    which i have missed also last time. I got brand new codes now and best thing is i got WARNING displayed. Kindly help me this out.

    <?php
    error_reporting(E_ALL | E_NOTICE);
    ini_set('display_errors', '1');
    	session_start();
    	$session_id = $_SESSION['user_id'];
    	if($session_id == null){
    	   header("location:Student_Edit.php");
    	   die();
    	}
    	include 'Connect.php';
    	$flag = "";
    	$student_id = $_POST['student_id'];
    	$first_name = $_POST['first_name'];
    	$last_name = $_POST['last_name'];
    	$gender = $_POST['gender'];
    	$date_of_birth = date("Y-m-d",strtotime($_POST['date_of_birth']));
    	$contact_no = $_POST['contact_no'];
    	$grade	= $_POST['grade'];
    	$section = $_POST['section'];
    	$LRN = $_POST['LRN'];
    	$email1 = $_POST['email1'];
    	$email2 = $_POST['email2'];
    	$address = $_POST['address'];
    	$description = $_POST['description'];
    	$imagename = "";
    	
      	$query = "UPDATE student_information SET first_name='$first_name',last_name='$last_name',";    
        $query .= "gender='$gender',date_of_birth='$date_of_birth',contact_no='$contact_no',grade='$grade',section='$section',";
        $query .= "LRN='$LRN',email1='$email1',email2='$email2',address='$address',description='$description'";  	
    	$query .= " WHERE student_id='{$_SESSION['user_id']}'";      
    	$result = mysql_query($query, $link_id);
    		if(mysql_error() != null){
    		die(mysql_error());
    	}
    	if($_FILES['image']['name'] != ""){
                    $filename = $_FILES['image']['name'];
                    $ext = strrchr($filename,".");
                    $imagename = $student_id;
                    $imagename .="_". $filename; 
                    if($ext ==".jpg" || $ext ==".jpeg" || $ext ==".JPG" || $ext ==".JPEG" || $ext ==".gif" || $ext ==".GIF"){
                        $size = $_FILES['image']['size'];
                        if($size > 0 && $size < 1000000){
                            $archive_dir = "images/".$student_id;
                            $userfile_tmp_name = $_FILES['image']['tmp_name'];
                            if(move_uploaded_file($userfile_tmp_name, $archive_dir)){
           mysql_query("update student_information set image='$imagename' where student_id='{$_SESSION['user_id']}'", $link_id); 
                                $flag = "success"; 
                                if(mysql_error()!=null){
                                    die(mysql_error());
                                }
                            }
                            else{
                                if(file_exists('images/' . $imagename)) {
                                    unlink('images/' . $imagename); 
                                }
                                rollbackData();
                            }
                        }
                        else{
                            if(file_exists('images/' . $imagename)) {
                                unlink('images/' . $imagename); 
                            }
                            rollbackData();
                            die("You can upload image of 1 MB size only. Please, try again.");
                        }
                    }           
                    else{
                        if(file_exists('images/' . $imagename)) {
                            unlink('images/' . $imagename); 
                        }
                        rollbackData();
                        die("You can upload images of .jpg, .jpeg, .gif extensions only. Please, try again. ");
                    }
                  }
    			  if($result){ 
    		$flag = "success";
    	}
    	else{
    		 $flag = "error"; 
      	}
    	header("location:Student_Edit.php?flag=$flag&student_id='{$_SESSION['user_id']}'");	  
    ?>     
    

    and these are the 3 warnings displayed except for being deprecated maybe you can figure this out.

     

    Warning: move_uploaded_file(images/<br /> <b>Notice</b>: Undefined variable: student_id in <b>C:\xampp\htdocs\a\Student_Edit.php</b> on line <b>112</b><br /> ;): failed to open stream: Invalid argument inC:\xampp\htdocs\a\Student_Edit_Handler.php on line 45

    Warning: move_uploaded_file(): Unable to move 'C:\xampp\tmp\php87E3.tmp' to 'images/<br /> <b>Notice</b>: Undefined variable: student_id in <b>C:\xampp\htdocs\a\Student_Edit.php</b> on line <b>112</b><br /> ;' in C:\xampp\htdocs\a\Student_Edit_Handler.php on line 45

    Fatal error: Call to undefined function rollbackData() in C:\xampp\htdocs\a\Student_Edit_Handler.php on line 56

     

    Please advise

  3. Hi there, 

    i have recieved this notice 

    Warning: Header may not contain more than a single header, new line detected in C:\xampp\htdocs\a\Student_Edit_Handler.php on line 53

    and these are my codes. Kindly help me to fix this.

    <?php
    	session_start();
    	$session_id = $_SESSION['user_id'];
    	if($session_id == null){
    	   header("location:Student_Edit.php");
    	   die();
    	}
    	include 'Connect.php';
    	$flag = "success";
    	function rollbackData(){
    		mysql_query(" ROLLBACK ");
    		global $flag; 
    		$flag = "error";
    		if(mysql_error() != null){
    			die(mysql_error());
    		}
    	}
    	$student_id = $_POST['student_id'];
    	$first_name = $_POST['first_name'];
    	$last_name = $_POST['last_name'];
    	$gender = $_POST['gender'];
    	$date_of_birth = date("Y-m-d",strtotime($_POST['date_of_birth']));
    	$contact_no = $_POST['contact_no'];
    	$grade = $_POST['grade'];
    	$section = $_POST['section'];
    	$LRN = $_POST['LRN'];
    	$email1 = $_POST['email1'];
    	$email2 = $_POST['email2'];
    	$address = $_POST['address'];
    	$description = $_POST['description'];
    	$imagename = "";
    	$flag= "";
    		mysql_query("SET AUTOCOMMIT = 0 ");
    		if(mysql_error() != null){
    			die(mysql_error());
    		}
    	$query = "UPDATE student_information SET first_name='$first_name',last_name='$last_name',";    
    	$query .= "gender='$gender',date_of_birth='$date_of_birth',contact_no='$contact_no',grade='$grade',section='$section',";
    	$query .= "LRN='$LRN',email1='$email1',email2='$email2',address='$address',description='$description'";     
    	$query .= " WHERE student_id='{$_SESSION['user_id']}'";      
    	$result = mysql_query($query, $link_id);
    	if(mysql_error() != null){
    		die(mysql_error());
    	}
    	if($result)
    	{ 
    		$flag = "success";
    	}
        else
    	{
    		 $flag = "error"; 
      	}
    	header("location:Student_Edit.php?flag=$flag&student_id=student_id=$student_id");
    ?>
    Please advise
    
  4. These are my codes in the html

    <tr class="stylesmall">
    		  <td>Update Learner Image: </td>
    		  <td colspan="3"><input type="file" name="image">
    		           <span class="style3"> <span class="stylesmall">jpg or gif file only</span></span></td>
    		</tr>
            <tr>
              <td colspan="4"><span class="stylered style6"><span class="style3">*</span> <em>fields are compulsory</em></span></td>
            </tr>
    		
            <tr>
              <td colspan="4" align="center"><input name="update" type="submit" id="update" value="Update">
    

    i read the link you gave me and tried to modify some codes but then it end up same error.

  5. i have writen flags on theStudent_Edit.php.

    <?php  if(!empty($_GET['flag']) && $_GET['flag'] == "success") { ?>   
    		<span class="stylered style1"><span class="style5">Learner Information updated successfully.</span></span>  
            <?php } else if(!empty($_GET['flag']) && $_GET['flag'] == "error") { ?>
    		<span class="stylered style3 style5"><span class="style1">Error while updating Learner Information. Please try again</span></span> 
            <?php }  ?>	</td>
    

    the specific error im getting is the flag=error which is 

    "Error while updating Learner Information. Please try again."

    The reason im pasting almost the whole codes.

  6. Hi Ben, 

     

    i got new codes now that uploads the image of registered student with unique student_id. it is called Student_Edit_handler. This was in response to the idea you suggested.

    $student_id = $_POST['student_id'];
        $first_name = $_POST['first_name'];
        $last_name = $_POST['last_name'];
        $gender = $_POST['gender'];
        $date_of_birth = date("Y-m-d",strtotime($_POST['date_of_birth']));
        $contact_no = $_POST['contact_no'];
        $grade = $_POST['grade'];
        $section = $_POST['section'];
        $LRN = $_POST['LRN'];
        $email1 = $_POST['email1'];
        $email2 = $_POST['email2'];
        $address = $_POST['address'];
        $description = $_POST['description'];
        $imagename = "";
        $flag= "";
            mysql_query("SET AUTOCOMMIT = 0 ");
            if(mysql_error() != null){
                die(mysql_error());
            }
        $query = "UPDATE student_information SET first_name='$first_name',last_name='$last_name',";    
        $query .= "gender='$gender',date_of_birth='$date_of_birth',contact_no='$contact_no',grade='$grade',section='$section',";
        $query .= "LRN='$LRN',email1='$email1',email2='$email2',address='$address',description='$description'";     
        $query .= " WHERE student_id='{$_SESSION['user_id']}'";      
        $result = mysql_query($query, $link_id);
        if(mysql_error() != null){
            die(mysql_error());
            }
            /*
                This block shows the start codes for the upload of the Learner's image
            */
     if($_FILES['image']['name'] != ""){
                    $filename = $_FILES['image']['name'];
                    $ext = strrchr($filename,".");
                    $imagename = $student_id;
                    $imagename .="_". $filename; 
                    if($ext ==".jpg" || $ext ==".jpeg" || $ext ==".JPG" || $ext ==".JPEG" || $ext ==".gif" || $ext ==".GIF"){
                        $size = $_FILES['image']['size'];
                        if($size > 0 && $size < 1000000){
                            $archive_dir = "images";
                            $userfile_tmp_name = $_FILES['image']['tmp_name'];
                            if(move_uploaded_file($userfile_tmp_name, $archive_dir .'/'. $student_id .'_'. $imagename .'.'. $ext)){
                                /*
                                    if image is successfully uploaded then imagename is stored in database.
                                */
                                mysql_query("update student_information set image='$imagename' where student_id='{$_SESSION['user_id']}'", $link_id); 
                                $flag = "success"; 
                                if(mysql_error()!=null){
                                    die(mysql_error());
                                }
                            }else{
                                if(file_exists('images/' . $imagename)) {
                                    unlink('images/' . $imagename); 
                                }
                                rollbackData();
                            }
                        }else{
                            if(file_exists('images/' . $imagename)) {
                                unlink('images/' . $imagename); 
                            }
                            rollbackData();
                            die("You can upload image of 1 MB size only. Please, try again.");
                        }
                    }else{
                        if(file_exists('images/' . $imagename)) {
                            unlink('images/' . $imagename); 
                        }
                        rollbackData();
                        die("You can upload images of .jpg, .jpeg, .gif extensions only. Please, try again. ");
                    }
                    }else{
                $flag="error";
        }
            if($flag == "success"){
                mysql_query(" COMMIT ");
                $flag="success";
                if(mysql_error() != null){
                    die(mysql_error());
                }
                }
            header("location:Student_Edit.php?flag=$flag");
            die();      
    ?>
    

    the problem left now is the image wont upload and it flags the error.

    i know this has been a lot but i need you to help me modify these codes.

  7. Sorry to bother you Ben, There has been slightly changes since i am also working in solving the scenario. here is now my current codes.

    if($_FILES['image']['name'] != ""){
    				$filename = $_FILES['image']['name'];
    				$ext = strrchr($filename,".");
    				$imagename = $student_id;
    				$imagename .="_". $filename; 
    				if($ext ==".jpg" || $ext ==".jpeg" || $ext ==".JPG" || $ext ==".JPEG" || $ext ==".gif" || $ext ==".GIF"){
    					$size = $_FILES['image']['size'];
    					if($size > 0 && $size < 1000000){
    						$archive_dir = "images";
    						$userfile_tmp_name = $_FILES['image']['tmp_name'];
    						if(move_uploaded_file($userfile_tmp_name, $archive_dir .'/'. $student_id .'_'. $imagename .'.'. $ext)){
    
    

    this codes can upload an image.

    there is no error.

    the image is uploaded succesfully.

    Example if the uplaoded file has a file name pic.jpg,,after it has been succesfully upload it is rename to

    "_pic.jpg"

    without the quotes just underscore and the file name itself.

    What i wanted is to rename it to its unique student_id number so i can display it smoothly to another page.

  8. This is so far what i got Ben and i failed to rename the uploaded file to its $student_id.

    if($_FILES['image']['name'] != ""){
    				$filename = $_FILES['image']['name'];
    				$ext = strrchr($filename,".");
    				$imagename = $student_id;
    				$imagename .="_". $filename; 
    				if($ext ==".jpg" || $ext ==".jpeg" || $ext ==".JPG" || $ext ==".JPEG" || $ext ==".gif" || $ext ==".GIF"){
    					$size = $_FILES['image']['size'];
    					if($size > 0 && $size < 1000000){
    						$archive_dir = "images";
    						$userfile_tmp_name = $_FILES['image']['tmp_name'];
    						if(move_uploaded_file($userfile_tmp_name, "$archive_dir/$imagename")){
    

    The file has been succesfully uploaded Ben but help me to insert the codes which to rename its file name to its student_id so i can display it to another page smoothly.

  9. Hello Admins and Php Freaks,

     

    I have manage to upload the image using this codes

    $student_id = $_POST['student_id'];
    	$first_name = $_POST['first_name'];
    	$last_name = $_POST['last_name'];
    	$gender = $_POST['gender'];
    	$date_of_birth = date("Y-m-d",strtotime($_POST['date_of_birth']));
    	$contact_no = $_POST['contact_no'];
    	$grade	= $_POST['grade'];
    	$section = $_POST['section'];
    	$LRN = $_POST['LRN'];
    	$email1 = $_POST['email1'];
    	$email2 = $_POST['email2'];
    	$address = $_POST['address'];
    	$description = $_POST['description'];
    	$LRCardname= "";
    	$LRCard2name= "";		
    	
    	
      	$query = "UPDATE student_information SET first_name='$first_name',last_name='$last_name',";    
        $query .= "gender='$gender',date_of_birth='$date_of_birth',contact_no='$contact_no',grade='$grade',section='$section',";
        $query .= "LRN='$LRN',email1='$email1',email2='$email2',address='$address',description='$description'";  	
    	$query .= " WHERE student_id='$student_id'";      
    	$result = mysql_query($query, $link_id);
    	if(mysql_error() != null){
    		die(mysql_error());
    	}
    		
    	/*
    			This block shows the start codes for the upload of the Learner Report Card.
    	*/
    	
    	if($result){
    			if($_FILES['LRCard']['name'] != ""){
    				$filename = $_FILES['LRCard']['name'];
    				$ext = strrchr($filename,".");
    				$LRCardname = $student_id;
    				$LRCardname .="_". $filename; 
    				if($ext ==".jpg" || $ext ==".jpeg" || $ext ==".JPG" || $ext ==".JPEG" || $ext ==".gif" || $ext ==".GIF"){
    					$size = $_FILES['LRCard']['size'];
    					if($size > 0 && $size < 5000000){
    						$archive_dir = "LRCards";
    						$userfile_tmp_name = $_FILES['LRCard']['tmp_name'];
    						if(move_uploaded_file($userfile_tmp_name, "$archive_dir/$LRCardname")){
    							/*
    								if LRC is successfully uploaded then LRC is stored in database.
    							*/
    							mysql_query("update student_information set LRCard='$LRCardname' where student_id='$student_id'", $link_id); 
    							$flag = "success"; 
    							if(mysql_error()!=null){
    								die(mysql_error());
    							}
    
    						}
    						else{
    							if(file_exists('LRCard/' . $LRCardname)) {
    								unlink('LRCards/' . $LRCardname); 
    							}
    							rollbackData();
    						}
    					}
    					else{
    						if(file_exists('LRCards/' . $LRCardname)) {
    							unlink('LRCard/' . $LRCardname); 
    						}
    						rollbackData();
    						die("You can upload LRCard of 5 MB size only. Please, try again.");
    					}
    				}
    				else{
    					if(file_exists('LRCards/' . $LRCardname)) {
    						unlink('LRCards/' . $LRCardname); 
    					}
    					rollbackData();
    					die("You can upload LRCard of .jpg, .jpeg, .gif extensions only. Please, try again. ");
    				}
    			} 	
    		}
    		else{
    			$flag="error";
    		}
    		if($flag == "success"){
    			mysql_query(" COMMIT ");
    			$flag="success";
    			if(mysql_error() != null){
    				die(mysql_error());
    			}
    	    }
    

    Now i want to display this uploaded image with respect to a specific student with auto incremented unique number. You know Admin Ben that i always doing my best to get those codes but this time i think im lost.

    I want this image to be displayed on another page. Please help me this time with the codes and ill do the rest.

    Please and another please. I always beleive in your expertise in CRUDE.

  10. Hello Ben,

     

     

    hahaha,, i am so dumb!! Why i haven't think of that....thank you for that hint Ben..

     

    I solve it,,and for the benefit of those future reader on this thread. ill post the solution.

    $query = "UPDATE student_information SET learner_id='$learner_id',first_name='$first_name',last_name='$last_name',";    
        $query .= "gender='$gender',date_of_birth='$date_of_birth',contact_no='$contact_no',grade='$grade',section='$section',";
        $query .= "LRN='$LRN',email1='$email1',email2='$email2',address='$address',description='$description'";  	
    	$query .= " WHERE student_id='{$_SESSION['user_id']}'";      
    	$result = mysql_query($query, $link_id);
    	if(mysql_error() != null){
    		die(mysql_error());
    		}
    	else{
    				$flag="success";
    		}
    		
    	header("location:Student_Edit.php?flag=$flag&student_id='{$_SESSION['user_id']}'");	  
    ?>
    

     Thank you Ben.

  11. Hello everyone,

    I am confused with these little codes why it keeps error in updating the learner information. These are my codes so far.

    These are the bits of Student_Info.php which i think would be useful in my query. 

    <?php  if(!empty($_GET['flag']) && $_GET['flag'] == "success") { ?>   
            <span class="stylered style1"><span class="style5">Learner Information updated successfully.</span></span>  
            <?php } else if(!empty($_GET['flag']) && $_GET['flag'] == "error") { ?>
            <span class="stylered style3 style5"><span class="style1">Error while updating Learner Information. Please try again</span></span> 
            <?php }  ?>  </td>
    

    This is the Student_Edit_Handler codes.

    <?php
        session_start();
        $session_id = $_SESSION['user_id'];
        if($session_id == null){
           header("location:Student_Edit.php");
           die();
        }
        include 'Connect.php';
        $flag = "";
        $student_id = $_POST['student_id'];
        $first_name = $_POST['first_name'];
        $last_name = $_POST['last_name'];
        $gender = $_POST['gender'];
        $date_of_birth = date("Y-m-d",strtotime($_POST['date_of_birth']));
        $contact_no = $_POST['contact_no'];
        $grade  = $_POST['grade'];
        $section = $_POST['section'];
        $LRN = $_POST['LRN'];
        $email1 = $_POST['email1'];
        $email2 = $_POST['email2'];
        $address = $_POST['address'];
        $description = $_POST['description'];
        $query = "UPDATE student_information SET learner_id='$learner_id',first_name='$first_name',last_name='$last_name',";    
        $query .= "gender='$gender',date_of_birth='$date_of_birth',contact_no='$contact_no',grade='$grade',section='$section',";
        $query .= "LRN='$LRN',email1='$email1',email2='$email2',address='$address',description='$description'";     
        $query .= " WHERE student_id='{$_SESSION['user_id']}'";      
        $result = mysql_query($query, $link_id);
        if(mysql_error() != null){
            die(mysql_error());
            }
        else{
                $flag="error";
            }
            if($flag == "success"){
                mysql_query(" COMMIT ");
                $flag="success";
                if(mysql_error() != null){
                    die(mysql_error());
                }
            }
        header("location:Student_Edit.php?flag=$flag&student_id='{$_SESSION['user_id']}'"); 
    ?>
    

    It flags the error on else{$flag="error";}

    I am stuck with these codes guys, please do help me modify it so learner information will be update.

  12. Hello there Sir Ben,

     

    Uhh Yes, they have to log in to their user account using their learner_id and student_password. 

    Im sorry for that,

     

    Here is my Student_login.php

    <td width="35%" align="left" class="style7 style1">Learner Id : </td>
               <td width="65%" align="left"><input name="learner_id" type="text" id="learner_id" action="Student_Home.php" method="post"></td>
            </tr>
            <tr bgcolor="#E1E1E1" class="stylesmall">
               <td align="left" class="style7 style1">Password:</td>
               <td align="left"><input name="student_password" type="password" id="student_password"></td>
            </tr>
            <tr bgcolor="#E1E1E1">	
               <td colspan="2" align="center"> 
    		     <?php if(!empty($_GET['flag']) && $_GET['flag'] == "invalid") { ?>
                 <span class="stylered style1">Invalid Learner Id or Password</span>
    			 <?php }?></td>
            </tr>
            <tr bgcolor="#E1E1E1">
               <td colspan="2" align="center">
    		        <p><input name="login" class="style10" type="submit" id="login" value="Login"></p> 

    I have updated my previous comment because from time to time i am also working with these codes with your guidance.

  13. Good day Admins,

     

    I have now variables

     

    $learner_id

    $student_pasword

    $student_id

     

    The learner_id and student_password are being used as their log in accounts. While the student_id is being used as their unique id and it is auto-incremented.

     

    Here are my codes.

     

    Student_login_handler.php

    
    
    <?php
    session_start();
    include 'Connect.php';
    $flag = "";
    $learner_id = $_POST['learner_id'];
    $student_password =  $_POST['student_password'];
    $query = "select last_login_date from student_information where learner_id='$learner_id' and student_password='$student_password'";
    $result = mysql_query($query,$link_id);
    if(mysql_error() != null){
    die(mysql_error());
    }
    if($date = mysql_fetch_array($result))
    {
    $lastdate = $date['last_login_date'];
    $date2 = date("d-m-Y h:i A",strtotime($lastdate));
    $_SESSION["user_id"] = $_POST["student_id"];
    $_SESSION["lastlogin"] =$date2;
    $_SESSION["type"] = "Student";
    mysql_query("UPDATE student_information SET last_login_date=now() where student_id='$GET[id]'",$link_id);
    if(mysql_error() != null){
    die(mysql_error());
    }
    header("location:  Student_Home.php?id={$student_id}"); 
    die();
    }
    else
    {
    $flag = "invalid";
    header("location:Student_login.php?flag=$flag");
    die();
    } 
    ?>
    

     

     
     

    This is so far what i've got and it's wrong. Help me to modify this gentlemen to achieve the objectives given above.

    It directs me to URL

    http://localhost/a/Student_Home.php?id=

     

    which i expect to be 

     

    http://localhost/a/Student_Home.php?id=51             (51 is the auto-incremented student_id, bears unique id of student)

  14. Hello Admin,

     

    This is my upload code

    if($result){
    			if($_FILES['image']['name'] != ""){
    				$filename = $_FILES['image']['name'];
    				$ext = strrchr($filename,".");
    				$imagename = $student_id;
    				if($ext ==".jpg" || $ext ==".jpeg" || $ext ==".JPG" || $ext ==".JPEG" || $ext ==".gif" || $ext ==".GIF"){
    					$size = $_FILES['image']['size'];
    					if($size > 0 && $size < 5000000){
    						$archive_dir = "images";
    						$userfile_tmp_name = $_FILES['image']['tmp_name'];
    						if(move_uploaded_file($userfile_tmp_name, "$archive_dir/$imagename"))

    and the image is successfully uploaded to

     

    xampp/htdocs/a/images

     

     

     

     you should rename the images (according to the profileID) 

    with the student id (not the unique number) is the file name.

     

    The same codes for display_image.php and the student_view.php as shown above.

    But still no luck the image still broken.

     

    Please advise.

  15. I have uploaded the specific image of the student in

     

    xampp/htdocs/a/images

     

    and i want to display it specifically on their profile given their unique id.

     

    I really think there is something missing in my codes maybe the path but i just dont know how to express it.

     

    Please advise

     

    Note: "images" is a folder where all the image of the students are saved.

×
×
  • Create New...