<?php
session_start();
mysql_connect('localhost','root');
mysql_select_db('ibuyhome');
$query="select name,address,email,contact from property_owner where owner_id=".$_SESSION['id'];
$row=mysql_query($query);
$result=mysql_fetch_array($row);
if(isset($_POST['click']))
{
$query="update property_owner set name='".$_POST['name']."',address='".$_POST['address']."',email='".$_POST['emailid']."',contact='".$_POST['contact']."' where owner_id=".$_SESSION['id'];
$k=mysql_query($query);
if($k)
{
echo("information updated");
header('location:dashowner1.php');
}
else
{
mysql_error();
}
}
?>
<html>
<head>
<script type="text/javascript">
function chk()
{
if(chk1() && chk2())
{
if(chk3())
{
if(chk4())
{
if(chk5())
{
return true;
}
}
}
}
return false;
}
function chk1()
{
var elem=document.getElementById("txt1");
if(elem.value=="")
{
document.getElementById("a").innerHTML="please enter name!";
return false;
}
else
{
document.getElementById("a").innerHTML="";
return true;
}
}
function chk2()
{
var elem=document.getElementById("txt1");
var alphaExp=/^[a-zA-Z]+$/;
if(elem.value.match(alphaExp))
{
document.getElementById("a").innerHTML="";
return true;
}
else
{
document.getElementById("a").innerHTML="please enter only alphabets!";
elem.focus();
return false;
}
}
function chk3()
{
var elem=document.getElementById("txt2");
if(elem.value=="")
{
document.getElementById("b").innerHTML="please enter name!";
return false;
}
else
{
document.getElementById("b").innerHTML="";
return true;
}
}
function chk4()
{
var elem=document.getElementById("txt3");
var alphaExp = /^([A-Za-z0-9\-\.\_])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if(elem.value.match(alphaExp))
{
document.getElementById("c").innerHTML="";
return true;
}
else
{
document.getElementById("c").innerHTML="please enter valid email!";
elem.focus();
return false;
}
}
function chk5()
{
var elem=document.getElementById("txt4");
var alphaExp=/^\d{10}$/;
if(elem.value.match(alphaExp))
{
document.getElementById("d").innerHTML="";
return true;
}
else
{
document.getElementById("d").innerHTML="enter mobile no of 10 digits !";
elem.focus();
return false;
}
}
</script>
</head>
<body><div>
<form method="post" onsubmit="return chk();"/>
<table border="0">
<tbody>
<tr>
<td>NAME:</td>
<?php "<td><input type='text' name='name' id='txt1' value=".$result['name']." /><span id='a'></span></td>";?>
</tr>
<tr>
<td>ADDRESS:</td>
<?php "<td><input type='text' name='address' id='txt2' value=".$result['address']." /><span id='b'></span></td>";?>
</tr>
<tr>
<td>EMAIL-ID:</td>
<?php "<td><input type='text' name='emailid' id='txt3' value=".$result['email']." /><span id='c'></span></td>";?>
</tr>
<tr>
<td>CONTACT:</td>
<?php "<td><input type='text' name='contact' id='txt4' value=".$result['contact']." /><span id='d'></span></td>";?>
</tr>
<tr>
<td><input type="submit" value="UPDATE" name="click" /></td>
<td><input type="reset" value="CANCEL" /></td>
</tr>
</tbody>
</table>
</form>
</div>
</body>
</html>
session_start();
mysql_connect('localhost','root');
mysql_select_db('ibuyhome');
$query="select name,address,email,contact from property_owner where owner_id=".$_SESSION['id'];
$row=mysql_query($query);
$result=mysql_fetch_array($row);
if(isset($_POST['click']))
{
$query="update property_owner set name='".$_POST['name']."',address='".$_POST['address']."',email='".$_POST['emailid']."',contact='".$_POST['contact']."' where owner_id=".$_SESSION['id'];
$k=mysql_query($query);
if($k)
{
echo("information updated");
header('location:dashowner1.php');
}
else
{
mysql_error();
}
}
?>
<html>
<head>
<script type="text/javascript">
function chk()
{
if(chk1() && chk2())
{
if(chk3())
{
if(chk4())
{
if(chk5())
{
return true;
}
}
}
}
return false;
}
function chk1()
{
var elem=document.getElementById("txt1");
if(elem.value=="")
{
document.getElementById("a").innerHTML="please enter name!";
return false;
}
else
{
document.getElementById("a").innerHTML="";
return true;
}
}
function chk2()
{
var elem=document.getElementById("txt1");
var alphaExp=/^[a-zA-Z]+$/;
if(elem.value.match(alphaExp))
{
document.getElementById("a").innerHTML="";
return true;
}
else
{
document.getElementById("a").innerHTML="please enter only alphabets!";
elem.focus();
return false;
}
}
function chk3()
{
var elem=document.getElementById("txt2");
if(elem.value=="")
{
document.getElementById("b").innerHTML="please enter name!";
return false;
}
else
{
document.getElementById("b").innerHTML="";
return true;
}
}
function chk4()
{
var elem=document.getElementById("txt3");
var alphaExp = /^([A-Za-z0-9\-\.\_])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if(elem.value.match(alphaExp))
{
document.getElementById("c").innerHTML="";
return true;
}
else
{
document.getElementById("c").innerHTML="please enter valid email!";
elem.focus();
return false;
}
}
function chk5()
{
var elem=document.getElementById("txt4");
var alphaExp=/^\d{10}$/;
if(elem.value.match(alphaExp))
{
document.getElementById("d").innerHTML="";
return true;
}
else
{
document.getElementById("d").innerHTML="enter mobile no of 10 digits !";
elem.focus();
return false;
}
}
</script>
</head>
<body><div>
<form method="post" onsubmit="return chk();"/>
<table border="0">
<tbody>
<tr>
<td>NAME:</td>
<?php "<td><input type='text' name='name' id='txt1' value=".$result['name']." /><span id='a'></span></td>";?>
</tr>
<tr>
<td>ADDRESS:</td>
<?php "<td><input type='text' name='address' id='txt2' value=".$result['address']." /><span id='b'></span></td>";?>
</tr>
<tr>
<td>EMAIL-ID:</td>
<?php "<td><input type='text' name='emailid' id='txt3' value=".$result['email']." /><span id='c'></span></td>";?>
</tr>
<tr>
<td>CONTACT:</td>
<?php "<td><input type='text' name='contact' id='txt4' value=".$result['contact']." /><span id='d'></span></td>";?>
</tr>
<tr>
<td><input type="submit" value="UPDATE" name="click" /></td>
<td><input type="reset" value="CANCEL" /></td>
</tr>
</tbody>
</table>
</form>
</div>
</body>
</html>
0 comments:
Post a Comment