Sunday 20 November 2016



How to create Small Program

            PHP-  Pre hypertext processor:- PHP me jo bhi website banti hai wo dynamic website hoti hai,

1.kuch Program me aap ko Simple bata raha hu simple  

   1.LOGIN FORM USER PASSWORD MATECH



<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>userlogin</title>
<script type="text/javascript">
function matchpass(){
    var firtpassword=document.f1.password.value;
    var secondpassword=document.f1.password2.value;
    if(firtpassword == secondpassword)
    {
    return true;   
    }
alert("password must be same");
return false;
}

</script>

</head>

<body>
<!-----password match karna-------------->
<form name="f1" action="" onSubmit="return matchpass()">
USER <input type="user" name="user"><br/>
password <input type="password" name="password"><br/>
re-enter-password<input type="password" name="password2"><br/>
<input type="submit" value="save">
</form>
</body>
</html>

                                        output

 



  2.FORM Validation error show karwna 


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>userlogin</title>
<script type="text/javascript">
function abc(){
    var error="";
    var fname=document.getElementById('f1name').value;
    var lname=document.getElementById('lname').value;
    if(fname =="")
    {
       error+="please enter name\n";   
    }
    if(lname =="")
    {
      error+="please enter lastname";   
    }
   
    if(error == "")
   
    return true;   
        else{
        alert(error);
        return true;
        }
}
</script>
</head>

<body>
<!-----validation-------------->
<form>
<table>
<tr>   <td>name<input type="text" name="name" id="f1name"> </td></tr>
<tr>   <td>lastname<input type="text" name="lasname" id="lname"> </td></tr>   

<tr><td>
<input type="button" name="submit" value="subit" onClick="abc();"></td></tr>
</table>
</form>
</body>

</html>


 OUTPUT






3.Database connection  add karwna xampp server se php ko

<?php
mysql_connect("localhost","root" ,"")or die (mysql_error());
mysql_select_db('empydb');
if(isset($_POST['submit']))
{
$insert=("insert into empyuser(name,lname)values('".$_POST['fname']."','".$_POST['lastname']."')");
mysql_query($insert);
echo "data sucessfull brother";   
    }

?>

<!-----detabase connection-------------->

<form method="post">
<table>
<tr>   <td>name<input type="text" name="fname" id="fname"> </td></tr>
<tr>   <td>lastname<input type="text" name="lastname" id="lastname"> </td></tr>   

<tr><td>
<input type="submit" name="submit" value="subit"></td>
<td>
<input type="button" name="submit" value="cancel" onClick="javascript:history:back(-1);"></td>

</tr>
</table>
</form>


 OUTPUT


4.Addition ka php me Progrma

<html>
<head> <title>php</title>
</head>
<body>
<!----- Addition Program-------------->
<form method="post">
<table>
<tr>   <td>Number1st:-<input type="text" name="t1"> </td></tr>
<tr>   <td>Number2nd:-<input type="text" name="t2"> </td></tr>   
<tr>  <td><input type="submit" name="sum" value="ok"></td>
</tr>
</table>
</form>
<?php
if(isset ($_POST['sum']))
{
$a=$_POST['t1'];
$b=$_POST['t2'];
$c=$a+$b;
}
?>
result:<input type="text" name="t3" value=<?php
if(isset($c))
{
echo $c;
}
?>>
</body>
</html> 



OUTPUT






RUN


 


 
 

3 comments:

  1. Hey Nice Blog!! Thanks For Sharing!!!Wonderful blog & good post.Its really helpful for me, waiting for a more new post. Keep Blogging!
    best java training in coimbatore
    php training in coimbatore
    best php training institutes in coimbatore

    ReplyDelete
  2. Webdevelop Code chanel

    https://www.youtube.com/watch?v=P_noB82TqDA

    ReplyDelete

About

Total Pageviews

Powered by Blogger.

BTemplates.com

MENU

Followers

About

jay hind

Popular Posts