How to add Textbox dynamically in php

I will show you how to add textbox, select, or any checkbox dynamically in PHP. I will show you how to add dynamic textbox while clicking on link.

<head>
<script language="javascript" type="text/javascript">
function add_textbox()
{
      document.getElementById("data").value="<input type='text' name='name'>";
}
</script>
</head>
<body>
<a onClick="add_textbox()">Add Textbox</a>
</body>

We can easily add all types of inputs dynamically.

Thank you

Premal Katigar

Adding select option dynemically in php with mysql

Just Check out my this post. Its all about dynamically generation of select option. when we select the particular country it should generate automatically the new select option of the states of the particular country.

Create first connectivity.php file. following is the coding for connectivity.

<?php
$con=mysql_connect("Localhost","root");
mysql_select_db("jobsindia",$con);
?>

Now goto localhost/phpmyadmin.

Create database named jobsindia.

Create tables named location_country, location_state

mysql_table

mysql_2

<?php
include 'connectivity.php';
$location=$_GET['loc'];
$email=$_GET['email'];
$paasword=$_GET['pwd'];
?><head>
<script type="text/javascript">
function reload(form)
{
var val=form.loc.options[form.loc.options.selectedIndex].value;
var pwd=document.form.pwd.value;
var email=document.form.email.value;
self.location='registration.php?loc=' + val+"&email="+ email+"&pwd="+pwd;

}
</script>

</head>
<body class="body1">
<form name="form" method="post">
 <td>Where are you currently Located:*</td>
 <td><select name="loc" id="location" onChange="reload(this.form)">
<?php


 $query="select name,id from location_country";
 $result=mysql_query($query);
 if($result)
 {
 ?>
 <option value="">SELECT</option>
 <?php
 while($row=mysql_fetch_array($result))
 {
 if($row[0]==$location)
 {
 
 ?>
 <option value="<?php echo $row[0]; ?>" selected><?php echo $row[0]; ?></option>
 <?php
 }
 else
 {
 ?>
 <option value="<?php echo $row[0]; ?>"><?php echo $row[0]; ?></option>
 <?php
 }
 }
 
 }
 

 ?>
 </select>
<?php 
 $query_country="select id from location_country where name='$location'";
 $result_country=mysql_query($query_country);
 if($result_country)
 {
 $id_country=mysql_fetch_array($result_country);

 }
 ?> 

 
 
 </td>
 <td>&nbsp;</td>
 </tr>
 <?php
 if(!$location=="")
 {
 if($location=="India")
 {
 ?>
 <tr>
 <td>Select Your State:*</td>
 <td><select name="state">
 <?php

 $state_query="select name_state from location_state where id=1";
 $result_state=mysql_query($state_query);
 if($result_state)
 {
 ?>
 <option value="">SELECT</option>
 <?php
 while($row_state=mysql_fetch_array($result_state))
 {
 ?>
 <option value ="<?php echo $row_state[0];?>"> <?php echo $row_state[0];?></option>
 <?php
 }
 
 }
 else
 {
 echo "ERROR";
 }
 ?>
 </select></td>
 <td>&nbsp;</td> 
 </tr>
 <?php
 }
 }
 ?>
<?php
 if(!$location=="")
 {
 if($location=="India")
 {
 ?>
 <tr>
 <td>Select Your State:*</td>
 <td><select name="state">
 <?php

 $state_query="select name_state from location_state where id=1";
 $result_state=mysql_query($state_query);
 if($result_state)
 {
 ?>
 <option value="">SELECT</option>
 <?php
 while($row_state=mysql_fetch_array($result_state))
 {
 ?>
 <option value ="<?php echo $row_state[0];?>"> <?php echo $row_state[0];?></option>
 <?php
 }
 
 }
 else
 {
 echo "ERROR";
 }
 ?>
 </select></td>
 <td>&nbsp;</td> 
 </tr>
 <?php
 }
 }
 ?>
</table>
</form>
</body>




 

Safety and Security of WordPress Blog (Infographic)

WordPress is one of the most popular content management system (CMS) in use and around 17% of the websites that are present on the internet these days are powered by this CMS. With the growing use of WordPress its security and safety has also become one of the major issues to deal with. In the year 2011 more than 144,000 word press sites were hacked and this number reached to 170,000 in the year 2012.

The website owners and the core developers of WordPress are responsible for the security of the system. In order to keep their security tight, the WordPress site owners should keep various points into consideration like updating the WordPress to the latest version that is released, keeping back of data, do not display the version of WordPress on blog, reporting bugs to WordPress security, not installing the free themes, using strong passwords for all the entry points, using only trusted plug-in and others.

Some of the most common ways that result in the site being hacked are having virus on the computer, keeping easy to crack password, approving comments that are non relevant, Contact US form going to the script in the site for processing and website displaying only the plain HTML+ JavaScript pages. Thus one should take care of these points to avoid getting their site hacked.

wordpress

 

how to redirect your website in php

I will show you how to redirect the website from one page to another page.

we can use either action method from the attribute of form tag.

<form action=”premal.php” name=”form”></form>

it will redirect your website to premal.php

redirect_website

another way to redirect the website is with using header() function of PHP.

header()

We have done redirection of website in php

Premal Katigar

84604-57306

premalkatigar2@gmail.com

Learning conditional statements in PHP

Conditionals allow your program to make choices. Following the same sort of boolean logic you just learned about, the computer can only make two choices; true or false. In the case of PHP this is accomplished using IF : ELSE statements. Below is an example of an IF statement that would apply a senior’s discount.

in following statements if $name is premal then all statements inside breckets should be display.

<?php

$name=”premal”;

if($name=”premal”)

{

echo “Premal Katigar”;

}

else

{

echo “Wrong Statement”;

}

?>

How to use arrays in php

When you are working with PHP, one way to represent data is to use a variable. But sometimes a variable just isn’t enough. Sometimes you need an array. An array is sort of like a variable that holds multiple entries. For example, if you wanted a variable called $state you could only hold one state name. But if you made the same variable an array, you could hold all 50 states.

<?php  $state = "Premal";  echo $state;  ?>

If you run the code above it will simply return:

Premal

<?php  $states = array ('Bhavi', 'Premal');  print_r ($states);  ?>

If you run this you will see:

Array ( [0] => Bhavi [1] => Premal [2] )

All of the elements (the items in our array) are indexed by number. The first number is always 0.

Let’s try it:

<?php  $states = array ('Premal', 'Katigar');  echo ($states[1]);  ?>

Running this will display:

Katigar


<?php   $states = array('Developer' => 'Premal', 'Develop' => 'Paresh');   print_r($states);   ?>

Here is another way to define the same array:

<?php  $states['Developer'] = 'Premal';  $states['Develop'] = 'Paresh'  print_r ($states); ?>

Try this code:

<?php   $states = array('Developer' => 'Premal','Develop'=>'Angel');   echo ($states[Developer]);  ?>

Running this code will simply give you:

Premal