codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?php //include_once "library/seslogin.php"; include_once "library/connection.php"; include_once "library/library.php"; $month =date("m"); $year =date("y"); $woom ="WO-OM"; $gr ="/"; if($month=='1'){ $month='A'; }elseif($month=='2'){ $month='B'; }elseif($month=='3'){ $month='C'; }elseif($month=='4'){ $month='D'; }elseif($month=='5'){ $month='E'; }elseif($month=='6'){ $month='F'; }elseif($month=='7'){ $month='G'; }elseif($month=='8'){ $month='H'; }elseif($month=='9'){ $month='I'; }elseif($month=='10'){ $month='J'; }elseif($month=='11'){ $month='K'; }else{ $month='L'; } mysql_connect("localhost","root",""); mysql_select_db("coba"); $qry ="SELECT MAX(id) AS MaxId FROM id_unik"; $hasil =mysql_query($qry); $data =mysql_fetch_array($hasil); $id =$data['MaxId']; $noId =(int)substr($id,0,2); $noId++; $new_id =sprintf("%03s",$noId); //$noId++; //$sqlmax ="SELEC MAX(id) AS maxcode FROM id_unik"; //$qrymax =mysql_query($koneksidb,$sqlmax); //$data =mysql_fetch_array($qrymax); //$wocode =$data['maxcode']; //$nowo =(int) substr($wocode,0,4); //$nowo =$nowo++; //$wo =sprintf("%03s",$nowo); //$sqlM ="SELECT * FROM id_unik"; //$qryM =mysql_query($sqlM,$koneksidb); //$dataM =mysql_fetch_array($qryM); //$maxidM =$dataM['id']; //$idM =(int)substr($maxidM,2,-12); //$id =$idM; //$sqlc ="SELECT COUNT(*) AS maxid FROM id_unik"; //$qryc =mysql_query($sqlc,$koneksidb) or die ("Error : ".mysql_error()); //$data =mysql_fetch_array($qryc); //$maxid =$data['maxid']; //$maxid =sprintf("%03s",$maxid); //$strmaxid =(int)substr($maxid,3,-11); //$newid =$maxid.$gr.$woom.$gr.$month.$gr.$year; //$sqlsync ="SELECT COUNT(*) AS idsync FROM id_unik WHERE id='$newid'"; //$qrysync =mysql_query($sqlsys,$koneksidb); //$datasync =mysql_fetch_array($qrysync); $newid =$new_id.$gr.$woom.$gr.$month.$gr.$year; if(isset($_POST['submit'])){ $code =$_POST['code']; $name =$_POST['name']; $pesanerror =array(); if(trim($code)==""){ $pesanerror[]="Please Insert Code Number"; } if(trim($name)==""){ $pesanerror[]="Please Insert Name"; } if (count($pesanerror)>=1){ echo"<div class='mssgBox'>"; echo"<img src='image/attention.png'><br>"; $nopesan=0; foreach($pesanerror as $indeks=>$pesan_tampil){ $nopesan++; echo"$nopesan. $pesan_tampil<br>"; } echo"</div><br>"; }else{ $mysql ="INSERT INTO id_unik (id,name) VALUES('$newid','$name')"; $myqry =mysql_query($mysql,$koneksidb)or die("Error : ".mysql_error()); if($myqry){ $qry ="SELECT MAX(id) AS MaxId FROM id_unik"; $hasil =mysql_query($qry); $data =mysql_fetch_array($hasil); $id =$data['MaxId']; $noId =(int)substr($id,0,2); $noId++; $new_id =sprintf("%03s",$noId); header('location:index.php'); }exit; } } $dataid = isset($_POST['code']) ? $_POST['code'] : ''; $dataname = isset($_POST['name']) ? $_POST['name'] : ''; ?> <link href="styles/style.css" rel="stylesheet" type="text/css"> <link href="styles/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="plugins/tigra_calendar/tcal.css" rel="stylesheet" type="text/css" /> <div style="padding: 0 15px"> <div class="table-responsive"> <table class="table-bordered"> <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" name="form1" target="_self" class="form-horizontal"> <tr> <td>Name</td> <td>:</td> <td><input type="text" name="name" id="name" placeholder="Input Your Name Here" value="<?php echo $dataname; ?>"></td> </tr> <tr> <td>Code</td> <td>:</td> <td><input type="text" name="code" id="code" value="<?php echo $newid; ?>"></td> </tr> <tr> <td colspan="3" align="center"><input type="submit" name="submit" value="Save"></td> </tr> </form> </table> </div> </div>
Private
[
?
]
Run code
Submit