//Config.php
<?php
$cn = mysql_connect('localhost','root','') or die(mysql_error());
if(!$cn)
{
echo "ERROR:not connected";
}
$db = mysql_select_db('info') or die(mysql_error());
if(!$db)
{
echo "ERROR: Not Connected..";
}
?>
//Stud.php
<body>
<form action="" method="post" enctype="multipart/form-data">
<div align="center">
<fieldset>
<legend>Stud-Info</legend>
<div>
<label>userId:-</label>
<label>
<input name="txtid" id="txtid" type="text" readonly="readonly"
/>
</label>
</div>
<div>
<label>Name:-<sup style="color:red">*</sup></label>
<label>
<input name="txtname" id="txtname" type="text" placeholder="Enater Name" />
</label>
</div>
<br/>
<div><input name="txtsignup" type="submit" value="Signup" onclick="return validate() " /></div>
</fieldset>
</div>
<fieldset><legend>Griedview</legend>
<table align="center" border="1"><caption><h3>Griedview</h3></caption>
<tr>
<th>userid</th>
<th>Username</th>
<th>Edit</th>
<th>Delete</th>
</tr>
<?php
$grid=mysql_query("Select * from Registration");
//echo "<table><tr><th>Id</th> <th>name</th></tr>";
while($gr=mysql_fetch_row($grid))
{
echo "<tr>";
echo "<td>$gr[0]</td>";
echo "<td>$gr[1]</td>";
echo "<td><a href=Stud.php?did=$gr[0]>Delete</a></td>";
echo "<td><a href=update.php?uid=$gr[0]>Edit</a></td>";
}
?>
</table>
</fieldset>
</form>
</body>
//validation on head
<script language="javascript" type="text/javascript">
function validate()
{
var x1= document.getElementById("txtname");
if(x1.value.length==0)
{
alert("please Enter UserName");
x1.focus();
return false;
}
}
</script>
<?php
include_once("config.php");
extract($_POST);
if(isset($txtsignup))
{
$res= mysql_query("insert into Registration (userName) Values('$txtname')") or
die(mysql_error());
}
if(isset($_REQUEST['did']))
{
mysql_query("delete from Registration where userId=".$_REQUEST['did']);
}
?>
//Update.php
<?php
include_once("config.php");
if(isset($_REQUEST['uid']))
{
$res=mysql_query("select * from registration where userId=".$_REQUEST['uid']) or die(mysql_error());
$r=mysql_fetch_row($res);
}
if(isset($_POST['submit']))
{
mysql_query("update registration set userName = '".$_POST['fname']."'
where userId='".$_POST['id']."'")or die(mysql_error());
header('location:Stud.php');
}
?>
<br>
<form id="tform" name="frm1" action="" method="post" enctype="multipart/form-data">
<div></div>
<table align="center" border="2">
<h1 align="center">Edit form</h1>
<tr>
<td>id:</td>
<td><input type="text" name="id" id="id" value="<?php echo $r[0];?>" /></td>
</tr>
<tr>
<td>first name:<sup style="color:#C30">*</sup></td>
<td><input type="text" name="fname" id="fname" value="<?php echo $r[1];?>" /></td>
</tr>
<td>
<input type="submit" name="submit" id="submit" value="edit"/>
</td></tr>
</table>
</form>
<?php
$cn = mysql_connect('localhost','root','') or die(mysql_error());
if(!$cn)
{
echo "ERROR:not connected";
}
$db = mysql_select_db('info') or die(mysql_error());
if(!$db)
{
echo "ERROR: Not Connected..";
}
?>
//Stud.php
<body>
<form action="" method="post" enctype="multipart/form-data">
<div align="center">
<fieldset>
<legend>Stud-Info</legend>
<div>
<label>userId:-</label>
<label>
<input name="txtid" id="txtid" type="text" readonly="readonly"
/>
</label>
</div>
<div>
<label>Name:-<sup style="color:red">*</sup></label>
<label>
<input name="txtname" id="txtname" type="text" placeholder="Enater Name" />
</label>
</div>
<br/>
<div><input name="txtsignup" type="submit" value="Signup" onclick="return validate() " /></div>
</fieldset>
</div>
<fieldset><legend>Griedview</legend>
<table align="center" border="1"><caption><h3>Griedview</h3></caption>
<tr>
<th>userid</th>
<th>Username</th>
<th>Edit</th>
<th>Delete</th>
</tr>
<?php
$grid=mysql_query("Select * from Registration");
//echo "<table><tr><th>Id</th> <th>name</th></tr>";
while($gr=mysql_fetch_row($grid))
{
echo "<tr>";
echo "<td>$gr[0]</td>";
echo "<td>$gr[1]</td>";
echo "<td><a href=Stud.php?did=$gr[0]>Delete</a></td>";
echo "<td><a href=update.php?uid=$gr[0]>Edit</a></td>";
}
?>
</table>
</fieldset>
</form>
</body>
//validation on head
<script language="javascript" type="text/javascript">
function validate()
{
var x1= document.getElementById("txtname");
if(x1.value.length==0)
{
alert("please Enter UserName");
x1.focus();
return false;
}
}
</script>
<?php
include_once("config.php");
extract($_POST);
if(isset($txtsignup))
{
$res= mysql_query("insert into Registration (userName) Values('$txtname')") or
die(mysql_error());
}
if(isset($_REQUEST['did']))
{
mysql_query("delete from Registration where userId=".$_REQUEST['did']);
}
?>
//Update.php
<?php
include_once("config.php");
if(isset($_REQUEST['uid']))
{
$res=mysql_query("select * from registration where userId=".$_REQUEST['uid']) or die(mysql_error());
$r=mysql_fetch_row($res);
}
if(isset($_POST['submit']))
{
mysql_query("update registration set userName = '".$_POST['fname']."'
where userId='".$_POST['id']."'")or die(mysql_error());
header('location:Stud.php');
}
?>
<br>
<form id="tform" name="frm1" action="" method="post" enctype="multipart/form-data">
<div></div>
<table align="center" border="2">
<h1 align="center">Edit form</h1>
<tr>
<td>id:</td>
<td><input type="text" name="id" id="id" value="<?php echo $r[0];?>" /></td>
</tr>
<tr>
<td>first name:<sup style="color:#C30">*</sup></td>
<td><input type="text" name="fname" id="fname" value="<?php echo $r[1];?>" /></td>
</tr>
<td>
<input type="submit" name="submit" id="submit" value="edit"/>
</td></tr>
</table>
</form>
No comments:
Post a Comment