Sunday, August 26, 2012

contact us page


For Me  

<?php  /***************** PHP Code **********************/ 


require_once('config/bootstrap.php'); 

if(isset(
$_POST) && ($_REQUEST["mode"]=='send')){

$name strip($_POST['txtname']); 
$email strip($_POST['txtemail']); 
$ph strip($_POST['txtphone']);
$msg strip($_POST['txtcomment']);

$headers =  "From: ".$email."\r\n"
$headers .= 'MIME-Version: 1.0' "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
$headers .= "\r\nX-Mailer: PHP/" phpversion();
$subject "contact us: nethomes.com";
$message "Name: " $name ."<br> Phone No: " $ph"<br/>Email Id:".$email "<br/>Message Details : " $msg  ;

$to =  "bit7bpl@gmail.com"// "arteriors51@yahoo.com"; 

if(mail($to$subject $message ,$headers)){ 
redirect("projectprofile.php"," Thank you for sending your valueable feedback/ query. We will get back to you as soon as possible. ");
 }
else {
redirect("projectprofile.php"," Please Try Again  ");
 }


/****************   End Mail *************/ ?>

/***************** JavaScript Validation ****************************/
<script>

function formvalidation(){ 


if(document.getElementById('txtname').value==''){
alert('Please enter name');document.getElementById('txtname').focus(); return false ;  }
if(document.getElementById('txtemail').value==''){
alert('Please enter Email id');document.getElementById('txtemail').focus(); return false ;  }
if(document.getElementById('txtemail').value!=''){
var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
email = document.getElementById('txtemail').value ;
if(emailPattern.test(email)==false){
alert('please Enter Valid Email Id');
document.getElementById('txtemail').focus();
return false ;
 }
    }    
if(document.getElementById('txtphone').value==''){
alert('Please enter Phone no');document.getElementById('txtphone').focus(); return false ;  }
if(document.getElementById('txtcomment').value==''){
alert('Please enter message');document.getElementById('txtcomment').focus(); return false ;  }
}    
</script>


/******************* HTML Code  **********************************/

<form  action="projectprofile.php?mode=send" method="post" enctype="multipart/form-data" name="form1" id="form1">
 <table width="364" height="237" align="left" cellpadding="0" cellspacing="2">
  

 <tr> 
  <td width="29%" align="left"><p>Name </p></td>
  <td width="3%"><p>:<span class="preeti">:</span></p></td>
  <td width="68%"><label>
  <input name="txtname" type="text" id="txtname"  />
   </label></td>
   </tr>
   <tr>
  <td align="left"><p class="white">Email ID </p></td>
   <td><p>:<span class="preeti">:</span></p></td>
   <td><label>
    <input name="txtemail" type="text" id="txtemail" />
       </label></td>
    </tr>
    <tr>
 <td align="left"><p><span class="white">Tel. No. </span></p></td>
   <td width="3%"><p>:<span class="preeti">:</span></p></td>
  <td><input name="txtphone" type="text" id="txtphone"  maxlength="12" onkeypress="isnumberkey(event);" /></td>
   </tr>
  <tr>
 <td align="left"><p><span class="white">your message
 </span></p></td>
   <td><p>:<span class="preeti">:</span></p></td>
  <td><textarea name="txtcomment" cols="28" rows="4" id="txtcomment" ></textarea></td>
  </tr>
    <tr>
  <td height="26">&nbsp;</td>
    <td>&nbsp;</td>
 <td><input name="Send" type="submit" value="   Send    " onclick="return formvalidation();" class="butt"></td>
  </tr>
  </table>
  </form>

Saturday, August 25, 2012

add data without html editor

str_replace('&nbsp;',' ',strip_tags($_POST["txtcomment"]))

Friday, August 24, 2012

add more input box in html




/**************** HTML Code **************************/
<tr>
<td width="30%" align="right"  valign="top"> <label class="mylbl">  Contact person  &nbsp;</label></td>
<td width="50%"  valign="top">
<table id="addmorecontact">
<tr>
<td><label class="mylbl">  Name &nbsp;</label> </td>
<td><label class="mylbl"> Designation &nbsp;</label> </td>
<!-- <td>  </td>-->
</tr>
<tr id="inputbox0">
    <td><input type="text" name="txtname[]" id="txtname0" style="width:200px" class="box " /> </td>
<td> <input type="text" name="txtdesig[]" id="txtdesig0" style="width:185px" class="box " /></td>
<td id="addmorebtn0">  <input type="button" value="ADD MORE" class="com_btn" onclick="return addmorecontact();"  /> </td>
</tr>
</table>
</td>
<td width="25%"  valign="bottom" align="left" id=" "></td>
</tr>

<input type="hidden" name="hidaddmorecp" id="hidaddmorecp" value="0"  />






/*************************** JAVASCRIPT Code *****************/
function addmorecontact(){
i=1; id=$('#hidaddmorecp').val();
if($('#txtname'+id).val()==''){ alert('Please enter name'); $('#txtname'+id).focus(); return false ; }
if($('#txtdesig'+id).val()==''){ alert('Please enter designation'); $('#txtdesig'+id).focus(); return false ; }
i=add(i,id);
$('#addmorebtn'+id).html("<input type='button' value='REMOVE' class='com_btn' onclick='return removemorecontact(\"inputbox"+id+"\");'  />");
$('#addmorecontact').append("<tr id='inputbox"+i+"'><td><input type='text' name='txtname[]' id='txtname"+i+"' style='width:200px' class='box ' /> </td><td> <input type='text' name='txtdesig[]' id='txtdesig"+i+"' style='width:185px' class='box ' /></td> <td id='addmorebtn"+i+"'>  <input type='button' value='ADD MORE' class='com_btn' onclick='return addmorecontact();'  /> </td></tr>");
 $('#hidaddmorecp').val(i)
}
function removemorecontact(x){
$('#'+x).remove();
}
function add(x,y){
z=parseInt(x)+parseInt(y);
return z;
}


Friday, August 17, 2012

how to upload image into database using php


how to upload file in database in php

how to upload image into database using php

step 1

1. create database demo


CREATE TABLE IF NOT EXISTS `table1` (
  `id` int(11) NOT NULL auto_increment,
  `file` longblob NOT NULL COMMENT 'file in binary',
  `type` varchar(250) NOT NULL,
  `name` varchar(250) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;


2. create two file 


demo.php

photo.php


demo.php

<?php 

$con
=mysql_connect('localhost','root','');
mysql_select_db('demo',$con);

//print_r($_FILES);
if(isset($_REQUEST['sub'])){
 
$tpy=$_FILES['txtfile']['type'];
  
$name=$_FILES['txtfile']['name'];
   
$c=file_get_contents($_FILES['txtfile']["tmp_name"]);
mysql_query("insert into table1(file,type,name) values('".addslashes($c)."', '".$tpy."', '".$name."')");
}
$arr=mysql_query("select * from table1");
while(
$r=mysql_fetch_array($arr)){
// echo "<img src='photo.php?id=".$r[0]."'  />";
 
echo "<a href='photo.php?id=".$r[0]."'>Download here </a>";
 }
?>

<form action="" enctype="multipart/form-data" method="post">
<input type="file" name="txtfile"  />
<input type="submit" name="sub" value="submit"  />
</form> 

photo.php

<?php 

$con
=mysql_connect('localhost','root','');
mysql_select_db('demo',$con);

$arr=mysql_query("select * from table1 where id= '".$_REQUEST['id']."' ");
while(
$r=mysql_fetch_array($arr)){
header("Content-Disposition: attachment;filename=".$r['name']."");
$ty=$r[2];
header("Content-type:".$ty."");
echo 
$r[1];



}
?>

Monday, August 6, 2012

dd-mm-yyyy in javascript

date format in javascript dd mm yyyy



Chang date format in JavaScript

function datef(x){
var arr = new Array();
arr=["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
arr2=x.split('-');
i=parseInt(arr2[1],10);
d=arr2[2]+"-"+arr[i]+"-"+arr2[0];
return d;
}