Kamis, 22 Agustus 2019

Import XLS


    <html>
    <head>
    <title>How To Import Excel (.xls) File To MySql Database Using PHP</title>
    </head>
    <body>
    <center><h1>TES UPLOAD</h1></center>
    <form name="import_export_form" method="post" action="" enctype="multipart/form-data">
    <label>Select Excel File : </label><input type="file" name="excelfile"/><br>
    <input type="submit" name="form_submit"/>
    </form>
    </body>
    </html>


<?php
 if(isset($_POST['form_submit'])){
require_once 'Excel/reader.php';
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('CP1251');
$filename = $_FILES['excelfile']['tmp_name'];
$nf = $_FILES['excelfile']['name'];

$data->read($filename);
$n=0;

for($x =2; $x <=count ($data->sheets[0]["cells"]); $x++){
$v1 = $data->sheets[0]["cells"][$x][2];
$v2= $data->sheets[0]["cells"][$x][3];
$v3= $data->sheets[0]["cells"][$x][4];
$v4= $data->sheets[0]["cells"][$x][5];
$v5= $data->sheets[0]["cells"][$x][6];
$v6= $data->sheets[0]["cells"][$x][7];

$n++;
echo $sql=" INSERT INTO `tb_data` (
``v1` ,`v2` ,`v3` ,`v4` ,`v5` ,`v6`) VALUES
('$v1', '$v2', '$v3', '$v4', '$v5', '$v6')";


}//for
}//isset




Download

Download File

<?php
$direktori = "ypathfile/";
$namafile=$_GET["file"];
if (!file_exists($direktori.$namafile)) {
  echo "<h1>Access forbidden!</h1>
        <p>Maaf, file $namafile yang Anda download sudah tidak tersedia atau filenya (direktorinya) telah diproteksi. <br />
        Silahkan hubungi <a href='mailto:adiarray@gmail.com'>Administrator Web</a>.</p>";
  exit();
}
else {
  header("Content-Type: octet/stream");
  header("Content-Disposition: attachment; filename=\"".$namafile."\"");
  $fp = fopen($direktori.$namafile, "r");
  $data = fread($fp, filesize($direktori.$namafile));
  fclose($fp);
  print $data;
}
?>




PHP Tiny

Download
<html>
<head>
<title>Dengan Editor TinyMCE</title>
<script type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
   tinyMCE.init({
mode : "textareas",
theme : "advanced",
   });
</script>
</head>
<body>

<form method="post" action="">
  Isi Berita:<br />
  <textarea name="isi" cols="30" rows="10"></textarea>
  <input type="submit" value="Simpan" />
</form>
</body>
</html>



PHP COde Pilihan Biasa

<div class="top_right">
<div class="languages">
<div class="lang_text"><b><font color='red'>PILIHAN BAHASA</font></b><ul></div>
        <a href="http://209.85.135.104/translate_c?hl=id&langpair=id%7Cen&u=<?php echo $web;?>/" class="lang">
        <img src="ypathicon/en.gif" alt="" border="0" /></a>
       
        <a href="http://209.85.135.104/translate_c?hl=id&langpair=id%7Cen&u=<?php echo $web;?>/" class="lang">
        <img src="ypathicon/de.gif" alt="" border="0" /></a>
       
        <a href="#" class="lang">
        <img src="ypathicon/id.jpeg" alt="" border="0" /></a>
</div>
</div>
<hr>




Ajax Combobox

<html>
<head>

<script type="text/javascript">
var xmlHttp

function showUser(str){
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null){
 alert ("Browser tidak support HTTP Request")
 return
 }
var url="getuser.php"
url=url+"?q="+str
url=url+"&sid="+Math.random()
xmlHttp.onreadystatechange=SC1
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function SC1() {
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
 document.getElementById("txtHint").innerHTML=xmlHttp.responseText
 }
}

function GetXmlHttpObject(){
var xmlHttp=null;
try{xmlHttp=new XMLHttpRequest();}
catch (e){
try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
  catch (e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
 }
return xmlHttp;
}
</script>

</head>
<body>
<form>
Pilih User:
<select name="users" onChange="showUser(this.value)">
<option value="1">Nama ID 1</option>
<option value="2">Nama ID 2</option>
<option value="3">Nama ID 3</option>
    <option value="4">Nama ID 4</option>
</select>
</form>
<p>
<div id="txtHint"><b>Informasi user akan tampil di sini...</b></div>
</p>
</body>
</html>



+++++++++++++++
<?php
session_start();
$jmldata=10;
?>
<html>
<head>
<script type="text/javascript">
function Ajax(){
var $http,$self = arguments.callee;

if (window.XMLHttpRequest) {$http = new XMLHttpRequest();} 
else if (window.ActiveXObject) {
try {$http = new ActiveXObject('Msxml2.XMLHTTP');} 
catch(e) {$http = new ActiveXObject('Microsoft.XMLHTTP');}
}

if ($http) {
$http.onreadystatechange = function(){
if (/4|^complete$/.test($http.readyState)) {
document.getElementById('ReloadThis').innerHTML = $http.responseText;
setTimeout(function(){$self();}, 1000);
}
};
$http.open('GET', 'songinfo.php' + '?' + new Date().getTime(), true);
$http.send(null);
}
}
</script>
<script type="text/javascript">setTimeout(function() {Ajax();}, 1000);</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body></body>
</html>
<hr />HTTP://www.LP2M-ARAY: <div id="ReloadThis">Default text</div>


PHP Code Captcha

Download

<?php
session_start();

?>
<form action="" method="post">
<table width="407"  style='border: 1pt dashed #0000CC;padding: 10px;'>

<tr>
  <td>Input Kode
  <td>
  <td><img src="setcaptcha.php"></td>
</tr>
<tr>
  <td>
  <td>
  <td>
  <input type="text" name="kodecaptcha" size="6" maxlength="6">
   (Masukkan 6 kode diatas)
  </td>
</tr>

<tr>
<td>
<td>
<td><input name="Simpan" type="submit" id="Simpan" value="Simpan" />
</td></tr>
</table>
</form>


<?php
if(isset($_POST["Simpan"])){


if($_POST["kodecaptcha"]==$_SESSION["captcha_session"]){

echo"<h1>Sukses Simpan....</h1>";
}
else{
echo"<h1>Gagal Simpan....</h1>";

}
}
?>

+++++++++++++++++++

<?php
session_start();
header("Content-type: image/png");
$captcha_image = imagecreatefrompng("captcha.png");
$captcha_font = imageloadfont("font.gdf");
$captcha_text = substr(md5(uniqid('')),-6,6);

$_SESSION['captcha_session'] = $captcha_text;

$captcha_color = imagecolorallocate($captcha_image,0,0,0);
imagestring($captcha_image,$captcha_font,15,5,$captcha_text,$captcha_color);
imagepng($captcha_image);
imagedestroy($captcha_image);
?>

PHP TO PDF FILE



<?php
session_start();
ob_start();

?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Laporan Data Nilai</title>
</head>
<body>
<?php
echo "<h1>Nilai Siswa LP2MARAY</h1>";
echo '<table border="0">
  <tr>
    <td width="100">NAMA</td>
    <td width="10">:</td>
    <td width="250">Riadi Marta Dinata</td>
  </tr>
  <tr>
    <td>TGL LAHIR</td>
    <td>:</td>
    <td>20 Agustus 1987</td>
  </tr>
  <tr>
    <td>ALAMAT</td>
    <td>:</td>
    <td>Kampung Sawah RT01/01 Jakarta Selatan</td>
  </tr>
   <tr>
    <td>TELEPON</td>
    <td>:</td>
    <td>082111476069</td>
  </tr>
  <tr>
    <td>ANGKATAN</td>
    <td>:</td>
    <td>B I M A</td>
  </tr>
</table>';

echo "<p>data yang tertera di atas adalah Siswa Terbaik di LP2M ARAY.</p>";
echo "<p align='right'>JAKARTA, ".date('d-m-Y')."
<img src='ttd.jpg' width='120'>
( Riadi Marta Dinata )</p>";
?>
</body>
</html>





<?php
$filename="namafile-".date("YmdHis").".pdf";


$content = ob_get_clean();
$content = '<page style="font-family: freeserif">'.nl2br($content).'</page>';
 require_once(dirname(__FILE__).'/html2pdf/html2pdf.class.php');
 try
 {
  $html2pdf = new HTML2PDF('P','A4','en', false, 'ISO-8859-15',array(30, 0, 20, 0));
  $html2pdf->setDefaultFont('Arial');
  $html2pdf->writeHTML($content, isset($_GET['vuehtml']));
  $html2pdf->Output($filename);
 }
 catch(HTML2PDF_exception $e) { echo $e; }
?>


DOWNLOAD


Sweet Alert

Download library weetalert.min.js, letakkan dalam satu folder sejajar index !  https://drive.google.com/drive/folders/1uXhLjQv998HlVhtzObOPC...