Wednesday 5 October 2016

coreemp.php

<?php
session_start();
if(!$_SESSION['user'])
{
header("Location:login.php");
}

if(isset($_SESSION['user']))
{
echo "Welcome ".$_SESSION['user'];
}

include('config.php');

if(isset($_REQUEST['btn_sub']))
{
$user=$_REQUEST['txt_user'];
$pwd=$_REQUEST['txt_pwd'];
$address=$_REQUEST['txt_address'];
$state=$_REQUEST['drp1'];
$city=$_REQUEST['drp2'];
$email=$_REQUEST['txt_email'];

$query = "SELECT 1 FROM registration WHERE email = '$email'";
    $abc = mysql_query($query);
if(mysql_num_rows($abc)>0)
    {
        die('email already exists');
    }
$date=$_REQUEST['txt_date'];
$phone=$_REQUEST['txt_phone'];
$gender=$_REQUEST['gender'];
$hobby=implode(",",$_REQUEST['hobby']);
$photo=$_FILES['f1']['name'];
move_uploaded_file($_FILES['f1']['tmp_name'],"upload/$photo");

//$photo=$_FILES['f1']['name'];
// move_uploaded_file($_FILES['f1']['tmp_name'],"upload/$photo");

$reg=mysql_query("Insert into registration
(userName,password,Address,state,city,email,date,phoneNo,gender,hobby,Photo)
values
('$user','$pwd','$address','$state','$city','$email','$date','$phone','$gender','$hobby','$photo')") or die( mysql_error());

  if($reg)
{
$found="N";
}
}

if(isset($_REQUEST['did']))
{

mysql_query("delete from registration where userId=".$_REQUEST['did']);
// unlink("upload/".$query);

}

?>
<!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>Employee Form</title>
<style>
.msg
{
color:#0C0;
}

</style>
<a href="logut.php">Logut</a>

<script>function submitform()
{
document.getElementById("Form1").submit();
alert("your form submitted");
}
</script>

<script language="javascript" type="application/javascript">

function validate()
{
  var user=document.getElementById("txt_user");
   if(user.value.length==0)
{
  alert("plese enter Username");
  user.focus();
  return false;
}
var pwd=document.getElementById("txt_pwd");
if(pwd.value.length==0)
{
alert("Please Enter Password..");
pwd.focus();
return false;
}
var cnfpwd=document.getElementById("txt_cnfpwd");
if(cnfpwd.value != pwd.value)
{
alert("Password And Confirm Password Must be Same..");
pwd.focus();
return false;
}
var email=document.getElementById("txt_email");
if(email.value.length==0)
{
alert("Please Enter The Email Address");
email.focus();
return false;
}
var phone=document.getElementById("txt_phone");
if(phone.value.length==0)
{
alert("Enter The Contact No");
phone.focus();
return false;
}

}

</script>
</head>

<body>

<form action="" method="post" name="Form1" enctype="multipart/form-data">
  <fieldset id="Field1">
    <legend>Registration</legend>
    <table width="200" border="0" align="center">
      <caption align="center" style="font-family:Verdana, Geneva, sans-serif">
      RegistrationForm
        </br>
      </caption>
     
      <tr>
        <td>Userid:-</td>
        <td><input name="txt_id" type="text" readonly="readonly" value="<?php

?>" size="5" /></td>
      </tr>
   
      <tr>
        <td>UserName:-</td>
        <td><input name="txt_user" id="txt_user" type="text" size="30" placeholder="Enter Your Name" /></td>
      </tr>
   
      <tr>
        <td>Password:-</td>
 <td><input name="txt_pwd" id="txt_pwd" type="password" size="30" placeholder="Enter Your Password" /></td>
      </tr>
     
      <tr>
        <td>cnfpassPassword:-</td>
        <td><input name="txt_cnfpwd" id="txt_cnfpwd" type="password" size="30" placeholder="Enter Your cnfPassword" /></td>
      </tr>
      <tr>
        <td>Address:-</td>
        <td><textarea id="txt_address" name="txt_address" placeholder="Enter Your Address" rows="4" cols="23" ></textarea></td>
      </tr>
     
      <tr>
        <td>State:-</td>
        <td><select name="drp1" id="drp1" onFocus="message('Field of choice')" >
            <option value="Select" selected="selected">--Select--</option>
            <option value="Gujarat">Gujarat</option>
            <option value="Maharashtra">Maharashtra</option>
            <option value="Goa">Goa</option>
            <option value="Assam">Assam</option>
            <option value="Bihar">Bihar</option>
            <option value="Arunachal Pradesh">Arunachal Prdesh</option>
            <option value="Uttar Pradesh">Uttar Prdesh</option>
            <option value="Madhya Pradesh">Madhya Prdesh</option>
            <option value="Andhra Pradesh">Andhra Prdesh</option>
          </select></td>
      </tr>
   
      <tr>
        <td>City:-</td>
        <td><select name="drp2" id="drp2" >
            <option value="--Select--" selected="selected" onfocus="Select" >--Select--</option>
            <option value="Gandhinagar">Gandhinagar</option>
            <option value="Mumbai">Mumbai</option>
            <option value="Panji">Panji</option>
            <option value="Dispur">Dispur</option>
            <option value="Patna">Patna</option>
            <option value="Itanagar">Itanagar</option>
            <option value="Lucknow">Lucknow</option>
            <option value="Bhopal">Bhopal</option>
            <option value="Vijaywada">Vijaywada</option>
          </select></td>
      </tr>
   
      <tr>
        <td>Email:-</td>
        <td><input name="txt_email" id="txt_email" type="text" placeholder="Enter Your Email" size="30" /></td>
      </tr>
     
      <tr>
        <td>DateOfBirth</br>
          (yyyy-mm-dd):-</td>
        <td><input type="date" id="txt_date" placeholder="Enter Your DateOfBirth" name="txt_date"></td>
      </tr>
   
      <tr>
        <td>PhoneNo:-</td>
        <td><input name="txt_phone" id="txt_phone" type="text" placeholder="Enter Your PhoneNo" size="30" /></td>
      </tr>
   
       <tr>
        <td>Gender:-</td>
        <td>
            <label>
              <input type="radio" name="gender" value="Male" checked="checked" id="RadioGroup1_0" />
              Male</label>
            <br />
            <label>
              <input type="radio" name="gender" value="Female" id="RadioGroup1_1" />
              Female</label>
            <br />
          </td>
      </tr>
   
      <tr>
        <td> Hobby:-</td>
        <td>
            <label>
              <input type="checkbox" name="hobby[]" value="Cricket" />
              Cricket</label>
            <label>
              <input type="checkbox" name="hobby[]" value="Tennis"  />
              Tennis</label>
            <label></br>
              <input type="checkbox" name="hobby[]" value="Football" />
              Football</label>
            <label>
              <input type="checkbox" name="hobby[]" value="Hocky"/>
              Hocky</label>
            <br />
          </td>
      </tr>
   
      <tr>
      <td>Photo:-</td>
<td>
      <input type="file" name="f1" id="f1" placeholder="Enter Your Photo"/></td>
      </tr>
      <tr>
        <td align="center"><input name="btn_sub" type="submit" value="SignUp" onclick="return validate()" /></td>
     
      <!--
<div onclick="submitform()" style="color:blue;">Submit the form by clicking this</div>
       -->
       
        <td align="left"><input name="btn_reset" type="reset" value="Reset"/></td>
      </tr>
       <tr>
      <td colspan="2" >
         <strong class="msg">
<?php
 if(isset($found))
 {
echo "Data Insert Succsessfully..";
 }
 ?></strong></td>
        </tr>
    </table>
  </fieldset>
 
    <fieldset><legend>DataGridview</legend>
  <table align="center" border="1">
  <caption><h3>Registration Form</h3></caption>
  <tr>
  <th>UserId</th>
  <th>UserName</th>
  <th>Password</th>
  <th>Address</th>
  <th>State</th>
  <th>City</th>
  <th>Email</th>
  <th>DateOfBirth</th>
  <th>PhoneNo.</th>
  <th>Gender</th>
  <th>Hobby</th>
  <th>Photo</th>
 
<th>Edit</th>
<th>Delete</th>
 </tr>

 <?php
 $query= mysql_query("select * from registration");
 $no=1;

 while($row=mysql_fetch_array($query))
 { ?>
  <tr>
   <td><?php echo $row['userId'] ?></td>
        <td><?php echo $row['userName'] ?></td>
        <td><?php echo $row['password'] ?></td>
        <td><?php echo $row['Address'] ?></td>
        <td><?php echo $row['state'] ?></td>
        <td><?php echo $row['city'] ?></td>
        <td><?php echo $row['email'] ?></td>
<td><?php echo $row['date'] ?></td>
        <td><?php echo $row['phoneNo'] ?></td>
        <td><?php echo $row['gender'] ?></td>
        <td><?php echo $row['Hobby'] ?></td>
<td><img src="upload/<?php echo $row['Photo'];?>" width="80" height="80" title="<?php echo $row['Photo'];?>"/> </td>
<td><a href="edit.php?eid=<?php echo $row['userId'];?>">Edit</a></td>
        <td><a href="emp.php?did=<?php echo $row['userId'];?>" onclick="return confirm('Are you Sure Delete?')">Delete</a></td>
    </tr>
 <?php
 $no++;
 }
 ?></table>
 </fieldset>
    </form>


</body>
</html>

No comments:

Post a Comment