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
Advertisements

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>




 

select option in php using database

I will show you how to add data into select option by fetching data from database. its quite simple. select option is mostly used for registrations & other major activities & forms. select option is useful.

create database named premal. add 1 table named location_country with 2 fields. 1 is for id autoincrement & name.

premal katigar

After that some data into database.

Now get following Code.

<?php
$con=mysql_connect("localhost","root");
mysql_select_db("premal",$con);
?>
<select name="location" id="location">
$query="select name from location_country";
 $result=mysql_query($query);
 if($result)
 {
 ?>
 <option value="NULL">SELECT</option>
 <?php
 while($row=mysql_fetch_array($result))
 {
 ?>
 <option value="<?php $row[0] ?>"><?php echo $row[0] ?></option>
 <?php
 }
 }
 ?> 


</select>

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

PHP user defined function

I will show you how to use user defined functions in PHP.

user defined functions are used mostly to decrease the coding load.

Besides the built-in PHP functions, we can create our own functions.

A function is a block of statements that can be used repeatedly in a program.

A function will not execute immediately when a page loads.

A function will be executed by a call to the function.

A user defined function declaration starts with the word “function”:

we create a function named “premal()”. The opening curly brace ( { ) indicates the beginning of the function code and the closing curly brace ( } ) indicates the end of the function. The function outputs “premal katigar!”. To call the function, just write its name:

user_defined_functions

We have done user defined functions.

how to store images in database using PHP

Firstly create your fetching_images.php file.

storing_images_using_php

now create add.php file.

In below code automatically create a new folder named inages in your www directory. all the images which you upload from here will store in that images folder.

we can create images using mkdir() function of PHP.

fetching_images_using_php

now create new file for displaying images named display.php

fetching_images_using_php1

You have successfully done image storing process. enjoy.

any query mail me or whatsapp me anytime.

thank you.

formatting using PHP

So you’ve gone though some of the tutorial, and you can make some nifty things in PHP. But the problem is, they all look like plain text. How do you jazz them up?

Formatting with PHP actually isn’t done with PHP, it’s done with HTML. You can do this in two ways. You can add the HTML inside of the PHP… or you can add the PHP inside of the HTML. Either way, make sure your file is saved as a .php or another file type that is allowed to execute PHP on your server.

HTML inside PHP

<?php

echo “<font color=red>Premal Katigar</font>”;

?>

PHP inside HTML

<font color=”red”>

<?php echo “Premal Katigar”; ?>

</font>

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”;

}

?>