Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Ad icon
ZTE MF283U 4G Unlocked Router (Used)
ayanthamaxi
Updated:
Sunday at 8:26 PM
ලංකාවේ හොඳම උපකාරක පන්ති සහ ගුරුවරුන් එකම තැනකින් - TopTuition.lk
dulithapathum
Updated:
Saturday at 8:07 AM
Colombo
RidhMathraa ’26 🎶✨
Tmadhusanka
Updated:
Jul 15, 2026
Ad icon
Colombo
PXN V10 Pro Direct Drive Racing Wheel (Under Warranty)
Abdur Rahman
Updated:
Jul 15, 2026
Ad icon
USDT ණය සේවාව - USDT Loan Service
පුරවැසියා
Updated:
Jul 15, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
PHP Help [Experts pls]
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="lkzombie" data-source="post: 20496502" data-attributes="member: 462352"><p>මේ තියෙන්නෙ මම ලියපු class එකක්</p><p>[PHP]</p><p><?php</p><p>include_once get_include_path().'cls/database/cls_dbconnection.php';</p><p>include_once get_include_path().'cls/misc/cls_images.php';</p><p>include_once get_include_path().'cls/misc/cls_session.php';</p><p>include_once get_include_path().'cls/business/cls_users.php';</p><p></p><p>class _ads</p><p>{</p><p> public $_adid = "";</p><p> public $_userid = "";</p><p> public $_subcatid = "";</p><p> public $_typeid = "";</p><p> public $_title = "";</p><p> public $_description = "";</p><p> public $_price = "";</p><p> public $_city = "";</p><p> public $_pictures = null;</p><p></p><p> </p><p> public $_message = "";</p><p> </p><p> </p><p> public function _open()</p><p> {</p><p> try</p><p> {</p><p> $classDB = new database();</p><p> $dbcon = $classDB->_getDBconnection();</p><p> $resultset = null;</p><p> </p><p> if($dbcon)</p><p> {</p><p> $resultset = $dbcon->prepare("SELECT * FROM tbl_ads WHERE _adid=:_adid AND _status=1;");</p><p> $resultset->execute(array(':_adid'=>$this->_adid));</p><p> </p><p> $rows = $resultset->fetch(PDO::FETCH_ASSOC);</p><p> </p><p> $this->_adid = $rows['_adid'];</p><p> $this->_userid = $rows['_userid']; </p><p> $this->_subcatid = $rows['_subcatid'];</p><p> $this->_typeid = $rows['_typeid'];</p><p> $this->_title = $rows['_title'];</p><p> $this->_description = $rows['_description'];</p><p> $this->_price = $rows['_price'];</p><p> $this->_city = $rows['_city'];</p><p> </p><p> $resultset = null;</p><p> $resultset = $dbcon->prepare("SELECT * FROM tbl_ads_images WHERE _adid=:_adid;");</p><p> $resultset->execute(array(':_adid'=>$this->_adid));</p><p> </p><p> if(!$resultset->rowCount()==0)</p><p> {</p><p> $this->_pictures = $resultset;</p><p> }</p><p> </p><p> </p><p> </p><p> $dbcon = null;</p><p> $classDB->close_db();</p><p> return(true);</p><p> }</p><p> }</p><p> catch(exception $e)</p><p> {</p><p> $this->_message="Unexpected error:_open";</p><p> return (false);</p><p> }</p><p> }</p><p> </p><p> public function _save($userinfo="")</p><p> {</p><p> try</p><p> {</p><p> $classDB = new database();</p><p> $classImage = new _images();</p><p> $dbcon = $classDB->_getDBconnection();</p><p> $resultset = null;</p><p> </p><p> if($dbcon)</p><p> {</p><p> $dbcon->beginTransaction();</p><p> </p><p> //Check user</p><p> $resultset = $dbcon->prepare("SELECT * FROM tbl_users WHERE _userid=:_userid AND _status=1;");</p><p> $resultset->execute(array(':_userid'=>$this->_userid));</p><p> </p><p> if($resultset->rowCount()!==1)</p><p> {</p><p> $this->_message="Invalid user!!"; </p><p> $dbcon->rollBack();</p><p> return (false);</p><p> } </p><p> </p><p> //Generate new id</p><p> $resultset = $dbcon->prepare("SELECT _adid FROM tbl_parameters;");</p><p> $resultset->execute();</p><p> </p><p> $rows = $resultset->fetch(PDO::FETCH_ASSOC);</p><p> $this->_adid = $rows['_adid']+1;</p><p> </p><p> $resultset=null;</p><p> </p><p> //Update new id</p><p> $resultset = $dbcon->prepare("UPDATE tbl_parameters SET _adid=:_adid;");</p><p> $resultset->execute(array(':_adid'=>$this->_adid));</p><p> </p><p> if($resultset->rowCount()!==1)</p><p> {</p><p> $this->_message="System error: Parameter cannot be updated."; </p><p> $dbcon->rollBack();</p><p> return (false);</p><p> exit;</p><p> } </p><p> </p><p> $resultset=null;</p><p> </p><p> $resultset = $dbcon->prepare("INSERT INTO tbl_ads (_adid, _userid, _subcatid, _typeid, _title, _description, _price, _city, _status) VALUES (?,?,?,?,?,?,?,?,1);");</p><p> </p><p> $resultset->bindParam(1, $this->_adid); </p><p> $resultset->bindParam(2, $this->_userid);</p><p> $resultset->bindParam(3, $this->_subcatid); </p><p> $resultset->bindParam(4, $this->_typeid); </p><p> $resultset->bindParam(5, $this->_title); </p><p> $resultset->bindParam(6, $this->_description); </p><p> $resultset->bindParam(7, $this->_price); </p><p> $resultset->bindParam(8, $this->_city); </p><p> </p><p> $resultset->execute();</p><p> </p><p> </p><p> if($resultset->rowCount()==1)</p><p> {</p><p> $resultset = null;</p><p> $uploadingpath = get_include_path().'images';</p><p> $allowedFileTypes = array("image/jpg","image/jpeg","image/bmp","image/gif","image/png");</p><p> </p><p> for($i=0; $i<count($this->_pictures['name']); $i++) </p><p> {</p><p> echo($i);</p><p> </p><p> $tmpFilePath = $this->_pictures['tmp_name'][$i];</p><p> if($tmpFilePath != "")</p><p> {</p><p> $fileType = $this->_pictures['type'][$i];</p><p> $ext = end((explode(".", $this->_pictures['name'][$i])));</p><p> $filename = $_SESSION['_user']['id'].'-'.time().'-'.$i.'.'.$ext;</p><p> </p><p> </p><p> $shortname = $this->_pictures['name'][$i];</p><p> $filePath = "$uploadingpath/uploaded/$filename";</p><p> </p><p> </p><p> if(!in_array($fileType,$allowedFileTypes))</p><p> {</p><p> $this->_message = 'Image type not allowed! Please upload JPG, JPEG, BMP, GIF or PNG images';</p><p> $dbcon->rollBack();</p><p> return(false);</p><p> exit;</p><p> }</p><p> </p><p> if ($this->_pictures['error'][$i] > 0)</p><p> {</p><p> $this->_message = 'Invalid Image! Unreadable or Damaged picture';</p><p> $dbcon->rollBack();</p><p> return(false);</p><p> exit;</p><p> }</p><p> </p><p> </p><p> if(!move_uploaded_file($tmpFilePath, $filePath)) </p><p> {</p><p> $this->_message = 'Internal Error! Please contact webmaster';</p><p> $dbcon->rollBack();</p><p> return(false);</p><p> }</p><p> </p><p> //100px resized images</p><p> $classImage->_load("$uploadingpath/uploaded/$filename");</p><p> $classImage->_resizeToWidth(100);</p><p> $classImage->_save("$uploadingpath/processed/100/$filename");</p><p> </p><p> //400px resized images</p><p> $classImage->_load("$uploadingpath/uploaded/$filename");</p><p> $classImage->_resizeToWidth(400);</p><p> $classImage->_save("$uploadingpath/processed/400/$filename");</p><p> </p><p> //800px resized images</p><p> $classImage->_load("$uploadingpath/uploaded/$filename");</p><p> $classImage->_resizeToWidth(800);</p><p> $classImage->_save("$uploadingpath/processed/800/$filename");</p><p> </p><p> </p><p> $resultset = $dbcon->prepare("INSERT INTO tbl_ads_images (_adid, _imagepath, _order) VALUES (_adid=:_adid,_imagepath=:_imagepath,_order=:_order);");</p><p> $resultset->execute(array(</p><p> ':_adid' => $this->_adid,</p><p> ':_imagepath' => $filename,</p><p> ':_order' => $i</p><p> ));</p><p> </p><p> </p><p> }</p><p> }</p><p> }</p><p> </p><p> $dbcon->commit();</p><p> Return (True);</p><p> exit;</p><p> }</p><p> else</p><p> {</p><p> $this->_message="No active database connection ";</p><p> return (false);</p><p> exit;</p><p> }</p><p> }</p><p> catch(exception $e)</p><p> {</p><p> $this->_message="Unexpected error:_open ".$e;</p><p> //$dbcon->rollBack();</p><p> return (false);</p><p> exit;</p><p> }</p><p> </p><p> </p><p> }</p><p> </p><p> public function _update()</p><p> {</p><p> </p><p> }</p><p> </p><p> public function _delete()</p><p> {</p><p> </p><p> }</p><p> </p><p> </p><p> </p><p> </p><p> </p><p> </p><p>}</p><p>?></p><p>[/PHP]</p><p></p><p>මේ ෆෝම් එක</p><p>[PHP]</p><p><form class="form-horizontal" enctype="multipart/form-data" method="post"></p><p> <fieldset></p><p> </p><p> <div class="form-group"></p><p> <label class="col-md-3 control-label">Category <sup>*</sup></label></p><p> <div class="col-md-8"></p><p> <select title="Select Category" name="_subcatid" id="category-group" class="selectpicker" required=""><!--#category-optionlist#--></select></p><p> </div></p><p> </div></p><p> </p><p> <div class="form-group"></p><p> <label class="col-md-3 control-label">Add Type</label></p><p> <div class="col-md-8"></p><p> <label class="radio-inline" for="radios-0"><input name="_typeid" id="radios-0" value="0" checked="checked" type="radio">Private </label></p><p> <label class="radio-inline" for="radios-1"><input name="_typeid" id="radios-1" value="1" type="radio">Business </label></p><p> </div></p><p> </div></p><p> </p><p> <div class="form-group"></p><p> <label class="col-md-3 control-label" for="Adtitle">Ad title <sup>*</sup></label></p><p> <div class="col-md-8"></p><p> <input id="Adtitle" name="_title" placeholder="Ad title" class="form-control input-md" required="" type="text"></p><p> <span class="help-block">A great title needs at least 60 characters. </span></p><p> </div></p><p> </div></p><p> </p><p> <div class="form-group"></p><p> <label class="col-md-3 control-label" for="textarea">Describe ad <sup>*</sup></label></p><p> <div class="col-md-8"></p><p> <textarea class="form-control" id="textarea" name="_description" placeholder="Describe what makes your ad unique" required=""></textarea></p><p> </div></p><p> </div></p><p> </p><p> <div class="form-group"></p><p> <label class="col-md-3 control-label" for="Price">Price <sup>*</sup></label></p><p> <div class="col-md-4"></p><p> <div class="input-group"><span class="input-group-addon">Rs.</span></p><p> <input id="Price" name="_price" class="form-control" placeholder="Price" required="" type="text"></p><p> </div></p><p> </div></p><p> <div class="col-md-4"></p><p> <div class="checkbox"></p><p> <label><input type="checkbox">Negotiable </label></p><p> </div></p><p> </div></p><p> </div></p><p> </p><p> <div class="form-group"></p><p> <label class="col-md-3 control-label" for="seller-Location">Location <sup>*</sup></label></p><p> <div class="col-md-8"></p><p> <input id="autocomplete-ajax" name="_city" class="form-control" required=""></p><p> </p><p> </div></p><p> </div></p><p> </p><p> <div class="form-group"></p><p> <label class="col-md-3 control-label" for="textarea"> Pictures</label></p><p> <div class="col-md-8"></p><p> <div class="mb10"></p><p> <input id="_pictures" name="_pictures[]" type="file" class="file" accept="image/*" multiple=""></p><p> </div></p><p> <p class="help-block">Add up to 5 photos. Maximum 2Mb</p></p><p> </div></p><p> </div></p><p> <!--#sellerinformations#--></p><p> <div class="form-group"></p><p> <label class="col-md-3 control-label"></label></p><p> <div class="col-md-8"></p><p> <div class="termbox mb10"></p><p> <label class="checkbox-inline" for="checkboxes-1"><input name="checkboxes" id="checkboxes-1" value="1" type="checkbox" required="">I have read and agree to the <a href="terms-conditions.html">Terms & Conditions</a></label></p><p> </div></p><p> <p class="help-block" id="errorcode"><!--#output_message#--></p></p><p> <div style="clear:both"></div></p><p> <input type="submit" class="btn btn-success btn-lg" title="Register" value="Post Ad"/></p><p> </div></p><p> </div> </p><p> </p><p> </fieldset></p><p> </form></p><p>[/PHP]</p><p></p><p>මෙතනදි තමයි class එක කෝල් වෙන්නෙ</p><p></p><p>[PHP]</p><p>if(isset($_SESSION['_user']))</p><p> {</p><p> $classads->_adid = 0;</p><p> $classads->_userid = $_SESSION['_user']['id'];</p><p> $classads->_subcatid = $_POST['_subcatid'];</p><p> $classads->_typeid = $_POST['_typeid'];</p><p> $classads->_title = $_POST['_title'];</p><p> $classads->_description = $_POST['_description'];</p><p> $classads->_price = $_POST['_price'];</p><p> $classads->_city = $_POST['_city'];</p><p> $classads->_pictures = &$_FILES['_pictures'];</p><p> </p><p> </p><p> if($classads->_save())</p><p> {</p><p> //header('Location: /user/manage-ads.html');</p><p> }</p><p> else</p><p> {</p><p> display_message($classads->_message);</p><p> }</p><p> }</p><p>[/PHP]</p><p></p><p></p><p>මට තියෙන ප්රශ්නෙ මේ ලූප් එක හරියට දුවනව ඒ වුනාට ඩේටාබේස් එකට එක රෝ එකයි වැටෙන්නෙ</p><p></p><p>[PHP]</p><p>for($i=0; $i<count($this->_pictures['name']); $i++) </p><p> {</p><p> echo($i);</p><p> </p><p> $tmpFilePath = $this->_pictures['tmp_name'][$i];</p><p> if($tmpFilePath != "")</p><p> {</p><p> $fileType = $this->_pictures['type'][$i];</p><p> $ext = end((explode(".", $this->_pictures['name'][$i])));</p><p> $filename = $_SESSION['_user']['id'].'-'.time().'-'.$i.'.'.$ext;</p><p> </p><p> </p><p> $shortname = $this->_pictures['name'][$i];</p><p> $filePath = "$uploadingpath/uploaded/$filename";</p><p> </p><p> </p><p> if(!in_array($fileType,$allowedFileTypes))</p><p> {</p><p> $this->_message = 'Image type not allowed! Please upload JPG, JPEG, BMP, GIF or PNG images';</p><p> $dbcon->rollBack();</p><p> return(false);</p><p> exit;</p><p> }</p><p> </p><p> if ($this->_pictures['error'][$i] > 0)</p><p> {</p><p> $this->_message = 'Invalid Image! Unreadable or Damaged picture';</p><p> $dbcon->rollBack();</p><p> return(false);</p><p> exit;</p><p> }</p><p> </p><p> </p><p> if(!move_uploaded_file($tmpFilePath, $filePath)) </p><p> {</p><p> $this->_message = 'Internal Error! Please contact webmaster';</p><p> $dbcon->rollBack();</p><p> return(false);</p><p> }</p><p> </p><p> //100px resized images</p><p> $classImage->_load("$uploadingpath/uploaded/$filename");</p><p> $classImage->_resizeToWidth(100);</p><p> $classImage->_save("$uploadingpath/processed/100/$filename");</p><p> </p><p> //400px resized images</p><p> $classImage->_load("$uploadingpath/uploaded/$filename");</p><p> $classImage->_resizeToWidth(400);</p><p> $classImage->_save("$uploadingpath/processed/400/$filename");</p><p> </p><p> //800px resized images</p><p> $classImage->_load("$uploadingpath/uploaded/$filename");</p><p> $classImage->_resizeToWidth(800);</p><p> $classImage->_save("$uploadingpath/processed/800/$filename");</p><p> </p><p> </p><p> $resultset = $dbcon->prepare("INSERT INTO tbl_ads_images (_adid, _imagepath, _order) VALUES (_adid=:_adid,_imagepath=:_imagepath,_order=:_order);");</p><p> $resultset->execute(array(</p><p> ':_adid' => $this->_adid,</p><p> ':_imagepath' => $filename,</p><p> ':_order' => $i</p><p> ));</p><p> </p><p> </p><p> }</p><p> }</p><p>[/PHP]</p><p></p><p></p><p></p><p>උදවු කරන අයට 5 ගානෙ සලකනු ලැබේ <img src="/styles/default/xenforo/smilies/default/rolleyes.gif" class="smilie" loading="lazy" alt=":rolleyes:" title="Rolleyes :rolleyes:" data-shortname=":rolleyes:" /></p></blockquote><p></p>
[QUOTE="lkzombie, post: 20496502, member: 462352"] මේ තියෙන්නෙ මම ලියපු class එකක් [PHP] <?php include_once get_include_path().'cls/database/cls_dbconnection.php'; include_once get_include_path().'cls/misc/cls_images.php'; include_once get_include_path().'cls/misc/cls_session.php'; include_once get_include_path().'cls/business/cls_users.php'; class _ads { public $_adid = ""; public $_userid = ""; public $_subcatid = ""; public $_typeid = ""; public $_title = ""; public $_description = ""; public $_price = ""; public $_city = ""; public $_pictures = null; public $_message = ""; public function _open() { try { $classDB = new database(); $dbcon = $classDB->_getDBconnection(); $resultset = null; if($dbcon) { $resultset = $dbcon->prepare("SELECT * FROM tbl_ads WHERE _adid=:_adid AND _status=1;"); $resultset->execute(array(':_adid'=>$this->_adid)); $rows = $resultset->fetch(PDO::FETCH_ASSOC); $this->_adid = $rows['_adid']; $this->_userid = $rows['_userid']; $this->_subcatid = $rows['_subcatid']; $this->_typeid = $rows['_typeid']; $this->_title = $rows['_title']; $this->_description = $rows['_description']; $this->_price = $rows['_price']; $this->_city = $rows['_city']; $resultset = null; $resultset = $dbcon->prepare("SELECT * FROM tbl_ads_images WHERE _adid=:_adid;"); $resultset->execute(array(':_adid'=>$this->_adid)); if(!$resultset->rowCount()==0) { $this->_pictures = $resultset; } $dbcon = null; $classDB->close_db(); return(true); } } catch(exception $e) { $this->_message="Unexpected error:_open"; return (false); } } public function _save($userinfo="") { try { $classDB = new database(); $classImage = new _images(); $dbcon = $classDB->_getDBconnection(); $resultset = null; if($dbcon) { $dbcon->beginTransaction(); //Check user $resultset = $dbcon->prepare("SELECT * FROM tbl_users WHERE _userid=:_userid AND _status=1;"); $resultset->execute(array(':_userid'=>$this->_userid)); if($resultset->rowCount()!==1) { $this->_message="Invalid user!!"; $dbcon->rollBack(); return (false); } //Generate new id $resultset = $dbcon->prepare("SELECT _adid FROM tbl_parameters;"); $resultset->execute(); $rows = $resultset->fetch(PDO::FETCH_ASSOC); $this->_adid = $rows['_adid']+1; $resultset=null; //Update new id $resultset = $dbcon->prepare("UPDATE tbl_parameters SET _adid=:_adid;"); $resultset->execute(array(':_adid'=>$this->_adid)); if($resultset->rowCount()!==1) { $this->_message="System error: Parameter cannot be updated."; $dbcon->rollBack(); return (false); exit; } $resultset=null; $resultset = $dbcon->prepare("INSERT INTO tbl_ads (_adid, _userid, _subcatid, _typeid, _title, _description, _price, _city, _status) VALUES (?,?,?,?,?,?,?,?,1);"); $resultset->bindParam(1, $this->_adid); $resultset->bindParam(2, $this->_userid); $resultset->bindParam(3, $this->_subcatid); $resultset->bindParam(4, $this->_typeid); $resultset->bindParam(5, $this->_title); $resultset->bindParam(6, $this->_description); $resultset->bindParam(7, $this->_price); $resultset->bindParam(8, $this->_city); $resultset->execute(); if($resultset->rowCount()==1) { $resultset = null; $uploadingpath = get_include_path().'images'; $allowedFileTypes = array("image/jpg","image/jpeg","image/bmp","image/gif","image/png"); for($i=0; $i<count($this->_pictures['name']); $i++) { echo($i); $tmpFilePath = $this->_pictures['tmp_name'][$i]; if($tmpFilePath != "") { $fileType = $this->_pictures['type'][$i]; $ext = end((explode(".", $this->_pictures['name'][$i]))); $filename = $_SESSION['_user']['id'].'-'.time().'-'.$i.'.'.$ext; $shortname = $this->_pictures['name'][$i]; $filePath = "$uploadingpath/uploaded/$filename"; if(!in_array($fileType,$allowedFileTypes)) { $this->_message = 'Image type not allowed! Please upload JPG, JPEG, BMP, GIF or PNG images'; $dbcon->rollBack(); return(false); exit; } if ($this->_pictures['error'][$i] > 0) { $this->_message = 'Invalid Image! Unreadable or Damaged picture'; $dbcon->rollBack(); return(false); exit; } if(!move_uploaded_file($tmpFilePath, $filePath)) { $this->_message = 'Internal Error! Please contact webmaster'; $dbcon->rollBack(); return(false); } //100px resized images $classImage->_load("$uploadingpath/uploaded/$filename"); $classImage->_resizeToWidth(100); $classImage->_save("$uploadingpath/processed/100/$filename"); //400px resized images $classImage->_load("$uploadingpath/uploaded/$filename"); $classImage->_resizeToWidth(400); $classImage->_save("$uploadingpath/processed/400/$filename"); //800px resized images $classImage->_load("$uploadingpath/uploaded/$filename"); $classImage->_resizeToWidth(800); $classImage->_save("$uploadingpath/processed/800/$filename"); $resultset = $dbcon->prepare("INSERT INTO tbl_ads_images (_adid, _imagepath, _order) VALUES (_adid=:_adid,_imagepath=:_imagepath,_order=:_order);"); $resultset->execute(array( ':_adid' => $this->_adid, ':_imagepath' => $filename, ':_order' => $i )); } } } $dbcon->commit(); Return (True); exit; } else { $this->_message="No active database connection "; return (false); exit; } } catch(exception $e) { $this->_message="Unexpected error:_open ".$e; //$dbcon->rollBack(); return (false); exit; } } public function _update() { } public function _delete() { } } ?> [/PHP] මේ ෆෝම් එක [PHP] <form class="form-horizontal" enctype="multipart/form-data" method="post"> <fieldset> <div class="form-group"> <label class="col-md-3 control-label">Category <sup>*</sup></label> <div class="col-md-8"> <select title="Select Category" name="_subcatid" id="category-group" class="selectpicker" required=""><!--#category-optionlist#--></select> </div> </div> <div class="form-group"> <label class="col-md-3 control-label">Add Type</label> <div class="col-md-8"> <label class="radio-inline" for="radios-0"><input name="_typeid" id="radios-0" value="0" checked="checked" type="radio">Private </label> <label class="radio-inline" for="radios-1"><input name="_typeid" id="radios-1" value="1" type="radio">Business </label> </div> </div> <div class="form-group"> <label class="col-md-3 control-label" for="Adtitle">Ad title <sup>*</sup></label> <div class="col-md-8"> <input id="Adtitle" name="_title" placeholder="Ad title" class="form-control input-md" required="" type="text"> <span class="help-block">A great title needs at least 60 characters. </span> </div> </div> <div class="form-group"> <label class="col-md-3 control-label" for="textarea">Describe ad <sup>*</sup></label> <div class="col-md-8"> <textarea class="form-control" id="textarea" name="_description" placeholder="Describe what makes your ad unique" required=""></textarea> </div> </div> <div class="form-group"> <label class="col-md-3 control-label" for="Price">Price <sup>*</sup></label> <div class="col-md-4"> <div class="input-group"><span class="input-group-addon">Rs.</span> <input id="Price" name="_price" class="form-control" placeholder="Price" required="" type="text"> </div> </div> <div class="col-md-4"> <div class="checkbox"> <label><input type="checkbox">Negotiable </label> </div> </div> </div> <div class="form-group"> <label class="col-md-3 control-label" for="seller-Location">Location <sup>*</sup></label> <div class="col-md-8"> <input id="autocomplete-ajax" name="_city" class="form-control" required=""> </div> </div> <div class="form-group"> <label class="col-md-3 control-label" for="textarea"> Pictures</label> <div class="col-md-8"> <div class="mb10"> <input id="_pictures" name="_pictures[]" type="file" class="file" accept="image/*" multiple=""> </div> <p class="help-block">Add up to 5 photos. Maximum 2Mb</p> </div> </div> <!--#sellerinformations#--> <div class="form-group"> <label class="col-md-3 control-label"></label> <div class="col-md-8"> <div class="termbox mb10"> <label class="checkbox-inline" for="checkboxes-1"><input name="checkboxes" id="checkboxes-1" value="1" type="checkbox" required="">I have read and agree to the <a href="terms-conditions.html">Terms & Conditions</a></label> </div> <p class="help-block" id="errorcode"><!--#output_message#--></p> <div style="clear:both"></div> <input type="submit" class="btn btn-success btn-lg" title="Register" value="Post Ad"/> </div> </div> </fieldset> </form> [/PHP] මෙතනදි තමයි class එක කෝල් වෙන්නෙ [PHP] if(isset($_SESSION['_user'])) { $classads->_adid = 0; $classads->_userid = $_SESSION['_user']['id']; $classads->_subcatid = $_POST['_subcatid']; $classads->_typeid = $_POST['_typeid']; $classads->_title = $_POST['_title']; $classads->_description = $_POST['_description']; $classads->_price = $_POST['_price']; $classads->_city = $_POST['_city']; $classads->_pictures = &$_FILES['_pictures']; if($classads->_save()) { //header('Location: /user/manage-ads.html'); } else { display_message($classads->_message); } } [/PHP] මට තියෙන ප්රශ්නෙ මේ ලූප් එක හරියට දුවනව ඒ වුනාට ඩේටාබේස් එකට එක රෝ එකයි වැටෙන්නෙ [PHP] for($i=0; $i<count($this->_pictures['name']); $i++) { echo($i); $tmpFilePath = $this->_pictures['tmp_name'][$i]; if($tmpFilePath != "") { $fileType = $this->_pictures['type'][$i]; $ext = end((explode(".", $this->_pictures['name'][$i]))); $filename = $_SESSION['_user']['id'].'-'.time().'-'.$i.'.'.$ext; $shortname = $this->_pictures['name'][$i]; $filePath = "$uploadingpath/uploaded/$filename"; if(!in_array($fileType,$allowedFileTypes)) { $this->_message = 'Image type not allowed! Please upload JPG, JPEG, BMP, GIF or PNG images'; $dbcon->rollBack(); return(false); exit; } if ($this->_pictures['error'][$i] > 0) { $this->_message = 'Invalid Image! Unreadable or Damaged picture'; $dbcon->rollBack(); return(false); exit; } if(!move_uploaded_file($tmpFilePath, $filePath)) { $this->_message = 'Internal Error! Please contact webmaster'; $dbcon->rollBack(); return(false); } //100px resized images $classImage->_load("$uploadingpath/uploaded/$filename"); $classImage->_resizeToWidth(100); $classImage->_save("$uploadingpath/processed/100/$filename"); //400px resized images $classImage->_load("$uploadingpath/uploaded/$filename"); $classImage->_resizeToWidth(400); $classImage->_save("$uploadingpath/processed/400/$filename"); //800px resized images $classImage->_load("$uploadingpath/uploaded/$filename"); $classImage->_resizeToWidth(800); $classImage->_save("$uploadingpath/processed/800/$filename"); $resultset = $dbcon->prepare("INSERT INTO tbl_ads_images (_adid, _imagepath, _order) VALUES (_adid=:_adid,_imagepath=:_imagepath,_order=:_order);"); $resultset->execute(array( ':_adid' => $this->_adid, ':_imagepath' => $filename, ':_order' => $i )); } } [/PHP] උදවු කරන අයට 5 ගානෙ සලකනු ලැබේ :rolleyes: [/QUOTE]
Insert quotes…
Verification
Nawa warak dahaya keeyada? (Namaya wadi kireema dahaya)
Post reply
Top
Bottom