Thursday, 24 December 2015

webpage has a redirect loop in magento 2



step: 1 Go to Phpmyadmin
          search core_config_data
step: 2 Edit the rows entitled web/unsecure/base_url and  web/secure/base_url
        http://127.0.0.1/magento_sample/  and
https://127.0.0.1/magento_sample/
step: 3 Edit the row web/url/redirect_to_base to 0 instead of 1
step: 4 Clear contents of both var/cache and var/sessions folders.

cheack your Admin url Work.....

Details

Saturday, 19 December 2015

How to Insert Data in Android to Mysql API

<?php

// Include confi.php
include_once('../confi.php');
//$apikey = "123456789";
//if ($_GET['apikey'] == $apikey) {

if($_SERVER['REQUEST_METHOD'] == "POST"){
// Get data
$category_name = isset($_POST['cat_name']) ? mysql_real_escape_string($_POST['cat_name']) : "";
$category_description = isset($_POST['cat_description']) ? mysql_real_escape_string($_POST['cat_description']) : "";
// Insert data into data base
$sql = "INSERT INTO `category` (`cat_id`,`cat_name`,`cat_description`) VALUES (NULL,'$category_name','$category_description');";
$qur = mysql_query($sql);

$result =array();
if($qur){
$result[] = array("msg" => "Done adding category!","Category Name" => $category_name,"Category Description" => $category_description);
$json = array("status" => 1, "info" => $result);
}else{
$json = array("status" => 0, "msg" => "Error adding category!");
}
}else{
$json = array("status" => 0, "msg" => "Request method not accepted");
}

@mysql_close($conn);

/* Output header */
header('Content-type: application/json');
echo json_encode($json);
//}
//else {
// echo "Access Denied";
//}

Saturday, 12 December 2015

Adding New Products with Built in Magento Tools

step 1 Go Categories
step 2  Custom Design Tab
Step 3  Copy Below Text
         <reference name="content">
               <block type="catalog/product_new" name="product_new" template="catalog/product/list.phtml">
               <action method="setCategoryId"><category_id>10</category_id></action>
                <action method="setColumnCount"><column_count>6</column_count></action>
                <action method="setProductsCount"><count>0</count></action>
             <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
                <block type="page/html_pager" name="product_list_toolbar_pager" />
                  <action method="setDefaultGridPerPage"><limit>12</limit></action>
                  <action method="addPagerLimit"><mode>grid</mode><limit>12</limit></action>
                 <action method="addPagerLimit"><mode>grid</mode><limit>24</limit></action>
                 <action method="addPagerLimit"><mode>grid</mode><limit>36</limit></action>
                <action method="addPagerLimit"><mode>grid</mode><limit>48</limit></action>
                <action method="addPagerLimit" translate="label"><mode>grid</mode><limit>all</limit><label>All</label></action>
              </block>
             <action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>6</count></action>
               <action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
              </block>
            </reference>

Step 4 Then Run

follow This link

Friday, 11 December 2015

There has been an error processing your request in magento

  • step 1     One by one, disable recently installed modules by changing <active>true</active>to <active>false</active> in app/etc/modules/<MODULE_NAME>.xml, where <MODULE_NAME> should be replaced with actual module name you installed recently.  follow This link Answer

Wednesday, 9 December 2015

After installation magento 2 then admin link not work

Before




After installing Magento 2 in Windows under Xampp, if your admin and front end link’s are not working, please follow the below steps to fix the same…
  1. Remove everything, except .htaccess file from pub/static folder
  2. Open up app/etc/di.xml find the path “Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink” and replace to “Magento\Framework\App\View\Asset\MaterializationStrategy\Copy”
Note: Remove entire files and folder under pub/static except .htaccess file.

After Link are Activate




how to solve PHP Extensions check in magento 2



step 1 Go to php.ini
step 2 find for ;extension=php_intl.dll
step 3 remove the comment ;

restart xampp 

Monday, 16 November 2015

Item (Mage_Catalog_Model_Product) with the same id already exist in magento

 This is my solution
 step 1  Edit : /www/app/code/core/Mage/Eav/Model/Entity/Collection/Abstract.php
Line: 256

step 2 Replace: return parent::addItem($object);

With: try { return parent::addItem($object); } catch (Exception $ex) { } 

Tuesday, 3 November 2015

There has been an error processing your request admin panel in magento

step 1  main directory in tmp folder create
step 2  tmp folder Set directory permissions to 777 or 755
step 3 Open “lib/Zend/Cache/Backend/File.php“
step 4 locate the following code

protected $_options = array( ‘cache_dir’ => null

and replace with

protected $_options = array( ‘cache_dir’ => ‘tmp’

sqlstate hy000 1045 access denied for user localhost using password yes in magento

step 1   change local.xml.sample to local.xml
stpe 2   change the detabese user name and password

Thursday, 29 October 2015

How to mail function in magento

http://www.magentocommerce.com/magento-connect/disable-email-notifications.html

Monday, 5 October 2015

validation with login

<script type="text/javascript">
/*
function demo()
{
var fn = document.getElementById("fn");
var email = document.getElementById("email");
var contact = document.getElementById("contact");
var pass = document.getElementById("pass");
var repass = document.getElementById("repass");

if((fn.value=="") || (fn.value.search(/^[A-Za-z]+$/)))
{
alert('Enter Name');
fn.focus();
return false;
}

var RegExEmail = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}.$/i;

if((email.value=="") ||(!RegExEmail.test(email.value)))
{
alert('Enter email');
email.focus();
return false;
}

if((contact.value=="") || (contact.value.search(/^[0-9]+$/)) || (contact.value.length<10))
{
alert('Enter Contact');
contact.focus();
return false;
}

if((pass.value=="") || (repass.value==""))
{
alert('Enter password twise');
pass.focus();
return false;
}

if(pass.value!=repass.value)
{
alert('password not match');
pass.focus();
return false;
}
return true;
}
*/


</script>

<script type="text/javascript">

function demo(){

var fn = document.getElementById("fn");
var email = document.getElementById("email");
var contact = document.getElementById("contact");
var pass = document.getElementById("pass");
var repass = document.getElementById("repass");
var gender_m = document.getElementById("gender_m");
var gender_f = document.getElementById("gender_f");
var city = document.getElementById("city");

if(fn.value==''){
alert('Enter Name');
fn.focus();
return false;
}

if(fn.value.search(/^[A-Za-z]+$/)){
alert('Enter Valid Name');
fn.focus();
return false;
}

if(email.value.search(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}.$/i)){
alert('Enter Valid Email');
email.focus();
return false;
}

if(contact.value.search(/^[0-9]+$/)){
alert('Enter Valid Contact');
contact.focus();
return false;
}

if(contact.value.length<10){
alert('Must Be Enter 10 Digit');
contact.focus();
return false;
}

if(pass.value!=repass.value){
alert('Password Not Match');
repass.focus();
return false;
}

if(gender_m.checked==false && gender_f.checked==false){
alert('Choose Gender');
gender_m.focus();
return false;
}

if(city.value==''){
alert('Select City');
city.focus();
return false;
}



return true;

}


</script>



<form name="form" action="#" method="post">
Name :-
<input type="text" name="Fname" id="fn" /><br /><br />
Email :-
<input type="text" name="Email" id="email"/><br /><br />
Contact :-
<input type="text" name="contact" id="contact" maxlength="10"/><br /><br />
Password :-
<input type="text" name="password" id="pass" /><br /><br />
Re-Password :-
<input type="text" name="repass" id="repass" /><br /><br />
Gender :-
<input type="radio" name="gender" id="gender_m" value="Male" />Male
<input type="radio" name="gender" id="gender_f" value="Female" />Female<br /><br />
City :-
<select id="city">
<option value="">--Select--</option>
    <option value="AHM">Ahmedabad</option>
</select><br /><br />
<input type="submit" name="submit" value="submit" onclick="return demo();" />
</form>
*********************************product*******************
  <form action="insert_product1.php" method="post" enctype="multipart/form-data">
    <table>
     <tr>
       <td>Name:</td>
      <tD><input type="text" name="t1"></td>
      </tr>
       <tr>
       <td>Price:</td>
      <tD><input type="text" name="t2"></td>
      </tr>
     
    <tr>
      <td>Category:</td>
       <td>
         <select name="t3">
             <option value="Electronic">Electronic</option>
             <option value="Mobile">Mobile</option>        
         </select>
     </td>
    </tr>
 
 
    <tr>
       <td>Descrition:</td>
      <tD><input type="text" name="t4"></td>
      </tr>
    <tr>
      <td>Photo</td>
      <td><input type="file" name="t5"></td>
   </tr>
          <tr>
           <td>&nbsp;</td>
           <td><input type="submit" value="submit"></td>
      </tr>
  </table>
  </form>

  <?php

    $conn=new PDO("mysql:dbname=ssit","root","");
    $result=$conn->query("select *from product");
     
?>
   <table border="1">
      <tr>
         <td>&nbsp;</td>
          <td>&nbsp;</tD>
        <td>Product Id</td>
        <td>Product Name</td>
         <td>Price</td>
        <td>Category</td>
         <td>Description</tD>
        <td>Photo</td>
        </tr>
            <?php
                while($row=$result->fetch())
               {
                  ?>
                   <tr>
                      <td><a href='deleteproduct1.php?x=<?php echo $row["pid"]; ?>'>Delete</a></td>
                       <td><a href='editproduct1.php?x=<?php echo $row["pid"]; ?>'>Edit</a></td>

                       <td><?php echo $row["pid"]; ?></td>
                       <td><?php echo $row["name"]; ?></td>
                       <td><?php echo $row["price"]; ?></td>
                       <td><?php echo $row["category"]; ?></td>
                       <td><?php echo $row["description"]; ?></td>
                       <td><img src='<?php echo $row["photo"]; ?>' height="50" width="50" ></td>

                   </tr>
               <?php  
               }
             ?>
   </table>

****************************insert*******************
<?php
      $na=$_POST["t1"];
      $p=$_POST["t2"];
      $ct=$_POST["t3"];
      $des=$_POST["t4"];
      $fname=$_FILES["t5"]["name"];
      $path="photo/".$fname;

      move_uploaded_file($_FILES["t5"]["tmp_name"],$path);
      $conn=new PDO("mysql:dbname=ssit","root","");
      $conn->query("insert into product(name,price,category,description,photo) values('".$na."','".$p."','".$ct."','".$des."','".$path."')");
      header("Location:product.php");
 
  ?>
******************edit*************
  <?php
    $id=$_GET["x"];
    $conn=new PDO("mysql:dbname=ssit","root","");
    $rs=$conn->query("select *from product where pid='".$id."'");
    $rw=$rs->fetch();
   

  ?>

<form action="updateproduct1.php" method="post" enctype="multipart/form-data">
    <input type="hidden" name="pid" value='<?php echo $rw["pid"]; ?>'>
    <table>
     <tr>
       <td>Name:</td>
      <tD><input type="text" value='<?php echo $rw["name"] ?>' name="t1"></td>
      </tr>
       <tr>
       <td>Price:</td>
      <tD><input type="text" value='<?php echo $rw["price"] ?>' name="t2"></td>
      </tr>
     
    <tr>
      <td>Category:</td>
       <td>
         <select name="t3">
             <?php
                    if($rw["category"]=="Electronic")
                    {
                ?>
             <option value="Electronic" selected>Electronic</option>
             <option value="Mobile">Mobile</option>
                    <?php
                          }
                          else
                          {
                    ?>
             <option value="Electronic">Electronic</option>
             <option value="Mobile" selected>Mobile</option>
 
                       <?php
                       }
                      ?>  
         </select>
     </td>
    </tr>
 
 
    <tr>
       <td>Descrition:</td>
      <tD><input type="text"  value='<?php echo $rw["description"] ?>' name="t4"></td>
      </tr>
    <tr>
      <td>Photo</td>
      <td><input type="file" name="t5">
           <img src='<?php echo $rw["photo"] ?>' width="30" height="30">
</td>
             
   </tr>
          <tr>
           <td>&nbsp;</td>
           <td><input type="submit" value="Update"></td>
      </tr>
  </table>
  </form>

  <?php

    $result=$conn->query("select *from product");
     
?>
   <table border="1">
      <tr>
         <td>&nbsp;</td>
          <td>&nbsp;</tD>
        <td>Product Id</td>
        <td>Product Name</td>
         <td>Price</td>
        <td>Category</td>
         <td>Description</tD>
        <td>Photo</td>
        </tr>
            <?php
                while($row=$result->fetch())
               {
                  ?>
                   <tr>
                      <td><a href='deleteproduct1.php?x=<?php echo $row["pid"]; ?>'>Delete</a></td>
                       <td><a href='editproduct1.php?x=<?php echo $row["pid"]; ?>'>Edit</a></td>

                       <td><?php echo $row["pid"]; ?></td>
                       <td><?php echo $row["name"]; ?></td>
                       <td><?php echo $row["price"]; ?></td>
                       <td><?php echo $row["category"]; ?></td>
                       <td><?php echo $row["description"]; ?></td>
                       <td><img src='<?php echo $row["photo"]; ?>' height="50" width="50" ></td>

                   </tr>
               <?php  
               }
             ?>
   </table>

*******************delete*****************
<?php
       $id=$_GET["x"];
       
      $conn=new PDO("mysql:dbname=ssit","root","");
      $conn->query("delete from product where pid='".$id."'");
      header("Location:product1.php");
 
  ?>
***************************************update
<?php
      $na=$_POST["t1"];
      $p=$_POST["t2"];
      $ct=$_POST["t3"];
       $des=$_POST["t4"];
       $id=$_POST["pid"];

 
      $conn=new PDO("mysql:dbname=ssit","root","");

          $fname=$_FILES["t5"]["name"];
        if($fname=="")
           {
      $conn->query("update product set name='".$na."',price='".$p."',category='".$ct."',description='".$des."' where pid='".$id."'");
         }
        else
           {
              $path="photo/".$fname;
move_uploaded_file($_FILES["t5"]["tmp_name"],$path);
             $conn->query("update product set name='".$na."',price='".$p."',category='".$ct."',description='".$des."',photo='".$path."' where pid='".$id."'");
           }
     header("Location:product1.php");
 
  ?>
***************multi login******
<?php
   session_start();
   $l=$_POST["t1"];
   $p=$_POST["t2"];
 


 
  $conn=new PDO("mysql:dbname=project","root","");
 
  $result1=$conn->query("select *from admin where loginid='".$l."' and password='".$p."'");
  if($row1=$result1->fetch())
   {
     header("Location:admin_welcome.php");
   }
   else
   {
 
   $result=$conn->query("select *From business where loginid='".$l."' and password='".$p."'");
 
   if($row=$result->fetch())
     {
 $_SESSION["rid"]=$row["rid"];
       header("Location:welcome_business.php");
    }
else
{
    $result2=$conn->query("select *From user where loginid='".$l."' and password='".$p."'");
        if($row2=$result2->fetch())
{
    $_SESSION["rid"]=$row2["uid"];
       header("Location:welcome_viewer.php");
 }
 else
  {

header("Location:login.php");
 }
}

}
 
  ?>

Tuesday, 29 September 2015

Login with session in php

********login*************
  <form action="checklogin.php" method="post">
    <table>
 
    <tr>
       <td>Loginid:</td>
      <tD><input type="text" name="t1"></td>
      </tr>
     <tr>
       <td>Password:</td>
      <tD><input type="password" name="t2"></td>
      </tr>
          <tr>
           <td>&nbsp;</td>
           <td><input type="submit" value="submit">
      </tr>
  </table>
  </form>

*************chack.php*******

  <?php
     session_start();
     $l=$_REQUEST["t1"];
     $p=$_REQUEST["t2"];
     $conn=new PDO("mysql:dbname=ssit","root","");
     $result=$conn->query("select *From registration where loginid='".$l."' and password='".$p."'");
   if($row=$result->fetch())
    {
      echo "welcome user ".$row["name"];
      $_SESSION["u"]=$row["rid"];
     ?>
      <br>
      <a href="changeprofile.php">change profile</a>
  <?php
    }
    else
    {
        header("Location:login.php");
    }
  ?>
*****************sessio**********
<?php
session_start();
?>
<html>
<head>
<title>USe of Data</title>
</head>
<body>
<form action="session4.php" method="post">
<?php
if(isset($_SESSION['t1']))
{
echo "Welcome".$_SESSION['t1'];


?>
<input type="submit" name="submit" value="Logout" />
<?php
}
else
{
header("Location:session.php");
}
?>
</form>
</body>
</html>
***********************4**********
<?php
session_start();
session_destroy();
header("Location:session.php");
?>

Friday, 31 July 2015

How to COOKIE Example

<?php session_start(); ?>
<?php


  if(isset($_POST['txtname']) && isset($_POST['txtname']))
  {
    
              $username=$_POST['txtname'];
             $password=$_POST['txtpass'];
           
       
            if(isset($_POST['chlrember']) && $_POST['chlrember'] == 'on')
            {
   
                 setcookie('txtname',$username, time()+120);
                  setcookie('txtpass',$password, time()+120);
            }
            else { 
    //setcookie("txtname", $username, time()-120);
    //setcookie("txtpass", $password, time()-120);
          }
   
   
   
  } 
  else {
         
          $username = '';
          $password = '';
              if(isset($_COOKIE['txtname']))
                 { $username=$_COOKIE['txtname']; }
               
             if(isset($_COOKIE['txtpass']))
                { $password=$_COOKIE['txtpass'];  }
        }
   
 
 
 
   if(isset($_POST['btnlogin']))
   {
      if( $_POST['txtname']=='admin' &&  $_POST['txtpass']=='admin')
      {
         
         $_SESSION['my']=$_POST['txtname'];   
         header('location:list.php');   
       
      }
      else
      {
        echo "Wrong User name";
      }
     
   
   }

 
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
    <script type="text/javascript">
        function chkform(form)
        {
          if(form.txtname.value=="")
          {
         
           form.txtname.focus();
           document.getElementById("a1").innerHTML="Enter User Name";
           return false;
          }
          if(form.txtpass.value=="")
          {
                form.txtpass.focus();
                document.getElementById("a2").innerHTML="Enter Your Password";
                return false;
          }
          return true;
       
        }
    </script>
</head>


<body bgcolor="#999966">
<form name="lo1" method="post" onSubmit="return chkform(this)">
    <table>
         <tr>
            <tr>
                <th>User Name</th>
                <td><input type="text" name="txtname" placeholder="Enter User Name"  value="<?=$username;?>" ><span id="a1" style="color:red"></span></td>
               
            </tr>
            <tr>
                <th>Password</th>
                <td><input type="password" name="txtpass" placeholder="Enter Pssword" value="<?=$password;?>" ><span id="a2" style="color:red"></span></td>
            </tr>
            <tr>
                <td colspan="2"><input type="checkbox" name="chlrember" > Remember Me</td>
                
            </tr>
            <tr>
                <td><input type="submit" name="btnlogin" value="Login"></td>
            </tr>
        </tr>
    </table>   
</form>

</body>
</html>

 

How To login Page With Remember me with COOKIE

<?php session_start(); ?>
<?php


  if(isset($_POST['txtname']) && isset($_POST['txtname']))
  {
    
              $username=$_POST['txtname'];
             $password=$_POST['txtpass'];
           
       
            if(isset($_POST['chlrember']) && $_POST['chlrember'] == 'on')
            {
   
                 setcookie('txtname',$username, time()+120);
                  setcookie('txtpass',$password, time()+120);
            }
            else { 
    //setcookie("txtname", $username, time()-120);
    //setcookie("txtpass", $password, time()-120);
          }
   
   
   
  } 
  else {
         
          $username = '';
          $password = '';
              if(isset($_COOKIE['txtname']))
                 { $username=$_COOKIE['txtname']; }
               
             if(isset($_COOKIE['txtpass']))
                { $password=$_COOKIE['txtpass'];  }
        }
   
 
 
 
   if(isset($_POST['btnlogin']))
   {
      if( $_POST['txtname']=='admin' &&  $_POST['txtpass']=='admin')
      {
         
         $_SESSION['my']=$_POST['txtname'];   
         header('location:list.php');   
       
      }
      else
      {
        echo "Wrong User name";
      }
     
   
   }

 
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
    <script type="text/javascript">
        function chkform(form)
        {
          if(form.txtname.value=="")
          {
         
           form.txtname.focus();
           document.getElementById("a1").innerHTML="Enter User Name";
           return false;
          }
          if(form.txtpass.value=="")
          {
                form.txtpass.focus();
                document.getElementById("a2").innerHTML="Enter Your Password";
                return false;
          }
          return true;
       
        }
    </script>
</head>


<body bgcolor="#999966">
<form name="lo1" method="post" onSubmit="return chkform(this)">
    <table>
         <tr>
            <tr>
                <th>User Name</th>
                <td><input type="text" name="txtname" placeholder="Enter User Name"  value="<?=$username;?>" ><span id="a1" style="color:red"></span></td>
               
            </tr>
            <tr>
                <th>Password</th>
                <td><input type="password" name="txtpass" placeholder="Enter Pssword" value="<?=$password;?>" ><span id="a2" style="color:red"></span></td>
            </tr>
            <tr>
                <td colspan="2"><input type="checkbox" name="chlrember" > Remember Me</td>
                
            </tr>
            <tr>
                <td><input type="submit" name="btnlogin" value="Login"></td>
            </tr>
        </tr>
    </table>   
</form>

</body>
</html>

Thursday, 23 July 2015

How date regular expression in php validation

if(!preg_match('/^(19|20)\d\d[\-\/.](0[1-9]|1[012])[\-\/.](0[1-9]|[12][0-9]|3[01])$/',$txtstrtdate))
       {
           echo $error="In valid Date";
          $code="2";
       }

Wednesday, 22 July 2015

How To live Data Search with Ajax used LIKE Query

===================
list.php
===================

<script>
function showUser(str) {
    if (str == "") {
        document.getElementById("txtHint").innerHTML = "";
        return;
    } else {
        if (window.XMLHttpRequest) {
            // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp = new XMLHttpRequest();
        } else {
            // code for IE6, IE5
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
            }
        }
        xmlhttp.open("GET","getuser.php?q="+str,true);
        xmlhttp.send();
    }
}
</script>

</head>

<body>
<form name="f11" method="post">
<div>
<span style="color:#FFF">Enter * All Data Show</span>&nbsp;&nbsp;&nbsp;<input type="text"  onchange="showUser(this.value)"/></div>
<div id="txtHint"><b>Person info will be listed here...</b></div>
</form>
</body>
</html>
================
getuser.php
==============
<?php
include('connection.php');
$q =$_GET['q'];


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php

if($q=='*')
{
 $sql="select * from employee ";
}
else
{
 $sql="SELECT * FROM employee WHERE emp_name OR emaill OR emp_username LIKE '%$q%'
AND emp_name OR emaill OR emp_username LIKE '%$q%'";
}

$result = mysqli_query($dd,$sql);
 $n=mysqli_num_rows($result);
  if($n > 0)
  {
echo "<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>

</tr>";
while($row = mysqli_fetch_array($result)) {
    echo "<tr>";
    echo "<td>" . $row['emp_name'] . "</td>";
    echo "<td>" . $row['emaill'] . "</td>";
    echo "<td>" . $row['emp_username'] . "</td>";
  
    echo "</tr>";
}
echo "</table>";
  } else { echo "Data Not Found"; }
?>
</body>
</html>

Monday, 20 July 2015

How to multiple Table Join Query

$sqlqr="select p.*,c.*,con.* from product as p LEFT JOIN categorie as c ON p.categaree=c.cat_id LEFT JOIN country as con ON p.conid=con.cid where usr_id=$id";

How to Dropdown country State Example

show-country-city-ajax.php
===============================
<?php
include('connection.php');
?>
<html>
<head>
<script>

function showUser(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}

if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","get-data.php?q="+str,true);
//xmlhttp.open("GET","get-data1.php?yy="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>

Select Your Country<select onChange="showUser(this.value)">
      <option>select</option>
<?php
$sql="SELECT * FROM country";
$result = mysqli_query($dd,$sql);
while($row = mysqli_fetch_array($result))
{
$id=$row['cid'];
echo "<option value='$id'>" . $row['coname'] . "</option>";
}
?>
</select>

<div id="txtHint" style="width:100px; border:0px solid gray;">
<b>your city disp here</b>
</div>

</body>
</html>

================
Get_data.php
===================

<?php
include('connection.php');
$q=$_GET["q"];
$sql="SELECT * FROM state WHERE conid ='$q'";
$result = mysqli_query($dd,$sql);
echo "Your State <select>";
while($row = mysqli_fetch_array($result))
{
    $id11=$row['stid'];
echo "<option>" . $row['stname'] . "</option>";
}

echo "</select>";
?>

===========
Note
===========
database
country filed  id and countryname
state filed Stid,Sname,cid(country table id)

How to user Name Chacked With Example

<?php

include('connection.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
  function chk(form)
  {
      if(form.txtname.value=="")
    {
      form.txtname.focus();
      document.getElementById("a11").innerHTML="Blank not allow";
      return false;
    }
    var ar = document.getElementById("a1").value;
    if(ar=="true")
    {
   
    }
    else {
            return false;
    }
    return true;
  }
  function userchk(str)
  {
    if(window.XMLHttpRequest)
     {
       xmlhttp = new XMLHttpRequest();
     }
     xmlhttp.onreadystatechange = function()
     {
   
          if(xmlhttp.readyState==4 && xmlhttp.status==200)
          {
               document.getElementById("msg").innerHTML = xmlhttp.responseText;
            if(xmlhttp.responseText=="user name not valid")
            {
             
              document.getElementById("a1").value="false";
            }
            else {
               
                  document.getElementById("a1").value="true";
                }
           
           }
     }
     xmlhttp.open("GET","ajax1.php?id="+str,true);
     xmlhttp.send();
  }
</script>
</head>

<body>
   <form name="f1" method="post" onsubmit="return chk(this);">
           <input type="text" name="txtname" onBlur="userchk(this.value)" />
           <span id="msg"></span>
           <span id="a11"></span>
           <input type="hidden" name="a1" value="" id="a1"  />

        <input type="submit" name="btnadd"  />
   
   </form>
   <?php
     if(isset($_POST['btnadd']))
     {
        $txtname=$_POST['txtname'];
         $sql="insert into simple(uname) values('$txtname')";
         $sqlexc=mysqli_query($dd,$sql);
         if(!$sqlexc)
         {
           echo mysql_error();
         }
         else {
       
           echo "<script>alert(' insert data');</script>";
         }
     }
  
   ?>
</body>
</html>

Sunday, 19 July 2015

How to image progress display % in javascript

<style>
  #progress_bar {
    margin: 10px 0;
    padding: 3px;
    border: 1px solid #000;
    font-size: 14px;
    clear: both;
    opacity: 0;
    -moz-transition: opacity 1s linear;
    -o-transition: opacity 1s linear;
    -webkit-transition: opacity 1s linear;
  }
  #progress_bar.loading {
    opacity: 1.0;
  }
  #progress_bar .percent {
    background-color: #99ccff;
    height: auto;
    width: 0;
  }
</style>

<input type="file" id="files" name="file" />
<button onclick="abortRead();">Cancel read</button>
<div id="progress_bar" style="width:100%;"><div class="percent">0%</div></div>

<script>
  var reader;
  var progress = document.querySelector('.percent');

  function abortRead() {
    reader.abort();
  }

  function errorHandler(evt) {
    switch(evt.target.error.code) {
      case evt.target.error.NOT_FOUND_ERR:
        alert('File Not Found!');
        break;
      case evt.target.error.NOT_READABLE_ERR:
        alert('File is not readable');
        break;
      case evt.target.error.ABORT_ERR:
        break; // noop
      default:
        alert('An error occurred reading this file.');
    };
  }

  function updateProgress(evt) {
    // evt is an ProgressEvent.
    if (evt.lengthComputable) {
      var percentLoaded = Math.round((evt.loaded / evt.total) * 100);
      // Increase the progress bar length.
      if (percentLoaded < 100) {
        progress.style.width = percentLoaded + '%';
        progress.textContent = percentLoaded + '%';
      }
    }
  }

  function handleFileSelect(evt) {
    // Reset progress indicator on new file selection.
    progress.style.width = '0%';
    progress.textContent = '0%';

    reader = new FileReader();
    reader.onerror = errorHandler;
    reader.onprogress = updateProgress;
    reader.onabort = function(e) {
      alert('File read cancelled');
    };
    reader.onloadstart = function(e) {
      document.getElementById('progress_bar').className = 'loading';
    };
    reader.onload = function(e) {
      // Ensure that the progress bar displays 100% at the end.
      progress.style.width = '30%';
      progress.textContent = '100%';
      setTimeout("document.getElementById('progress_bar').className='';", 2000);
    }

    // Read in the image file as a binary string.
    reader.readAsBinaryString(evt.target.files[0]);
  }

  document.getElementById('files').addEventListener('change', handleFileSelect, false);
</script>

Friday, 17 July 2015

How to Two table Left Join Query Example

 
  $sql="se
lect p.*,c.* from product as p  LEFT JOIN categorie as c ON p.categaree=c.cat_id where usr_id=$id";

Friday, 10 July 2015

Example Edit thean image update

<?php
   session_start();
   include("connection.php");
   if(!$_SESSION['hello'])
   {
      echo "<script>window.location='registar.php'</script>";
   }
     $id=$_GET['id'];
   $sql="select * from reg where rid=$id";
   $sqlexcu=mysqli_query($dd,$sql);
   $fetch=mysqli_fetch_array($sqlexcu);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
    <form name="f1" method="post" enctype="multipart/form-data">
        <table border="1">
              <tr>
                  <th colspan="2">My Profile</th>
              </tr>
              <tr>
                  <th>Name</th>
                  <td><input type="text" name="txtname" value="<?php echo    $fetch['name']; ?>" /></td>
              </tr>
              <tr>
                      <th>User Name</th>
                    <td><input type="text" value="<?php echo $fetch['uname']; ?>"  disabled="disabled"/></td>
              </tr>
              <tr>
                  <th>Email</th>
                  <td><input type="text" name="txtemail" value="<?php echo $fetch['uemail']; ?>" /></td>
              </tr>
              <tr>
                      <th>Mobile Number</th>
                    <td><input type="text" name="txtmono" value="<?php echo $fetch['phonenum']; ?>"  /></td>
              </tr>
              <tr>
                      <th>Address</th>
                    <td><textarea name="txtadd"><?php echo $fetch['address']; ?></textarea></td>
              </tr>
              <tr>
                      <th>Postal Code</th>
                    <td><input type="text" name="txtcode" value="<?php echo $fetch['postcode']; ?>"  /></td>
              </tr>
              <tr>
                      <th>About me</th>
                    <td><textarea name="txtabtme"> <?php echo $fetch['aboutme']; ?></textarea></td>
              </tr>
              <tr>
                      <th>Image</th>
                    <td> <input type="file" name="file"  /></td>
              </tr>
              <tr>
                      <th>Password</th>
                    <td> <input type="password" name="txtpass" value="<?php echo $fetch['pass']; ?>"  /></td>
              </tr>
              <tr>
                       <td colspan="2"> <center> <input type="submit" name="btnupdate" value="Update" /></center></td>
              </tr>
            
        </table>
    </form>
    <?php
        if(isset($_POST['btnupdate']))
        {
            $txtname=$_POST['txtname'];
            $txtemail=$_POST['txtemail'];
            $txtmono=$_POST['txtmono'];
            $txtadd=$_POST['txtadd'];
            $txtcode=$_POST['txtcode'];
            $txtabtme=$_POST['txtabtme'];
            $f1=$_FILES['file']['name'];
            $tmp=$_FILES['file']['tmp_name'];
           
            $txtpass=$_POST['txtpass'];
           
            if($f1)
            {
            $rand=rand(1,5000000);
            $imag=$rand.$f1;
            $path= "imag/".$imag;
                 move_uploaded_file($tmp,$path);
            }
               if($f1=="")
               {
             $update="update reg set name='$txtname',uemail='$txtemail',phonenum='$txtmono',address='$txtadd',postcode='$txtcode',aboutme='$txtabtme',pass='$txtpass' where rid=$id ";
                }
                else {
            $update="update reg set name='$txtname',uemail='$txtemail',phonenum='$txtmono',address='$txtadd',postcode='$txtcode',aboutme='$txtabtme',pimage='$imag',pass='$txtpass' where rid=$id ";
                }
            $updateexcu=mysqli_query($dd,$update);   
            if(!$updateexcu)
            {
              echo  mysql_error();   
            }
            else {
             echo "<script>window.location='profile.php'</script>";
                }
    }
    ?>
</body>
</html>

Thursday, 9 July 2015

server side validation in php all field in PHP

<?php
session_start();
include("connection.php");
 $error="";
?>
<?php if (isset($error)) { echo "<p class='message'>" .$error. "</p>" ;} ?>
 <?php
 ini_set("display_errors",0);
    if(isset($_POST['btnadd']))
    {
       
         // $txtname=$_POST['txtname'];
         $txtname=$_POST['txtname'];
          $txtuname=$_POST['txtuname'];
         $txtemail=$_POST['txtemail'];
         $txtphonenum=$_POST['txtphonenum'];
         $txtadd=$_POST['txtadd'];
       
          $txtcode=$_POST['txtcode'];
       
         $txtabout=$_POST['txtabout'];
         $txtpass=$_POST['txtpass'];
         $txtconpass=$_POST['txtconpass'];
           $file=$_FILES['file']['name'];
   
             $rand=rand(1,5000000);
              $img=$rand.$file;
           
               move_uploaded_file($_FILES['file']['tmp_name'],"imag/".$img);
               $pass=$_POST['txtconpass'];
           
              // $date = date('Y-m-d H:i:s');
             
               $status='Active';
                 if($txtname == "")
               {
                    // null chak name field
                   
                    echo $error="Please Enter name";
                    $code="1";
               }
               elseif(!preg_match("/^[a-zA-Z]+$/",$txtname))
                 {       
                       // chack name field only char
                           echo  $first_nameErr = "Only letters  allowed";
                        $code="1";
                  }
               elseif($txtemail=="")
               {
                   echo $error="Please Enter Email";
                   $code="2";
               }
               elseif(!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i",$txtemail))
               {
                  echo  $error ="Please Enter valid Email";
                  $code="2";
               }
               elseif($txtphonenum=="")
               {
                    echo  $error= "Please Enter Mobile Number";
                    $code="3";
               }
               elseif(!preg_match("/^\d{10}$/",$txtphonenum))
               {
                   echo $error = "Please Enter 10 Digit number";
                   $code= "3";
                  
               }
               elseif(trim($txtadd)=="")
               {
                    echo $error="Please Enter Your Address";
                    $code="4";
               }
               elseif(strlen($txtadd) < 60)
               {
                    echo $error = "Please at least 60 word write";
                    $code = "4";
               }
               elseif($txtcode=="")
               {
                      echo $error ="Please Enter Pincode ";
                      $code= "5";
               }
               elseif(!preg_match("/^\d{6}$/",$txtcode))
               {
                       echo $error = "Enter must be 6 Digit";
                    $code = "5";
               }
               elseif(trim($txtabout)=="")
               {
                       echo $error = "Please enter a About me";
                    $code="6";
               }
               elseif(strlen($txtabout) < 120)
               {
                   echo $error = "Please at least 120 word write";
                   $code = "6";
               }
               elseif($txtpass=="")
               {
                 echo $error= "Please Enter password";
                 $code = "7";
               }
               elseif(strlen($txtpass) < 8)
               {
                   echo $error = "Please at lease 8  char length";
                   $code = "7";
               }
               elseif($txtconpass=="")
               {
                    echo $error = "Please Enter confirm password";
                    $code= "8";
               }
               elseif($txtconpass !=$txtpass)
               {
                   echo $error = "Your Password is not match";
                   $code = "8";
               }
               elseif(!preg_match("/[0-9a-zA-Z]/",$txtconpass))
               {
                   echo  $error= "Please Enter Char";
                   $code = "8";
               }
               elseif(!preg_match("/[@$,<>#:?_*&;]/",$txtconpass))
               {
                   echo $error = "Pleace Enter at least one special char ";
                   $code = "8";
               }
               else
                   {
                   $sql="insert into reg(name,uname,uemail,phonenum,address,postcode,aboutme,pimage,pass,rdate,status) values('$txtname','$txtuname','$txtemail','$txtphonenum','$txtadd','$txtcode','$txtabout','$img','$txtconpass',now(),'$status')"; 
         $sqlexcu=mysqli_query($dd,$sql);
                  echo "submit";
                   }

         if(!$sqlexcu)
         {
           echo mysql_error();   
         }
         else {
             echo "<script>alert('Your Registration successfully');</script>";
            }
  }
   ?>
<style type="text/css" >

.error{border:1px solid red; }

.message{color: red; font-weight:italite;}

</style>

 <form name="f2" id="f2" method="post" enctype="multipart/form-data" style=" margin-top: -100px;"  onsubmit="return chkform(this);">
     <table border="1">
          <tr>
             <th colspan="2">Registration Form</th>
          </tr>
         
          <tr>
              <th>Name</th>
              <td><input type="text" name="txtname" placeholder="Enter Name" value="<?php if(isset($txtname)) {  echo $txtname; }   ?>" <?php if(isset($code) && $code == 1){echo "class=error";} ?> /></td>
          
          </tr>
          <tr>
              <th>User Name</th>
              <td><input type="text" name="txtuname"  placeholder="Enter User Name" onblur="userchaked(this.value)"/></td>
              <span id="msg"></span>
              
          </tr>
          <tr>
             <th>Email</th>
             <td><input type="text" name="txtemail" placeholder="Enter email Addres" value="<?php if(isset($txtemail)) { echo $txtemail; } ?>"   <?php if(isset($code) && $code == 2){echo "class=error";} ?> /> </td>
         
          </tr>
          <tr>
             <th>Phone number</th>
             <td><input type="text" name="txtphonenum" placeholder="Enter Phone number" value="<?php  if(isset($txtphonenum)) { echo $txtphonenum; } ?>"  <?php if(isset($code) && $code == 3) { echo "class=error";  } ?> /> </td>
         
          </tr>
         
          <tr>
             <th>Address</th>
             <td><textarea name="txtadd" <?php if(isset($code) && $code == 4) {  echo "class=error"; } ?> > <?php if(isset($txtadd)) {  echo $txtadd; } ?> </textarea></td>
          </tr>
          <tr>
              <th>Post code</th>
              <td><input type="text" name="txtcode" placeholder="Enter Postal Code" value="<?php if(isset($txtcode)) { echo $txtcode;  } ?>" <?php  if(isset($code) && $code == 5) {  echo "class=error"; } ?> /></td>
          </tr>
          <tr>
             <th>About Me</th>
             <td><textarea name="txtabout" <?php if(isset($code) && $code == 6) {  echo "class=error";  } ?>  > <?php if(isset($txtabout)) { echo $txtabout;   } ?>  </textarea></td>
          </tr>
          <tr>
            <th>Profile Image</th>
            <td><input type="file" name="file" id="imgfile" onchange="readURL(this)";/></td>
            <img id="preview" src="#" alt="." />
          </tr>
          <tr>
             <th>Password</th>
             <td><input type="password" name="txtpass" placeholder="Enter Password" value="<?php if(isset($txtpass))  {  echo $txtpass; } ?>" <?php  if(isset($code) && $code == 7)  { echo "class=error"; } ?> /></td>
          </tr>
          <tr>
             <th>Confirm Password</th>
             <td><input type="password" name="txtconpass"  placeholder="Enter Confirm password" value="<?php if(isset($txtconpass)) {  echo $txtconpass; } ?>" <?php if(isset($code) && $code == 8) { echo "class=error";  } ?> /></td>
              <input type="hidden" name="a1" value="" id="a1" />
          </tr>
          <tr>
             <td colspan="2"><center><input type="submit" name="btnadd"   /></center></td>
          </tr>
        
     </table>
 </form>