<?php include "header.php"; 



if($login_type=='admin'){

$submit=$_POST['submit'];
if($submit=='Add Record'){



$username=$_POST['username'];



$password=$_POST['password'];

$type=$_POST['type'];

$mno=$_POST['mno'];
$email=$_POST['email'];


   define ("FILEREPOSITORY","upload/");



   if (is_uploaded_file($_FILES['uploaded_file']['tmp_name'])) {



      if ($_FILES['uploaded_file']['type'] == "") {

         echo "<h2>must be uploaded.</h2>";

      } else {

         $rd2 = mt_rand(1000,9999);
$path = $_FILES['uploaded_file']['name'];
$ext = pathinfo($path, PATHINFO_EXTENSION);
		 

         $result = move_uploaded_file($_FILES['uploaded_file']['tmp_name'], FILEREPOSITORY."/".$rd2."$fname.$ext");

         if ($result == 1) {echo "<p>File successfully uploaded.</p>";

		 $nupload=$rd2."$fname.$ext";

		 $query = "INSERT INTO `user` (`id`, `username`, `password`, `type`,`code`,`img`,`mno`,`email`) VALUES ('$id', '$username', '$password', '$type','$code','$nupload','$mno','$email')";



  mysql_query( $query )



 or die ( "Couldn't add data to \"application\" table: " 



 .mysql_error() );



print "<div>Data Save [ ". mysql_affected_rows() .



" row(s) ] Successfully </div>";


				?><script type="text/javascript">

   	// Javascript URL redirection

    window.location.replace("user_manage.php");

</script>

                <?php

		 }else{echo "<p>There was a problem uploading the file.1</p>";}

      } #endIF

   } #endIF

  





}











if($submit=='Update'){



$id=$_POST['id'];



$username=$_POST['username'];



$password=$_POST['password'];

$type=$_POST['type'];
$mno=$_POST['mno'];
$email=$_POST['email'];



   define ("FILEREPOSITORY","upload/");



   if (is_uploaded_file($_FILES['uploaded_file']['tmp_name'])) {



      if ($_FILES['uploaded_file']['type'] == "") {

         echo "<h2>must be uploaded.</h2>";

      } else {

         $rd2 = mt_rand(1000,9999);
$path = $_FILES['uploaded_file']['name'];
$ext = pathinfo($path, PATHINFO_EXTENSION);
		 

         $result = move_uploaded_file($_FILES['uploaded_file']['tmp_name'], FILEREPOSITORY."/".$rd2."$fname.$ext");

         if ($result == 1) {echo "<p>File successfully uploaded.</p>";

		 $nupload=$rd2."$fname.$ext";

$query = "UPDATE user SET username='$username',password='$password',type='$type',img='$nupload',mno='$mno',email='$email' WHERE id='$id' and code='$code'";



 $result = mysql_query( $query );



 if ( ! $result )



die ("Couldn't update: ".mysql_error());



print "<h1>Table Updated ". mysql_affected_rows() .



" row(s) updated</h1>";


  mysql_query( $query )

				?><script type="text/javascript">

   	// Javascript URL redirection

    window.location.replace("user_manage.php");

</script>

                <?php

		 }else{echo "<p>There was a problem uploading the file.1</p>";}

      } #endIF

   } #endIF

}















//$submit=$_GET['submit'];

//

//if($submit=='Delete'){

//

//$id=$_GET['id'];

//

//$query = "DELETE FROM user WHERE id=$id";

//

//$result = mysql_query( $query );

//

//if ( ! $result )

//

//die ("Couldn't deleted: ".mysql_error());

//

//print "<h1>Table deleted ". mysql_affected_rows() .

//

//" row(s) deleted</h1><p>";

//

//}



?>



     <div id="page-wrapper">







            <div class="row">



                <!-- Page Header -->



                <div class="col-lg-12">





    



    



<?php /*?><script language='JavaScript'>







function validate()



{



	conf = confirm("Are you sure you want to delete?");



	if (conf)



		return true



	else



		return false;



}







</script><?php */?>



<div class="card card-danger">
              <div class="card-header">
                <h3 class="card-title">Create User</h3>
              </div>

      <form id="myform" method="post" action="user_manage.php" name="upload" enctype="multipart/form-data">



	  <table cellpadding=2 cellspacing=0 border=1  align=center class="table table-bordered table-striped">



				






		


		<tr>



		  <td class=color3> Counter User Name</td>



		  <td class=color2><input  name="username" type="text" id="post" class="form-control" tabindex="1" required="required" /></td>
		  </tr>



        



        <tr>



          <td class=color3>Password</td>



          <td class=color2><input  name="password" type="text" id="post" class="form-control" tabindex="2" required="required" /></td>
        </tr>



        <tr>
          <td class=color3>Image</td>
          <td class=color2><input name="uploaded_file" type="file" class="form-control" required/>
<input type="hidden" name="MAX_FILE_SIZE" value="1000000000" /></td>
        </tr>
        <tr>
          <td class=color3>Mobile</td>
          <td class=color2><input  name="mno" type="mobile" class="form-control" id="mno" tabindex="3" required="required" /></td>
        </tr>
        <tr>
          <td class=color3>Email</td>
          <td class=color2><input class="form-control" name="email" type="text" id="email" tabindex="4" required="required" /></td>
        </tr>
        <tr>

          <td class=color3>User Type</td>

          <td class=color2><select name="type" required id='type' class="form-control" tabindex="5">

   <option value="">Select</option>

    <option value="admin">Administrative</option>

    <option value="counter">College Counter</option>

    <option value="teacher">Teachers - Login</option></select></td>
        </tr>

        <tr> 



			<td class=color3></td>



			<td class=color2><input name="submit" type="submit" value="Add Record" tabindex="6"/></td>
		</tr>
	</table>



</form></div></td>



  </tr>



</table><div class="card card-danger">
              <div class="card-header">
                <h3 class="card-title">User Account</h3>
              </div>

 <?php
$query = "SELECT * FROM user where code='$code'";
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);
$result = mysql_query($query) or die("Couldn't execute query");
?>



<div style="overflow:auto; text-align:center">







<?php if($numrows!=""){?>



   <table  cellpadding="1" border="1" cellspacing="1" bgcolor="#FFFFFF" align="center" class="table table-bordered table-striped">



 <tr>



	



 <td align="center" valign="top" class="border"><div align="center" style="font-size:12px; "  ><em><strong>S.</strong></em></div></td>



  <td align="center" valign="top" class="style1" style="font-size:12px; ">Counter User Name</td>



 



  <td align="center" valign="top" class="style1" style="font-size:12px; ">Password</td>



  <td align="center" valign="top" class="border">Photo</td>
  <td align="center" valign="top" class="border">Mobile Number</td>
  <td align="center" valign="top" class="border">Email</td>
  <td align="center" valign="top" class="border">Type</td>

  <td align="center" valign="top" class="border"><div align="center" style="font-size:12px; "   ><em><strong>Update</strong></em></div></td>



 <td align="center" valign="top" class="border"><div align="center" style="font-size:12px; "   ><em><strong>Delete</strong></em></div></td>
 </tr>



<?php 



$counter = 1;?>



 <?php



while ( $a_row = mysql_fetch_row( $result ) )



 {?>



 



 



<form action="user_manage.php"  method="post" name="upload" enctype="multipart/form-data">



<input  name="id" type="hidden" value="<?php echo $a_row[0];?>" />



 <tr>



 <td height="20" align="center" valign="top" ><div align="center" style="font-size:12px;"><?php echo $counter;?></div></td>



 <td align="center" valign="top" ><input name="username" type="text" class="form-control" id="post"  value="<?php echo $a_row[1];?>" size="45" readonly="readonly" /></td>



 



 <td align="center" valign="top" ><input class="form-control" name="password" type="text" id="post2"  value="<?php echo $a_row[2];?>" /></td>



 <td align="center" valign="top" >
 <?php if($a_row[5]!=""){ ?>
 <img src="http://rnsc.mdsoftware.co.in/old/admin/upload/<?php echo $a_row[5];?>" height="100" width="100"/>
 <?php } ?>
 <input name="uploaded_file" type="file" class="form-control" required/>
<input type="hidden" name="MAX_FILE_SIZE" value="1000000000" /></td>
 <td align="center" valign="top" ><span class="color2">
   <input class="form-control" name="mno" type="mobile"  required="required" value="<?php echo $a_row[6];?>" />
 </span></td>
 <td align="center" valign="top" ><span class="color2">
   <input class="form-control" name="email" type="email"  required="required" value="<?php echo $a_row[7];?>" />
 </span></td>
 <td align="center" valign="top" ><select name="type" class="form-control" required id='type'>

   <option value="<?php echo $a_row[3];?>"><?php echo $a_row[3];?></option>

    <option value="admin">Administrative</option>

    <option value="counter">College Counter</option>

    <option value="teacher">Teachers - Login</option></select></td>

 <td align="center" valign="top" >







 <input type="submit"  name="submit" value="Update"  ></td>



 <td align="center" valign="top" >







 



<?php /*?><a href="feed_coll_info.php?id=<?php echo $a_row[0];?>&&submit=Delete" onclick='return validate();'><img src="images/out.gif" height="25" width="25" /></a><?php */?></td>
 </tr>
 </form>







   



  <?php $counter++;}?>
  </table>



</div>



   <?php }?>







<?php if($numrows==""){



  echo "<div  style='border:none; text-align:center'><h3 class='logo2'>No Record Found</h3></div>";



}?>


<?php 



}







include "footer.php"; ?>