Jump to content

handoyo

Members
  • Posts

    22
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

handoyo's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi all,suppose i got two rows like this picture I'm trying to change the modified column value to current datetime without refreshing the page when i click the update button..The first row worked,the second doesn't work..Here is my codes views/order_home <script type="text/javascript" src="<?php echo base_url(); ?>js/jquery.js"></script> <script type="text/javascript" src="<?php echo base_url(); ?>js/jquery.form.js"></script> <script type="text/javascript"> // wait for the DOM to be loaded $(document).ready(function() { $("#msg").hide(); $('#myform').ajaxForm(function() { var no_id=$('#no_id').val(); $.post("getOrder/", { 'id' : no_id }, function(data){ $('#modif').html(data.modified); }, "json"); //nampilin di div message string yg ada di dalam html() $("#msg").html("Berhasil update order").fadeIn(1500); $("#msg").fadeOut(1500); }); }); </script> <h1><?php echo $title;?></h1> <?php if ($this->session->flashdata('message')){ echo "<div class='message' name='msg' id='msg'>".$this->session->flashdata('message')."</div>"; } echo "<div name='msg' class ='msg' id='msg'></div>"; echo "<table border='1' cellspacing='0' cellpadding='3' width='100%' id='order_home' name='order_home'>\n"; echo "<tr valign='top'>\n"; echo "<th>No Order</th>\n<th>No Cust</th><th>Tgl Pesan</th><th>Modified</th><th>Status</th><th>Update</th><th>id</th><th>Actions</th>\n"; echo "</tr>\n"; if (count($order)){ foreach ($order as $key => $list){ echo "<tr valign='top'>\n"; echo "<td>".anchor("admin/order/detail/".$list['no_order'],$list['no_order'])."</td>\n"; echo "<td>".$list['custid']."</td>\n"; $datetime = strtotime($list['tgl_pesan']); $orderdate = date("d-m-y H:i ", $datetime); echo "<td>".$orderdate."</td>\n"; $modifieddate = strtotime($list['modified']); $modified = date("d-m-y H:i ", $modifieddate); echo "<td id='modif' name='modif'>".$modified."</td>\n"; $attributes = array('id' => 'myform'); echo form_open('admin/order/edit',$attributes); echo "<td align='center'>".form_dropdown('status',$status,$list['status'])."</td>\n"; $btn = array('id'=>'update','name'=>'update','value'=>'Update'); $data = array('name'=>'notif','id'=>'notif'); echo "<td align='center'>".form_checkbox($data)."<label for='update'>Notifikasi cust</label>".form_submit($btn)."</td>\n"; echo '<input type="hidden" id="no_id" name="no_id" value="'.$list['id'].'" />'; echo form_close(); echo "<td align='center'>"; echo anchor("admin/order/edit/".$list['no_order'],img(base_url().'/images/edit.jpg')); echo " | "; echo anchor("admin/order/delete/".$list['no_order'],img(base_url().'/images/delete.jpg')); echo "</td>\n"; echo "</tr>\n"; } } echo "</table>"; ?> controller/order function edit($no=0) { if ($this->input->post('no_id')) { if (isset($_REQUEST['notif'])) { $this->input->post('status_order'); $result=$this->MOrder->updateOrder(); $this->email->from('admin@7com.cphoster.com','Admin'); $this->email->to('yonghan79@gmail.com'); $this->email->subject('Testing email class'); $this->email->message('Status order '.$status); $this->email->send(); //return $result; $this->session->set_flashdata('message','Berhasil update order'); redirect('admin/order/index','refresh'); } else { $this->MOrder->updateOrder(); $this->session->set_flashdata('message','Berhasil update order'); redirect('admin/order/index','refresh'); } } else { //$id = $this->uri->segment(4); $data['title'] = "Edit Order"; $data['main'] = 'admin/order_edit'; $data['order'] = $this->MOrder->getOrder($no); $data['status']=$this->MOrder->getStatus(); if (!count($data['order'])){ redirect('admin/order/index','refresh'); } $this->load->vars($data); $this->load->view('dashboard'); } } //buat ambil data dari db menggunakan jquery n json function getOrder() { $no=trim($this->input->post('id')); $hasil=$this->MOrder->getOrder($no); $datetime = strtotime($hasil['modified']); $orderdate = date("d-m-y H:i ", $datetime); $array=array('modified'=>$orderdate); echo json_encode($array); } Are there anything wrong with my codes?Thanks a lot...
  2. I got i working GKWelding,i got a mistake with echo form_input($harga_diskon) ."</p>"; It should be echo form_input($data) ."</p>";
  3. I did not get the value GK..Usually what cause the js don't work?Thanks GKWelding..
  4. Hi all,i got codes in CI views like this admin/product_home.php <h1><?php echo $title;?></h1> <p><?php echo anchor("admin/produk/create", "Create new product");?> | <?php echo anchor("admin/produk/export","Export");?></p> <?php echo form_open_multipart("admin/products/import"); $data = array('name' => 'csvfile', 'size'=>15); echo form_upload($data); echo form_hidden('csvinit',true); echo form_submit('submit','IMPORT'); echo form_close(); ?> <?php if ($this->session->flashdata('message')){ echo "<div class='message'>".$this->session->flashdata('message')."</div>"; } if (count($products)){ echo form_open("admin/products/batchmode"); echo "<p>Category: ". form_dropdown('category_id',$categories); echo " "; echo "</p>"; echo "<table border='1' cellspacing='0' cellpadding='3' width='500'>\n"; echo "<tr valign='top'>\n"; echo "<th> </th><th>ID</th>\n<th>Nama</th><th>Status</th><th>Actions</th>\n"; echo "</tr>\n"; foreach ($products as $key => $list){ echo "<tr valign='top'>\n"; echo "<td align='center'>".form_checkbox('p_id[]',$list['id'],FALSE)."</td>"; echo "<td>".$list['id']."</td>\n"; echo "<td>".$list['nama']."</td>\n"; echo "<td>".$list['status']."</td>\n"; echo "<td align='center'>".$list['status']."</td>\n"; echo "<td align='center'>"; //echo anchor('admin/products/edit/'.$list['id'],'edit'); echo anchor("admin/produk/edit/".$list['id'],img(base_url().'/images/edit.jpg')); echo " | "; //echo anchor('admin/products/delete/'.$list['id'],'delete'); echo anchor("admin/produk/edit/".$list['id'],img(base_url().'/images/edit.jpg')); echo "</td>\n"; echo "</tr>\n"; } echo "</table>"; echo form_close(); } ?> admin/product_create.php <h1><?php echo $title;?></h1> <?php echo form_open_multipart('admin/produk/create'); echo "<p><label for='parent'>Category</label><br/>"; echo form_dropdown('cat_id',$categories) ."</p>"; echo "<p><label for='name'>Name</label><br/>"; $data = array('name'=>'nama','id'=>'nama','size'=>25); echo form_input($data) ."</p>"; echo "<p><label for='short'>Short Description</label><br/>"; $data = array('name'=>'shortdesc','id'=>'short','size'=>40); echo form_input($data) ."</p>"; echo "<p><label for='long'>Long Description</label><br/>"; $data = array('name'=>'longdesc','id'=>'long','rows'=>5, 'cols'=>'40'); echo form_textarea($data) ."</p>"; echo "<p><label for='uimage'>Upload Image</label><br/>"; $data = array('name'=>'image','id'=>'uimage'); echo form_upload($data) ."</p>"; echo "<p><label for='uthumb'>Upload Thumbnail</label><br/>"; $data = array('name'=>'thumbnail','id'=>'uthumb'); echo form_upload($data) ."</p>"; echo "<p><label for='harga'>Harga</label><br/>"; $data = array('name'=>'harga','id'=>'harga','size'=>10); echo form_input($data) ."</p>"; echo "<p><label for='diskon'>diskon(%)</label><br/>"; $data = array('name'=>'diskon','id'=>'diskon','size'=>10); echo form_input($data) ."</p>"; echo "<p><label for='harga_diskon' >Harga Diskon</label><br/>"; $data = array('name'=>'harga_diskon','id'=>'harga_diskon','size'=>10); echo form_input($harga_diskon) ."</p>"; echo "<p><label for='status'>Status</label><br/>"; $options = array('active' => 'active', 'inactive' => 'inactive'); echo form_dropdown('status',$options) ."</p>"; echo "<p><label for='featured'>Featured</label><br/>"; $options = array('Y' => 'Y', 'N' => 'N'); echo form_dropdown('featured',$options) ."</p>"; echo "<p><label for='new'>New</label><br/>"; $options = array('Y' => 'Y', 'N' => 'N'); echo form_dropdown('baru',$options) ."</p>"; echo "<p><label for='promo'>Promo</label><br/>"; $options = array('Y' => 'Y', 'N' => 'N'); echo form_dropdown('promosi',$options) ."</p>"; echo form_submit('submit','create product'); echo form_close(); ?> and the Produk controller function index() { $data['title'] = "Manage Products"; $data['main'] = 'admin/product_home'; $data['products'] = $this->MProduk->getAllProducts(); $data['categories'] = $this->MCat->getCategoriesDropDown(); $this->load->vars($data); $this->load->view('dashboard'); } function create(){ if ($this->input->post('nama')){ $this->MProduk->addProduct(); $this->session->set_flashdata('message','Product created'); redirect('admin/produk/index','refresh'); }else { $data['title'] = "Create Product"; $data['main'] = 'admin/product_create'; $data['categories'] = $this->MCat->getCategoriesDropDown(); $this->load->vars($data); $this->load->view('dashboard'); } } I'm intending to automatically fill the harga_diskon field with the calculated value from harga-diskon/100. This is js script <script type="text/javascript" src="<?php echo base_url(); ?>js/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#diskon").change(function() { var price = parseInt($("#harga").val()); var discount = parseInt($("#diskon").val()); var discounted_price = harga * (diskon/100); //alert(price + " + " + discount + " = " + discounted_price); $("#harga_diskon").val(discounted_price); return false; }); }); </script> I try to put the js on the view page,it doesn't give me the expected results.Can someone tell me how to properly do it?And where should i put the js scripts?Thanks a lot...
  5. Hi all,i found out a tutorial about ecommerce on phpwebcommerce.com..There are a some codes like this $sql = "SELECT cat_id, cat_parent_id, cat_name FROM tbl_category ORDER BY cat_id"; $result = dbQuery($sql) or die('Cannot get Product. ' . mysql_error()); $categories = array(); while($row = dbFetchArray($result)) { list($id, $parentId, $name) = $row; if ($parentId == 0) { // we create a new array for each top level categories $categories[$id] = array('name' => $name, 'children' => array()); //print_r($categories); } else { // the child categories are put int the parent category's array $categories[$parentId]['children'][] = array('id' => $id, 'name' => $name); //print_r($categories); } } // build combo box options $list = ''; foreach ($categories as $key => $value) { $name = $value['name']; $children = $value['children']; $list .= "<optgroup label=\"$name\">"; foreach ($children as $child) { $list .= "<option value=\"{$child['id']}\""; if ($child['id'] == $catId) { $list.= " selected"; } $list .= ">{$child['name']}</option>\r\n"; } $list .= "</optgroup>"; } return $list; The database like this cat_id cat_parent_id cat_name cat_description cat_image 17 13 Hunter X Hunter Story about hunter and combat 12 0 Cars Expensive and luxurious cars dce08605333d805106217aaab7f93b95.jpg 13 0 Manga It's all about manga, yay.... 2a5d7eb60c1625144b3bd785bf70342c.jpg 14 12 Volvo Swedish luxury car 15 12 Mercedes-Benz Expensive but real good 16 13 Naruto This is the story of Naruto and all his gang 18 0 testing 123 tes When i try to print_r like this $categories[$id] = array('name' => $name, 'children' => array()); print_r($categories); it gives me Array ( [12] => Array ( [name] => Cars [children] => Array ( ) ) ) Array ( [12] => Array ( [name] => Cars [children] => Array ( ) ) [13] => Array ( [name] => Manga [children] => Array ( ) ) ) Array ( [12] => Array ( [name] => Cars [children] => Array ( [0] => Array ( [id] => 14 [name] => Volvo ) [1] => Array ( [id] => 15 [name] => Mercedes-Benz ) ) ) [13] => Array ( [name] => Manga [children] => Array ( [0] => Array ( [id] => 16 [name] => Naruto ) [1] => Array ( [id] => 17 [name] => Hunter X Hunter ) ) ) [18] => Array ( [name] => testing 123 [children] => Array ( ) ) ) and $categories[$parentId]['children'][] = array('id' => $id, 'name' => $name); print_r($categories); it gives me Array ( [12] => Array ( [name] => Cars [children] => Array ( [0] => Array ( [id] => 14 [name] => Volvo ) ) ) [13] => Array ( [name] => Manga [children] => Array ( ) ) ) Array ( [12] => Array ( [name] => Cars [children] => Array ( [0] => Array ( [id] => 14 [name] => Volvo ) [1] => Array ( [id] => 15 [name] => Mercedes-Benz ) ) ) [13] => Array ( [name] => Manga [children] => Array ( ) ) ) Array ( [12] => Array ( [name] => Cars [children] => Array ( [0] => Array ( [id] => 14 [name] => Volvo ) [1] => Array ( [id] => 15 [name] => Mercedes-Benz ) ) ) [13] => Array ( [name] => Manga [children] => Array ( [0] => Array ( [id] => 16 [name] => Naruto ) ) ) ) Array ( [12] => Array ( [name] => Cars [children] => Array ( [0] => Array ( [id] => 14 [name] => Volvo ) [1] => Array ( [id] => 15 [name] => Mercedes-Benz ) ) ) [13] => Array ( [name] => Manga [children] => Array ( [0] => Array ( [id] => 16 [name] => Naruto ) [1] => Array ( [id] => 17 [name] => Hunter X Hunter ) ) ) ) 1.How should i format the output so i can learn the results that was returned? 2.What does $categories[$id] = array('name' => $name, 'children' => array()); and $categories[$parentId]['children'][] = array('id' => $id, 'name' => $name); means? 3.What is the uses of .= ? Thanks a lot...God bless you all..
  6. I mean securing login system using token..
  7. Hi all,i wonder if someone has used token for login system..Does anyone here willing to teach me how to do it? Thanks a lot...
  8. Do you mean the session_destroy() at proses.php?Thanks...
  9. I'm using it to hold the errors..Could you help me please?Thanks a lot...
  10. Hi all...I'm trying to make an error display on the register.php when the user hasn't enter valid data by proccesing it to proses.php..I've made it by using session..But i was unable to destroy the session suppose the user doesn't want to register and they go back to the index.php by using the browser back button...What should i do so the session can be cleared suppose the user came back to the register.php?I've tried the unset() and it's not working...Here are the codes that i've made...Thanks a lot... register.php /error_reporting(0); session_start(); include 'output_fns.php'; $thisPage="Index"; include 'include/navigation.php'; do_kepala('Register'); $prop=$_SESSION["id_prop"]; $tgl_pil=$_SESSION["id_tgl"]; $bln_pil=$_SESSION["id_bln"]; ?> <div id="styled" class="myform"> <form id="form1" name="form1" method="post" action="proses.php"> <fieldset> <legend >Data keanggotaan</legend> <br> <label>Email anda : <span class="small">Untuk login</span> </label> <input type="text" name="email" id="email" value="<?php echo $fields['email']; ?>"> <span class="error"> <?php echo $Error['email']; ?> <?php echo $Error['daftar']; ?> </span> <div class="spacer"></div> <label>Password : <span class="small">6-12 karakter</span> </label> <input type="password" name="pwd1" id="pwd1" ?> <span class="error"> <?php echo $Error['pwd1']; ?> </span> <div class="spacer"></div> <label>Ulangi Password : </label> <input type="password" name="pwd2" id="pwd2" /> <span class="error"> <?php echo $Error['pwd2']; ?> </span> <div class="spacer"></div> </fieldset> <fieldset> <legend>Data pribadi</legend> <br> <h1> * Mohon diisi dengan data yang sebenarnya</h1> <div class="spacer"></div> <br> <label>*Nama lengkap anda : <span class="small">Mohon nama asli anda</span> </label> <input type="text" name="nama" id="nama" value="<?php echo $nama; ?>"/> <span class="error"> <?php echo $Error['nama']; ?> </span> <div class="spacer"></div> <label>*Tempat lahir anda : <span class="small"></span> </label> <input type="text" name="tempat_lahir" id="tempat_lahir" value="<?php echo $tmpt; ?>"/> <div class="spacer"></div> <label for="tgl">*Tanggal lahir <span class="small">dd/mm/yyyy</span> </label> <select name="tgl" id="tgl"> <?php //ambil id dari table propinsi buat ditaruh di option propinsi $usertgl=$tgl_pil; $handle=db_connect(); $ambil="Select * from tgl"; $result=$handle->query($ambil); while($row=$result->fetch_array()) { if ($row['id'] == $usertgl) { echo '<option value="'.$row['id'].'" selected="selected">'.$row['tgl'].'</option>'; } else { echo '<option value="'.$row['id'].'">'.$row['tgl'].'</option>'; } } ?> </select> <label for="bln"></label><select name="bln" id="bln"> <option value="1" selected="selected">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> </select> <label for="thn"></label> <input type="text" name="thn" id="thn" style="float:left; font-size:12px; padding:5px 0px; border:solid 1px #aacfe4; width:55px; margin:2px 0 10px 8px;" value="<?php echo $thn?>"/> <div class="spacer"></div> <label>Jenis Kelamin <span class="small">Jenis kelamin anda</span> </label> <select name="jekel"> <option value="Pilih" selected="selected">Pilih salah satu... </option> <option value="pria" id="jekel">Pria</option> <option value="wanita" id="jekel">Wanita</option> </select> <div class="spacer"></div> <label>*Alamat : <span class="small">Alamat lengkap anda</span> </label> <input type="text" name="alamat" id="alamat" value="<?php echo $alamat; ?>"/> <div class="spacer"></div> <label>*Kota : <span class="small">Kota anda</span> </label> <input type="text" name="kota" id="kota" value="<?php echo $kota; ?>"/> <div class="spacer"></div> <label>*Propinsi : <span class="small">Propinsi anda</span> </label> <select name="propinsi"> <?php //ambil id dari table propinsi buat ditaruh di option propinsi $userprop=$prop; $handle=db_connect(); $ambil="Select * from propinsi"; $result=$handle->query($ambil); while($row=$result->fetch_array()) { if ($row['id'] == $userprop) { echo '<option value="'.$row['id'].'" selected="selected">'.$row['prop'].'</option>'; } else { echo '<option value="'.$row['id'].'">'.$row['prop'].'</option>'; } } ?> </select> </fieldset> <br> <button type="submit" name="submit">Sign-up</button> </form> </div> ?> proses.php session_start(); include 'class/class.all.php'; $Error = array(); $fields = array(); //if(isset($_POST['submit'])) // { //$email=$_POST['email']; $email=$_REQUEST['email']; $fields['email']=$email; if(empty($email)) { $Error['email']='Email tidak boleh kosong'; } else if (!strchr($email, '@')) { $Error['email']='Email yang anda masukkan tidak valid'; } $pwd1=$_REQUEST['pwd1']; if(empty($pwd1)) { $Error['pwd1']='Password 1 tidak boleh kosong'; } $pwd2=$_REQUEST['pwd2']; if(empty($pwd2)) { $Error['pwd2']='Password 2 tidak boleh kosong'; } else if($pwd1 != $pwd2) { $Error['pwd2']='Password harus cocok'; } $nama=$_REQUEST['nama']; if(empty($nama)) { $Error['nama']='Nama tidak boleh kosong'; } $pwd=$pwd1; $tmpt=$_REQUEST['tempat_lahir']; $tgl=$_REQUEST['tgl']; $bln=$_REQUEST['bln']; $thn=$_REQUEST['thn']; $tgl_lahir=$tgl.'-'.$bln.'-'.$thn; $jekel=$_REQUEST['jekel']; $alamat=$_REQUEST['alamat']; $kota=$_REQUEST['kota']; $propinsi=$_REQUEST['propinsi']; //if (!empty($Error)) if (count($Error)>0) { $_SESSION["errors"]=$Error; $_SESSION["fields"]=$fields; $_SESSION["id_prop"]=$propinsi; $_SESSION["id_tgl"]=$tgl; $_SESSION["id_bln"]=$bln; //header('Refresh: 2; url=http://'.$_SERVER['HTTP_HOST'].'/rekandoa/register.php'); //echo 'ada yang salah'; header('location:register.php'); } else { unset($_SESSION["errors"]); unset($_SESSION["fields"]); unset($_SESSION["id_prop"]); unset($_SESSION["id_tgl"]); unset($_SESSION["id_bln"]); session_destroy(); //class class.auth.php $adduser=new auth(); //cek email $cek=$adduser->CekEmail($email); if ($cek) { $Error['daftar']='Email yang anda masukkan sudah terdaftar'; $_SESSION["errors"]=$Error; header('location:register.php'); } else { //panggil fungsi adduser yg ada di class class.auth.php $add=$adduser->adduser($email,$pwd,$nama,$tmpt,$tgl_lahir,$jekel,$alamat,$kota,$propinsi); if ($add==1) { header('location:thanks.php'); } else { } } } // } ?>
  11. Thanks a lot..Then i better use the default one...
  12. Hi all,i want to ask about handling sessions with mysql..Right now i'm using file based session..Suppose i use this code on the auth.php auth.php <?php session_start(); include('db.inc.php'); $email=mysql_real_escape_string($_POST['email']); $pwd=mysql_real_escape_string($_POST['pwd']); $sql="Select member_id,email,password,nama,type from users where email='$email' and password=md5('$pwd')"; $exec=mysql_query($sql); $result=mysql_fetch_array($exec); if ($result['type'] == "member") { $_SESSION['nama']=$result['nama']; $_SESSION['id']=$result['member_id']; header('location:member.php'); } else { echo 'Anda gagal login'; header('location:index.php'); } ?> member.php <?php session_start(); include('output_fns.php'); if(!$_SESSION['nama']) { header('location:index.php'); } else { do_kepala('Member'); echo 'Welcome ' . $_SESSION['nama']; menu_member(); $do = $_GET['do']; //buat milih action switch ( $do ) { case "request": include_once ( "request.php" ); BREAK; case "isi_testi": include_once ( "isi_testi.php" ); BREAK; case "edit_profile": include_once ( "edit_profile.php" ); BREAK; default: include_once ( "member.php" ); BREAK; } } ?> What should i do and how do i handle it with mysql..Please point me how to do it..Thanks a lot...
  13. I'm not intending to let members to create folders..It just that i do it that way cause i intending to separate it from the main pages..Sorry if my words are not clear enough..
  14. Hi all,i want to ask.I've created a folder for the members..On my code,i redirect to localhost/rekan doa/member/index.php if the member suceeded to login..Is it possible to make the address become localhost/rekandoa/index.php?member=a instead of localhost/rekan doa/member/index.php?Please teach me and what should i learn..Thanks a lot...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.