Thursday, October 18, 2012

To create lost password page for wordpress

<code><?php
/**
 *Template Name: Forget Password
 The template for displaying all pages.
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site will use a
 * different template.
 *
 * @package WordPress
 * @subpackage Twenty_Eleven
 * @since Twenty Eleven 1.0
 */

get_header(); ?>
<?php get_sidebar(); ?>
<script type = 'text/javascript'>

     function join_team()
{
   
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;   
    if(reg.test(document.getElementById("email_user").value) == false)
    {
    alert("Please enter a valid email");
    document.getElementById('email_user').focus();
    return false;
    } 
}
</script>
<?php
function createRandomPassword() {
    $chars = "abcdefghijkmnopqrstuvwxyz023456789";
    srand((double)microtime()*1000000);
   $i = 0;
    $pass = '' ;
    while ($i <= 7) {

        $num = rand() % 33;

        $tmp = substr($chars, $num, 1);

        $pass = $pass . $tmp;

        $i++;
    }
    return $pass;
}
// Usage






if(isset($_REQUEST['forgetpwd']) )
    {
    $password = createRandomPassword();
        $mail_address = $_REQUEST[email_user];
        $query = "select * from wp_users where user_email='".$mail_address."'";
        //echo     $query;
        $rs   = mysql_query($query);
        $row  = mysql_fetch_assoc($rs);
        $newpwd = md5($password );
       
        if($row['user_email']==$mail_address)
        {
            $query1 =  "update  wp_users set user_pass='".$newpwd."' where user_email ='".$mail_address."'";
            ///echo $query1;
            $row1 = mysql_query($query1);
            $to      = $mail_address;          //brokeremail
            $from     =  "Info@ledworld.com";                 //visitoremail
            $subject ="Forgot Password";
            $message = "";
            $message .= "Dear ".$row['user_login'].",<br><br>Your Login information along with password is as mentioned below :<br><br>";
            $message .= "Username    : ".$row['user_login']."<br>";
            $message .= "Password    : ".$password."<br>";
            //$message .= "Message : ".$_POST['txtmsg']."<br>";
            //$message .="File : ".$_POST['upfile']."<br>";
            $message .= "<br><br><br>Thank You ,<br> Support Team";
                $message;
                    $headers ="MIME-Version: 1.0" . "\r\n";
                    $headers .="Content-type:text/html;charset=iso-8859-1" . "\r\n";
                    $headers .="From: $from" . "\r\n";
                    $abc=@mail($to,$subject,$message,$headers);
                    if($abc)
                    {
                      echo " <script>alert('mail send'); window.location='/wordpress/ledworld/login/'</script>";
                    }
                    else
                    {
                     echo "<script>alert('Mail send Succesfully');</script>";
                     echo "<div class = 'email_msg' >".$msg = "Email Send Sucessfully". "</div>";
                   
                      //echo "<script>window.location='?page_id=121&action=forget'</script>";
                      echo "<script>window.location='/wordpress/ledworld/lost-password/'</script>";
                    }
        }
        else
        {
       
        $error_msg =  "Email Address is not exists in our record";
        }
    }
?>
   <div class="c_right">
<div class="c_heading">Lost Password</div>
           <div class="login">
       
       
           
           
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <form method = "post" action = "" onsubmit = 'return join_team();'/>
            <tr>
      <td colspan ="3" align = "center">
    <?php if($error_msg!="")
    {?>
    <span style = "color:red;adding-left: 49px;"><?php echo $error_msg; ?></span>
    <?php
    }
    ?>
        </td>
  </tr>
  <tr>
    <td width="39%" align="right">Email:</td>
    <td width="1%" height="35">&nbsp;</td>
    <td width="60%">
        <input name="email_user" type="text" id = "email_user" class="form_fild" />    </td>
  </tr>
   <tr>
    <td align="right">&nbsp;</td>
    <td height="">&nbsp;</td>
    <td valign="bottom"><input type = "hidden" name = "forgetpwd"/><input type = "image"  src="<?php bloginfo('template_url');?>/images/getpassword.png" alt="" width="141" height="26" /></td>
  </tr>
</table>
</form>
</div>
      </div>

<?php get_footer(); ?></code>

To create a custom register page for wordpress

<?php
/*
Template name:Register Template
*/

if(isset($_REQUEST['hdnSubmit_frm']))
{
      $username=$_REQUEST['username'];
     
               $first_name=$_REQUEST['first_name'];
               $last_name=$_REQUEST['last_name'];
               $nickname=$_REQUEST['nickname'];
               $billing_company=$_REQUEST['billing_company'];
               $billing_address_1=$_REQUEST['billing_address_1'];
               $billing_address_2=$_REQUEST['billing_address_2'];
               $billing_city=$_REQUEST['billing_city'];
               $billing_postcode=$_REQUEST['billing_postcode'];
               $billing_country=$_REQUEST['billing_country'];
               $billing_state=$_REQUEST['billing_state'];
               /*$billing_email=$_REQUEST['billing_email'];*/
               $billing_email=$useremail;
               $billing_phone=$_REQUEST['billing_phone'];
               $billing_taxid=$taxid;
               /*$billing_taxid=$_REQUEST['billing_taxid'];*/
              
               /*Shipping id*/
              
                $shipping_first_name=$_REQUEST['shipping_first_name'];
                $shipping_last_name=$_REQUEST['shipping_last_name'];
                $shipping_company=$_REQUEST['shipping_company'];
                $shipping_address_1=$_REQUEST['shipping_address_1'];
                $shipping_address_2=$_REQUEST['shipping_address_2'];
                $shipping_city=$_REQUEST['shipping_city'];
                $shipping_postcode=$_REQUEST['shipping_postcode'];
                /*$shipping_taxid=$_REQUEST['shipping_taxid'];*/
                $shipping_taxid=$taxid;
                $shipping_country=$_REQUEST['shipping_country'];
                $shipping_state=$_REQUEST['shipping_state'];
     
      $useremail=$_REQUEST['useremail'];
      $taxid=$_REQUEST['taxid'];
      $password =$_REQUEST['pass'];

      if (username_exists( $username ))
         {
            $msg="<p style='color:red'>
Username already exists</p>
";
}
elseif(email_exists($useremail))
{
$msg="<p style='color:red'>
Email already registered</p>
";

}
else
{
//$detail=mysql_query("select * from wp_users where user_login='$username' and user_email='$useremail' ");
//$detail1=mysql_num_rows($detail);
//if($detail1>0)
//{
// echo "Already registered";
//} 

$user_id = username_exists( $username );
if ( !$user_id and email_exists($useremail) == false ) {
$random_password = wp_generate_password( $length=12, $include_standard_special_chars=false );
$user_id = wp_create_user( $username, $password, $useremail );
} else {
$random_password = __('User already exists.  Password inherited.');
}

update_user_meta($user_id,'first_name',$first_name);
update_user_meta($user_id,'last_name',$last_name);
add_user_meta($user_id,'nickname',$nickname);
add_user_meta($user_id,'billing_company',$billing_company);
add_user_meta($user_id,'billing_address_1',$billing_address_1);
add_user_meta($user_id,'billing_address_2',$billing_address_2);
add_user_meta($user_id,'billing_city',$billing_city);
add_user_meta($user_id,'billing_postcode',$billing_postcode);
add_user_meta($user_id,'billing_country',$billing_country);
add_user_meta($user_id,'billing_state',$billing_state);
add_user_meta($user_id,'billing_email',$billing_email);
add_user_meta($user_id,'billing_phone',$billing_phone);
add_user_meta($user_id,'taxid',$taxid);

add_user_meta($user_id,'shipping_first_name',$shipping_first_name);
add_user_meta($user_id,'shipping_last_name',$shipping_last_name);
add_user_meta($user_id,'shipping_company',$shipping_company);
add_user_meta($user_id,'shipping_address_1',$shipping_address_1);
add_user_meta($user_id,'shipping_address_2',$shipping_address_2);
add_user_meta($user_id,'shipping_city',$shipping_city);
add_user_meta($user_id,'shipping_postcode',$shipping_postcode);
add_user_meta($user_id,'shipping_taxid',$shipping_taxid);
add_user_meta($user_id,'shipping_country',$shipping_country);
add_user_meta($user_id,'shipping_state',$shipping_state);

$msg="<p style='color:green'>
Registered Successfully</p>
";
if($user_id>0)
{
wp_set_auth_cookie( $user_id, false, is_ssl() );
$url=get_option('siteurl');
header("location:$url");
}
}

}
get_header();
get_sidebar();
?>
<script>
function showSelected(){

    if(document.frm.username.value=="")
    {
        alert("Enter Full Name.");
        document.frm.username.focus();
        return false;
    }

    if(document.frm.first_name.value=="")
    {
        alert("Enter First Name.");
        document.frm.first_name.focus();
        return false;
    }
   
    if(document.frm.last_name.value=="")
    {
        alert("Enter Last Name.");
        document.frm.last_name.focus();
        return false;
    }
   
    /*if(document.frm.nickname.value=="")
    {
        alert("Enter Nick Name.");
        document.frm.nickname.focus();
        return false;
    }*/
   
    if(document.frm.billing_company.value=="")
    {
        alert("Enter Billing Company.");
        document.frm.billing_company.focus();
        return false;
    }
   
    if(document.frm.billing_address_1.value=="")
    {
        alert("Enter Billing Address 1.");
        document.frm.billing_address_1.focus();
        return false;
    }
   
    /*if(document.frm.billing_address_2.value=="")
    {
        alert("Enter Billing Address 2.");
        document.frm.billing_address_2.focus();
        return false;
    }*/
   
    if(document.frm.billing_city.value=="")
    {
        alert("Enter Billing City.");
        document.frm.billing_city.focus();
        return false;
    }
   
    if(document.frm.billing_postcode.value=="")
    {
        alert("Enter Billing Post Code.");
        document.frm.billing_postcode.focus();
        return false;
    }
   
    if(document.frm.billing_country.value=="")
    {
        alert("Enter Billing Country.");
        document.frm.billing_country.focus();
        return false;
    }
   
    if(document.frm.billing_state.value=="")
    {
        alert("Enter Billing State.");
        document.frm.billing_state.focus();
        return false;
    }
   
    if(document.frm.billing_phone.value=="")
    {
        alert("Enter Billing Phone.");
        document.frm.billing_phone.focus();
        return false;
    }
   
   
    /* shipping */
   
    if(document.frm.shipping_first_name.value=="")
    {
        alert("Enter Shipping first name.");
        document.frm.shipping_first_name.focus();
        return false;
    }
   
    if(document.frm.shipping_last_name.value=="")
    {
        alert("Enter Shipping Last name.");
        document.frm.shipping_last_name.focus();
        return false;
    }
   
    if(document.frm.shipping_company.value=="")
    {
        alert("Enter Shipping Last name.");
        document.frm.shipping_company.focus();
        return false;
    }
   
    if(document.frm.shipping_address_1.value=="")
    {
        alert("Enter Shipping Address.");
        document.frm.shipping_address_1.focus();
        return false;
    }
   
    if(document.frm.shipping_city.value=="")
    {
        alert("Enter Shipping City.");
        document.frm.shipping_city.focus();
        return false;
    }
   
    if(document.frm.shipping_postcode.value=="")
    {
        alert("Enter Shipping Post code.");
        document.frm.shipping_postcode.focus();
        return false;
    }
   
    if(document.frm.shipping_country.value=="")
    {
        alert("Enter Shipping Country.");
        document.frm.shipping_country.focus();
        return false;
    }
   
    if(document.frm.shipping_state.value=="")
    {
        alert("Enter Shipping state.");
        document.frm.shipping_state.focus();
        return false;
    }
   
   
   
    /* shipping*/
   
   
   
   
    if(document.frm.useremail.value == "")
    {
        alert("Enter Email Id.");
        document.frm.useremail.focus();
        return false;
    }
   
   


    var str=document.frm.useremail.value;
    var at="@"
    var dot="."
    var lat=str.indexOf(at)
    var lstr=str.length
    var ldot=str.indexOf(dot)
   
    if (str.indexOf(at)==-1)
    {
        alert("Enter valid email id.");
        document.frm.useremail.focus();
        return false;
    }

    if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
    {
        alert("Enter valid email id.");
        document.frm.useremail.focus();
        return false;
    }

    if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
    {

        alert("Enter valid email id.");
        document.frm.useremail.focus();
        return false;
    }

    if (str.indexOf(at,(lat+1))!=-1)
    {
        alert("Enter valid email id.");
        document.frm.useremail.focus();
        return false;
    }

    if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
    {
        alert("Enter valid email id.");
        document.frm.useremail.focus();
        return false;
    }

    if (str.indexOf(dot,(lat+2))==-1)
    {
        alert("Enter valid email id.");
        document.frm.useremail.focus();
        return false;
    }

    if (str.indexOf(" ")!=-1)
    {
        alert("Enter valid email id.");
        document.frm.useremail.focus();
        return false;
    }
   
    if(document.frm.userreemail.value=="")
    {
        alert("Enter retype email.");
        document.frm.userreemail.focus();
        return false;

    }
   
    if(document.frm.useremail.value != document.frm.userreemail.value)
    {
        alert("Email does not match.");
        document.frm.userreemail.focus();
        return false;
    }

    if(document.frm.pass.value=="")
    {
        alert("Enter password.");
        document.frm.pass.focus();
        return false;
    }

    if(document.frm.pass.value.length<6)
    {
        alert("Your password must be at least 6 characters long.");
        document.frm.pass.focus();
        return false;
    }
    if(document.frm.repass.value=="")
    {
        alert("Enter retype password.");
        document.frm.repass.focus();
        return false;

    }
    if(document.frm.pass.value != document.frm.repass.value)
    {
        alert("Password does not match.");
        //document.frm.pass.value = "";
        document.frm.repass.value = "";
        document.frm.pass.focus();
        return false;
    }
    document.frm.submit();
}
</script>
<div class="c_right">
      <div class="c_heading">
Register</div>
<div class="register">
       
        <strong>Email Address &amp; Password</strong>
Enter your email address, which will serve as the Username for your account, and create a password.

Your password must be at least 6 characters with at least 1 digit and at least 1 letter.
       
      </div>
<div class="register1">
         <?php if(isset($_REQUEST['msg'])){ ?>
            <span id="message" style="font-weight: bold;color: red;">Sorry, that email address already has an account, please try another</span>
            <?php } ?>
        <form name="frm" method="post" action="">
        <input type="hidden" id="hdnSubmit_frm" name="hdnSubmit_frm" value="insert" />
       
            <table style="width:100% !important">
<tr>
                <td colspan="2"><strong> Required field *</strong>  <?php if(isset($_REQUEST['hdnSubmit_frm']))
                             {
                               echo $msg;                           
                             } ?></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;">Name*</td>
              <td>
                <input name="username" id="username" type="text" value="<?php echo $_REQUEST['username']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;">Email Address*</td>
              <td><input name="useremail" id="useremail" type="text" value="<?php echo $_REQUEST['useremail']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;">Re-enter Email Address*</td>
              <td>
                    <input name="userreemail" id="userreemail" type="text" value="<?php echo $_REQUEST['useremail']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;">Tax Id*</td>
              <td>
                  <input name="taxid" id="taxid" type="text" value="<?php echo $_REQUEST['taxid']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;">Password*</td>
              <td><input name="pass" id="pass" type="password" value="<?php echo $_REQUEST['pass']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;">Re-enter Password*</td>
              <td>
                  <input name="repass" id="repass" type="password" value="<?php echo $_REQUEST['pass']; ?>" class="billing_fild"></td>
            </tr>
<!-- ----- Billing Address ----------------------------------- -->
<tr style="background:#E9E9E9;"><td colspan="2" ><h2 style="padding-left: 10px;">
Billing Address</h2>
</td></tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;">First Name*</td>
              <td>
                  <input name="first_name" id="first_name" type="text" value="<?php echo $_REQUEST['first_name']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;">Last Name*</td>
              <td>
                  <input name="last_name" id="last_name" type="text" value="<?php echo $_REQUEST['last_name']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;"> Company*</td>
              <td>
                  <input name="billing_company" id="billing_company" type="text" value="<?php echo $_REQUEST['billing_company']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;"> Address 1*</td>
              <td>
                  <input name="billing_address_1" id="billing_address_1" type="text" value="<?php echo $_REQUEST['billing_address_1']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;"> Address 2</td>
              <td>
                  <input name="billing_address_2" id="billing_address_2" type="text" value="<?php echo $_REQUEST['billing_address_2']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;">City*</td>
              <td>
                  <input name="billing_city" id="billing_city" type="text" value="<?php echo $_REQUEST['billing_city']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;"> Post Code*</td>
              <td>
                  <input name="billing_postcode" id="billing_postcode" type="text" value="<?php echo $_REQUEST['billing_postcode']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;"> Country*</td>
              <td>
                  <input name="billing_country" id="billing_country" type="text" value="<?php echo $_REQUEST['billing_country']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;"> State*</td>
              <td>
                  <input name="billing_state" id="billing_state" type="text" value="<?php echo $_REQUEST['billing_state']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;">Phone*</td>
              <td>
                  <input name=" billing_phone" id="billing_phone" type="text" value="<?php echo $_REQUEST[' billing_phone']; ?>" class="billing_fild"></td>
              </tr>
<!-- ----- fealds ------------------------------------------------------ -->

           
           
             
             
              <!-- ----- Shipping  Address ----------------------------------- -->
<tr style="background:#E9E9E9;"><td colspan="2" ><h2 style="padding-left: 10px;">
 Shipping Address</h2>
</td></tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;"> First Name*</td>
              <td>
                  <input name="shipping_first_name" id="shipping_first_name" type="text" value="<?php echo $_REQUEST['shipping_first_name']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;">Last Name*</td>
              <td>
                  <input name="shipping_last_name" id="shipping_last_name" type="text" value="<?php echo $_REQUEST['shipping_last_name']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;">Company*</td>
              <td>
                  <input name="shipping_company" id="shipping_company" type="text" value="<?php echo $_REQUEST['shipping_company']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;"> Address 1*</td>
              <td>
                  <input name="shipping_address_1" id="shipping_address_1" type="text" value="<?php echo $_REQUEST['shipping_address_1']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;"> Address 2</td>
              <td>
                  <input name="shipping_address_2" id="shipping_address_2" type="text" value="<?php echo $_REQUEST['shipping_address_2']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;"> City*</td>
              <td>
                  <input name="shipping_city" id="shipping_city" type="text" value="<?php echo $_REQUEST['shipping_city']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;">Post Code*</td>
              <td>
                  <input name="shipping_postcode" id="shipping_postcode" type="text" value="<?php echo $_REQUEST['shipping_postcode']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;"> Country*</td>
              <td>
                  <input name="shipping_country" id="shipping_country" type="text" value="<?php echo $_REQUEST['shipping_country']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td style="background:#F5F5F5;padding-left: 10px;">State*</td>
              <td>
                  <input name="shipping_state" id="shipping_state" type="text" value="<?php echo $_REQUEST['shipping_state']; ?>" class="billing_fild"></td>
              </tr>
<tr>
              <td>&nbsp; </td>
              <td><a href="#submit" onClick="showSelected();"> <img src="<?php bloginfo('template_directory'); ?>/images/register.png" alt="" border="0"></a></td>
              </tr>
</table>
</form>
</div>
</div>
<?php get_footer(); ?>

Thursday, October 4, 2012

Redirecting non-www to www with .htaccess


RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Simply  create a file .htaccess   and save this code in the file   .htaccess  after that add the file in your site root directory       Thanks 

Friday, September 21, 2012

Onpage load poup by jquery

<link media="screen" rel="stylesheet" href="colorbox.css" />
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="http://www.javascript-coder.com/files/jquery-popup/modal-popup/jquery.colorbox-min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function()
{
    $(window).bind('load',
        function(e)
        {
            $.colorbox({opacity:0.3, href:"test.html"});
        });
});
</script>

Wednesday, August 8, 2012

How to send email with attachement in php

<?php
include('../../../wp-load.php');

function eemail_send_mail($recipients = array(), $subject = '', $message = '',$attachment='', $type='plaintext', $sender_name='', $sender_email='',$filename='')
{
  
    global $wpdb;
    global $user_login , $user_email;
  
    if($sender_email == "" || $sender_name == '')
    {
        get_currentuserinfo();
        $sender_email = $user_email;
        $sender_name = $user_login;
    }
  
    $eemail_from_name = get_option('eemail_from_name');
    if($eemail_from_name!="")
    {
        $sender_name = $eemail_from_name;
    }
  
    $eemail_from_email = get_option('eemail_from_email');
    if($eemail_from_email!="")
    {
        $sender_email = $eemail_from_email;
    }
  
    $num_sent = 0; // return value
  
    if ( (empty($recipients)) ) { return $num_sent; }
  
    if ('' == $message) { return false; }
  
  
    // $fileatt="../wp-content/plugins/email-newsletter/attachement/".$attachment;
          $fileatt=$attachment;
         //echo  $fileatt;
        //  echo "<img src='".$fileatt."'>";
    $fileatt_type = ".jpg,.gif,.txt,.jpeg,.rar,.php,.flv,.doc,.docx,.log,.dat,.mp3,.mp4"; // File Type
         $fileatt_name =$filename;
    $email_from =$eemail_from_email;
  
        $email_subject = stripslashes($subject);
  
    $headers = "From: ".$email_from;

    $file = fopen($fileatt,'rb');
        $data = fread($file,filesize($fileatt));
        fclose($file);
        if($data){
            //echo "aaaaaaaaaaaaaaaaaa";
            //echo  $data;
        }

    $semi_rand = md5(time());
        $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
      
        $from = $email;
  
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
        $headers .="From: \"$from\" <$from>\r\nReply-To: \"$from\" <$from>\r\nX-Mailer: PHP/".phpversion();  
        $headers .= "\nMIME-Version: 1.0\n" .
        "Content-Type: multipart/mixed;\n" .
        " boundary=\"{$mime_boundary}\"";
      
    $email_message = stripslashes($message);
    $email_message .= "This is a multi-part message in MIME format.\n\n" .
        "--{$mime_boundary}\n" .
        "Content-Type:text/html; charset=\"iso-8859-1\"\n" .
        "Content-Transfer-Encoding: 7bit\n\n" .
        $email_message . "\n\n";
      
        $data = chunk_split(base64_encode($data));
      
        $email_message .= "--{$mime_boundary}\n" .
        "Content-Type: {$fileatt_type};\n" .
        " name=\"{$fileatt_name}\"\n" .
        "Content-Transfer-Encoding: base64\n\n" .
        $data . "\n\n" ."--{$mime_boundary}--\n";
  
    if(count($recipients) > 0)
    {
        for ($i=0; $i<count($recipients); $i++)
        {
            @$to = @$recipients[$i];
            if (!eemail_valid_email($to))
            {
                echo "$to email not valid<br>";
                continue;
            }
            //@$newheaders = $headers . "To: \"" . $to . "\" <" . $to . ">\n" ;
            //echo $email_message;
            //@wp_mail($to, $subject, $message , $headers);
            @mail($to, $email_subject, $email_message, $headers);
               @$num_sent = @$num_sent + 1;
        }
    }
    return $num_sent;
}


function eemail_valid_email($email) {
   $regex = '/^[A-z0-9][\w.+-]*@[A-z0-9][\w\-\.]+\.[A-z0-9]{2,6}$/';
   return (preg_match($regex, $email));
}

if(isset($_POST['submit'])){
$name=$_POST['name'];
$subject=$_POST['subject'];
$email=array($_POST['email']);
$message=$_POST['message'];
$attachment=$_FILES['uploaded_file']['tmp_name'];
$filename=$_FILES['uploaded_file']['name'];
$type='html';
$senderemail='test@test.com';
print_r($_FILES);
if(eemail_send_mail($email,$subject,$message,$attachment,$name,$senderemail,$filename))
{
echo"aaaaaaaaaaaaaaaaaaaaaaaaaaaa";
}else{
?>
<form method="POST" name="email_form"
action="" enctype="multipart/form-data">

<p>
<label for='name'>Name: </label><br>
<input type="text" name="name" >
</p>
<p>
<label for='name'>Subject: </label><br>
<input type="text" name="subject" >
</p>
<p>
<label for='email'>Email: </label><br>
<input type="text" name="email" >
</p>
<p>
<label for='message'>Message:</label> <br>
<textarea name="message"></textarea>
</p>
<p>
<label for='uploaded_file'>Select A File To Upload:</label> <br>
<input type="file" name="uploaded_file">
</p>
<input type="submit" value="Submit" name='submit'>

</form>
<?php
}
}else{
?>

<form method="POST" name="email_form"
action="" enctype="multipart/form-data">

<p>
<label for='name'>Name: </label><br>
<input type="text" name="name" >
</p>
<p>
<label for='name'>Subject: </label><br>
<input type="text" name="subject" >
</p>
<p>
<label for='email'>Email: </label><br>
<input type="text" name="email" >
</p>
<p>
<label for='message'>Message:</label> <br>
<textarea name="message"></textarea>
</p>
<p>
<label for='uploaded_file'>Select A File To Upload:</label> <br>
<input type="file" name="uploaded_file">
</p>
<input type="submit" value="Submit" name='submit'>

</form>
<?php
}

?>

Friday, July 20, 2012

Cannot modify header information - pluggable.php


Warning: Cannot modify header information - headers already sent by (output started at /homepages/9/d260170483/htdocs/pettraining/wordpress-2.8/wordpress/wp-content/themes/dog-lover/functions.php:6) in /homepages/9/d260170483/htdocs/pettraining/wordpress-2.8/wordpress/wp-includes/pluggable.php on line 865

If you find this problem in your site  look the page you lastly updated or  the page  on which you are using header location  function   .
After  finding the  page or template  you need to put the   code on top of page

<?php   Ob_start();  ?>

After placing the code at top  save the file  and your problem will be resolved . if have any other issue let me know  or check file  again .

How to use fck editor in php

First download the fck editor and ck finder and place them in your directory and  replace the path with your own path

ckeditor from here ---
http://ckeditor.com/download/

ckfinder from here ----
http://ckfinder.com/download/
 

basePath = 'http://localhost/test_new2/wp-content/themes/twentyeleven/ckeditor/';
CKFinder::SetupCKEditor($ckeditor, '/ckfinder/');
$ckeditor->editor('CKEditor1');
$FCKeditor->Width = '220px';
$FCKeditor->Height = '100px';
$ckeditor->ckeditor->config['toolbar'] = 'Full';
$ckeditor->ckeditor->config['language'] = 'en';
*/
?>