0byt3m1n1
Path:
/
data
/
17
/
1
/
18
/
11
/
1670011
/
user
/
1801231
/
htdocs
/
metalsh
/
admin
/
pages
/
[
Home
]
File: add_testimonial.php
<? session_start(); if($_POST['Submit']=="Add Testimonial") { $name=trim($_POST['name']); $title=trim($_POST['title']); $des=trim($_POST['des']); if($name!='' && $title!='' && $des!='') { //image uploading if((!empty($_FILES["uploaded_file"])) && ($_FILES['uploaded_file']['error'] == 0)) { //Check if the file is JPEG image and it's size is less than 350Kb $filename = basename($_FILES['uploaded_file']['name']); $ext = strtolower(substr($filename, strrpos($filename, '.') + 1)); //echo $ext."<br>"; if($filename!="") { $inmex=$filename; } else if($filename=="") { $inmex=""; } //echo $filename."<br>"; if (($ext == "jpg") || ($ext == "gif") || ($ext == "JPG")) { //mkdir("user_images/".$_POST['user'], 0777); $newname = '../user_images/'.$inmex; $imgspath = 'user_images/'.$inmex; //Check if the file with the same name is already exists on the server if (!file_exists($newname)) { //Attempt to move the uploaded file to it's new place if ((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) { $q_insert="insert into `tbl_testimonial` ( `id`, `name`, `title`, `description`, `image_path`, `status` ) values( NULL, '".$name."', '".$title."', '".$des."', '".$imgspath."', 'Active' )"; $r_insert=mysql_query($q_insert); if($r_insert) { ?> <script language="javascript" type="text/javascript"> window.location='index.php?page=view_edit_testimonial'; </script> <? } } else { echo "Error: A problem occurred during file upload!<br>"; } } else { echo "Error: File ".$inmex." already exists"; } } else { echo "Error: Only .jpg/.gif/.doc/.ppt/.pdf images under 1050Kb are accepted for upload"; } } else { $q_insert="insert into `tbl_testimonial` ( `id`, `name`, `title`, `description`, `image_path`, `status` ) values( NULL, '".$name."', '".$title."', '".$des."', 'user_images/no_image.jpg', 'Active' )"; $r_insert=mysql_query($q_insert); if($r_insert) { ?> <script language="javascript" type="text/javascript"> window.location='index.php?page=view_edit_testimonial'; </script> <? } else { echo mysql_error(); } } //End of image uploading } } ?> <style type="text/css"> <!-- .style5 {font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #000033; } .style6 { font-family: Arial, Helvetica, sans-serif; font-size: 16px; color: #FFFFFF; font-weight: bold; } --> </style> <table width="950" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="910" align="left" valign="middle"><form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> <table width="900" border="0" cellspacing="2" cellpadding="2" style="border:1px solid #000033"> <tr> <td colspan="2" align="left" valign="middle" bgcolor="#0099FF" class="style6" style="padding:5px;">Add Testimonial</td> </tr> <? if($_SESSION['msg']) { ?> <? unset($_SESSION['msg']); } ?> <? if($_SESSION['err_msg']) { ?> <? unset($_SESSION['err_msg']); } ?> <tr> <td width="150" align="right" valign="middle"><span class="style5">Name</span></td> <td align="left" valign="middle"><label> <input name="name" type="text" id="name" value="<?=$_POST['level_name']?>" size="30" /> </label></td> </tr> <tr> <td align="right" valign="top"><span class="style5">Title</span></td> <td align="left" valign="top"><label> <input name="title" type="text" class="style5" id="title" size="40" /> </label></td> </tr> <tr> <td align="right" valign="top"><span class="style5"> Description</span></td> <td align="left" valign="top"><label> <?php include("fckeditor/fckeditor.php") ; ob_start(); $oFCKeditor = new FCKeditor('des') ; $oFCKeditor->BasePath = 'fckeditor/' ; $oFCKeditor->Height = 400 ; $oFCKeditor->Width = "90%" ; //$oFCKeditor->Config['EditorAreaCSS'] = '../style.css' ; //$handle = fopen($filename, "r"); //$contents = fread($handle, filesize($filename)); $contents=$row['des']; //fclose($handle); $oFCKeditor->Value= $contents ; $oFCKeditor->Create() ; $out1 = ob_get_contents(); ob_end_clean(); echo $out1; ?> </label></td> </tr> <tr> <td align="right" valign="middle" class="style5">Upload Image</td> <td align="left" valign="top"><label> <input name="uploaded_file" type="file" class="style5" id="uploaded_file" size="40" /> </label></td> </tr> <tr> <td align="right" valign="top"><label></label></td> <td align="left" valign="top"><input type="submit" name="Submit" id="Submit" value="Add Testimonial" /></td> </tr> </table> </form> </td> </tr> </table>