Friday 17 February 2017

Login validataion in PHP




<?php
include"connect.php";
$un=$_POST['txtuname'];
$up=$_POST['txtpass'];
//echo "$un</br>$up</br>";


$res=pg_query($con,"select count(*) from Users where uname='$un' and upass='$up'");

$r=pg_fetch_array($res);
if($r[0]==1)
{
session_start();
$_SESSION['unm']=$un;
$_SESSION['ups']=$up;

 echo "<script type='text/javascript'>";
                echo "if(confirm('Login Successfully'))document.location='home.html';else document.location='home.html';";
                echo "</script>";

}
else
{

 echo "<script type='text/javascript'>";
                echo "if(confirm('Username or password doesnot match'))document.location='home.html';else document.location='home.html';";
                echo "</script>";

}


?>

Validation and Insertion in PHP




Email Validation in PHP using eregi function



<?php
include"connect.php";

$name=$_GET['txtname'];
$add=$_GET['txtadd'];
$mo=$_GET['txtmno'];
$g=$_GET['radg'];
$email=$_GET['txtemail'];
$dt=$_GET['dd']."/".$_GET['mm']."/".$_GET['yy'];
$un=$_GET['txtuname'];
$pass=$_GET['txtpass'];
$cpass=$_GET['txtcpass'];

//(ereg("^[a-zA-Z ]$",$name)) && (ereg("^[7-9]?[0-9]{9}$",$mo)))


//eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9]+)*(\.[a-z]{2,3})$",$email)))

//echo "$name </br>$add</br>$mo</br>$g</br>$email</br>$dt</br>$un</br>$pass</br>$cpass</br>";

if($name!="" && $add!="" && $mo!="" && $g!="" && $email!="" && $dt!="" && $un!="" && $pass!="" && $pass===$cpass)
{

    if((eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9]+)*(\.[a-z]{2,3})$",$email)) && (ereg("^[a-zA-Z ]+$",$name)) && (ereg("^[7-9]?[0-9]{10}$",$mo)))
    {
        $r=pg_query($con,"insert into Users values('$name','$add','$mo','$g','$email','$dt','$un','$pass')");
        if($r)
        {
        echo "<script type='text/javascript'>";
        echo "if(confirm('You are registered Successfully'))document.location='career.html';else document.location='career.html';";
        echo "</script>";
        }   
        else
        {
        echo "<script type='text/javascript'>";
        echo "if(confirm('Something Wrong'))document.location='index.html';else document.location='index.html';";
        echo "</script>";
       
        }
    }
    else
    {

        echo "<script type='text/javascript'>";
        echo "if(confirm('email or name or mobile invalid'))document.location='index.html';else document.location='index.html';";
        echo "</script>";
    }


}
else
{
    echo "<script type='text/javascript'>";
    echo "if(confirm('Fields should not be empty'))document.location='index.html';else document.location='index.html';";
    echo "</script>";

}
?>

Thursday 16 February 2017

Upload imge in database in Project folder Using PHP




HTML FILE

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="barrensavannah.css" />
<title>Clean Pune </title>

<b><u><font size=5 face="italic" color=black width=500><marquee align=top behaviour=slide  bgcolor=orange direction=left width=750 height=25 >WELCOME TO CLEAN PUNE</marquee></font></blink></u></b>


</head>

<body onload="seaproblems()">

<script type="text/javascript">
        function seaproblems()
        {
                var xmlhttp=false;
                if(window.XMLHttpRequest)
                {
                        xmlhttp=new XMLHttpRequest();
                }
                xmlhttp.onreadystatechange=function()
                {
                        if(xmlhttp.readyState==4 && xmlhttp.status==200)
                        {
                                document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
                        }
                }
                xmlhttp.open("GET","seaproblems.php");
                xmlhttp.send();
        }
</script>






    <div id="page">
        <div class="topNaviagationLink"><a href="index.html">Home</a></div>
        <div class="topNaviagationLink"><a href="problems.html">Problems</a></div>
 <div class="topNaviagationLink"><a href="listofcorporators.php">Corporators</a></div>       
<div class="topNaviagationLink"><a href="contact.html">Contact Us</a></div>
<div class="topNaviagationLink"><a href="login.html">Login</a></div>

    </div>
    <div id="mainPicture">
        <div class="picture">
            <div id="headerTitle"></div>
            <div id="headerSubtext"></div>
        </div>
    </div>
        <div class="contentBox">
        <div class="innerBox">
            <h1> Enter your problem here </h1>
          <div class="contentText">
<form action=problem.php method=post enctype="multipart/form-data">   
<table width=680 align=center frame="box">

    <tr><td width="200">   Area</td><td><select name="area">
                <option value="">Select</option>
                <option value="Shaniwar Peth">Shaniwar Peth</option>
                <option value="Rupeenagar-Talawade">Rupeenagar-Talawade </option>
                <option value="Raviwar Peth">Raviwar Peth</option>
                <option value="Chikhali">Chikhali</option>   
                <option value="Krushnanagar">Krushnanagar</option>   
                 </select></td></tr>

    <tr><td>   Description</td><td><textarea rows="5" cols="50" name="desc">
    </textarea></td></tr>

<tr><td>   Upload image:</td><td> <input type="file" name="uploadedimage" id="pic"></td></tr>
</br>

<tr><td></td></tr><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr><tr><td></td><td ><input type="submit" value="Submit" /></td></tr>
</table>
</form>

<div id="txtHint">your problem will be listed here</div>

           </div>
         
         
          <!-- Please leave this in place after all of your content - thanks :) -->
<div id="footer"><a href="http://www.aszx.net"> developed</a> by <a href="http://www.bryantsmith.com">Pooja Shelke & Reshma Shinde</a></div>
<!-- Please leave this in place after all of your content - thanks :) -->
       
       
     </div>

    </div>
       
</body>
</html>




PHP FILE

<?php
include "connect.php";

$parea=$_POST['area'];
$pdesc=$_POST['desc'];


$count=1;
$row=mysql_query("select * from problem");
while($res=mysql_fetch_array($row))
$count=$count+1;


    function GetImageExtension($imagetype)
         {
       if(empty($imagetype)) return false;
       switch($imagetype)
       {
           case 'image/bmp': return '.bmp';
           case 'image/gif': return '.gif';
           case 'image/jpeg': return '.jpg';
           case 'image/png': return '.png';
           default: return false;
       }
     }



if (!empty($_FILES["uploadedimage"]["name"]) && !empty($parea) && !empty($pdesc))
{

        $file_name=$_FILES["uploadedimage"]["name"];
        $temp_name=$_FILES["uploadedimage"]["tmp_name"];
        $imgtype=$_FILES["uploadedimage"]["type"];
        $ext= GetImageExtension($imgtype);
        $imagename=date("d-m-Y")."-".time().$ext;
        $target_path = "images/".$imagename;


    if(move_uploaded_file($temp_name, $target_path))
    {   

            $query_upload="INSERT into problem VALUES($count,'$parea','".$target_path."','$pdesc','".date("Y-m-d")."','Not Solved')";
            //mysql_query($query_upload) or die("error in $query_upload == ----> ".mysql_error());
        if(mysql_query($query_upload))
        {
            echo "<script type='text/javascript'>";
                echo "if(confirm('Your Problem uploaded successfully'))document.location='problems.html';else document.location='problems.html';";
                   echo "</script>";   
       
        }
        else
        {
            echo "<script type='text/javascript'>";
                echo "if(confirm('Your Problem not uploaded'))document.location='problems.html';else document.location='problems.html';";
                   echo "</script>";   
        }

    }
    else
    {

           exit("Error While uploading your problem on the server");
    }
}
else
{
            echo "<script type='text/javascript'>";
                echo "if(confirm('Something Wrong'))document.location='problems.html';else document.location='problems.html';";
                   echo "</script>";   
   
}
?>


Wednesday 15 February 2017

Validation in VB.Net


Imports System.Text.RegularExpressions
Public Class Validation
    Private Sub Validation_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        DateTimePicker1.MaxDate = Today

    End Sub

    Private Sub txtName_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtName.KeyPress
        If e.KeyChar >= "a" And e.KeyChar <= "z" Or e.KeyChar >= "A" And e.KeyChar <= "Z" Or e.KeyChar = " " Or e.KeyChar = Convert.ToChar(Keys.Back) Then
            'nothing to do valid character
        Else
            e.KeyChar = ""
            txtName.Select()
            MsgBox("Enter only Alphabets", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Invalid Input")
        End If
    End Sub

    Private Sub txtMobile_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtMobile.KeyPress
        If e.KeyChar >= "0" And e.KeyChar <= "9" Or e.KeyChar = Convert.ToChar(Keys.Back) Then

        Else
            e.KeyChar = ""
            txtMobile.Select()
            MsgBox("Enter only Numbers", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Invalid Input")
        End If

    End Sub


    Private Sub txtMobile_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtMobile.Leave
        Try

            If txtMobile.Text.Substring(0, 1) >= 7 And txtMobile.Text.Length = 10 Then

            Else

                txtMobile.Select()
                MsgBox("Enter valid mobile", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Invalid Input")
            End If

        Catch ex As Exception
            MsgBox(ex.Message)

        End Try
    End Sub

    Private Sub txtemail_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtemail.Leave
        Dim f As Boolean
        f = Module1.validateEmail(txtemail.Text)
        If f = False Then
            MsgBox("Enter valid Email", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "Invalid Input")
            txtemail.Select()
        End If
    End Sub
    Public Function validateEmail(ByVal emailAddress) As Boolean
        ' Dim email As New Regex("^(?[^@]+)@(?.+)$")
        Dim email As New Regex("([\w-+]+(?:\.[\w-+]+)*@(?:[\w-]+\.)+[a-zA-Z]{2,7})")
        If email.IsMatch(emailAddress) Then
            Return True
        Else
            Return False
        End If
    End Function

End Class