All in one Php Integrated Code
<!doctype html>
<?php
/*-----------------------------------CONNECTIVITY CODE-----------------------------------*/
error_reporting(E_ERROR | E_PARSE); //optional,to remove warning messages.
$conn=mysqli_connect("localhost","root","","codershelpline");
if ($conn)
{
echo "database connected successfully","<br>";
}
else
{
die("Connection Aborted:" . mysqli_connect_error());
}
/*-------------------------------- HTML TO PHP TRANSFER CODE--------------------------*/
$TxtSlno1=$_REQUEST['TxtSlno'];
$TxtSname1=$_REQUEST['TxtSname'];
$TxaAddr1=$_REQUEST['TxaAddr'];
$Rdbsex1=$_REQUEST['Rdbsex'];
$TxtUname1=$_REQUEST['TxtUname'];
$TxtPassword1=$_REQUEST['TxtPassword'];
$DtpDob1=$_REQUEST['DtpDob'];
$TxtMobno1=$_REQUEST['TxtMobno'];
$TxtEmail1=$_REQUEST['TxtEmail'];
$CmbSecQues1=$_REQUEST['CmbSecQues'];
$TxtSecAns1=$_REQUEST['TxtSecAns'];
$ChkCricket1=$_REQUEST['ChkCricket'];
$ChkDance1=$_REQUEST['ChkDance'];
$ChkMusic1=$_REQUEST['ChkMusic'];
$TxtRem1=$_REQUEST['TxtRem'];
/*------------------------------ SAVE CODE TO MYSQL DATABASE---------------------------*/
if(isset($_REQUEST['BtnSave']))
{
$qry="select TxtSlno4 from chlsave where TxtSlno4='$TxtSlno1'";
$result=mysqli_query($conn,$qry);
$a=0;
while($row1=mysqli_fetch_array($result))
{
$Sno=$row1['TxtSlno4'];
if($Sno)
{
echo "Sl.No. Already Exist.";
$a=$a+1;
}
}
if($a===0)
{
mysqli_query($conn,"INSERT INTO chlsave(TxtSlno4,TxtSname4,TxaAddr4,Rdbsex4,TxtUname4,
TxtPassword4,DtpDob4,TxtMobno4,TxtEmail4,CmbSecQues4,TxtSecAns4,ChkCricket4,ChkDance4,
ChkMusic4,TxtRem4) VALUES ('$TxtSlno1','$TxtSname1','$TxaAddr1','$Rdbsex1','$TxtUname1',
'$TxtPassword1','$DtpDob1','$TxtMobno1','$TxtEmail1','$CmbSecQues1','$TxtSecAns1',
'$ChkCricket1','$ChkDance1','$ChkMusic1','$TxtRem1')");
if(mysqli_affected_rows($conn) > 0)
{
echo "Data Saved";
}
else
{
echo "Data Not Saved <br/>";
echo mysqli_error($conn);
}
}
}
/*-------------------------------------DELETE CODE------------------------------------*/
if(isset($_REQUEST['BtnDel']))
{
$qry="select TxtSlno4 from chlsave where TxtSlno4='$TxtSlno1'";
$result=mysqli_query($conn,$qry);
$x=0;
while($row1=mysqli_fetch_array($result))
{
$Sno=$row1['TxtSlno4'];
if($Sno)
{
$value="delete from chlsave where TxtSlno4='$TxtSlno1'";
if($conn->query($value)===TRUE)
{
echo "Record Removed ";
}
$x=$x+1;
}
}
if($x===0)
{
echo "Record Not Found.";
}
}
/*-------------------------------------SEARCH CODE------------------------------------*/
$SearchBx1=$_REQUEST['SearchBx'];
if(isset($_REQUEST['BtnSrc']))
{
$query2="select * from chlsave where TxtSlno4='$SearchBx1'";
$result=mysqli_query($conn,$query2);
while($row1=mysqli_fetch_array($result))
{
$TxtSlno3=$row1['TxtSlno4'];
$TxtSname3=$row1['TxtSname4'];
$TxaAddr3=$row1['TxaAddr4'];
$Rdbsex3=$row1['Rdbsex4'];
$TxtUname3=$row1['TxtUname4'];
$TxtPassword3=$row1['TxtPassword4'];
$DtpDob3=$row1['DtpDob4'];
$TxtMobno3=$row1['TxtMobno4'];
$TxtEmail3=$row1['TxtEmail4'];
$CmbSecQues3=$row1['CmbSecQues4'];
$TxtSecAns3=$row1['TxtSecAns4'];
$ChkCricket3=$row1['ChkCricket4'];
$ChkDance3=$row1['ChkDance4'];
$ChkMusic3=$row1['ChkMusic4'];
$TxtRem3=$row1['TxtRem4'];
}
}
/*-------------------------------------UPDATE CODE------------------------------------*/
if(isset($_REQUEST['BtnUpd']))
{
$modify="update chlsave set TxtSname4='$TxtSname1',TxaAddr4='$TxaAddr1',Rdbsex4='$Rdbsex1'
,TxtUname4='$TxtUname1',TxtPassword4='$TxtPassword1',DtpDob4='$DtpDob1',TxtMobno4='$TxtMobno1'
,TxtEmail4='$TxtEmail1',CmbSecQues4='$CmbSecQues1',TxtSecAns4='$TxtSecAns1',ChkCricket4=
'$ChkCricket1',ChkDance4='$ChkDance1',ChkMusic4='$ChkMusic1',TxtRem4='$TxtRem1' where TxtSlno4=
'$TxtSlno1'";
if($conn->query($modify)===TRUE)
{
echo "Record updated";
}
else
{
echo "error update".$conn->error;
}
}
?>
<!--------------------------------HTML DESIGN CODE------------------------------------->
<html>
<head>
<title>Codershelpline Code for display html value</title>
</head>
<body>
<form name="form1" id="form2" action="#" method="post" >
<center>
<fieldset style="width: 600px">
<legend>Create New Student Account</legend>
<table>
<tr>
<td>Serial No.</td>
<td>:</td>
<td><input type="text" name="TxtSlno" value="<?php echo $TxtSlno3;?>"></td>
<td>Search Box</td>
<td>
<select name="SearchBx" id="SearchBx">
<option>---Select---</option>
<?php
$res=mysqli_query($conn,"select TxtSlno4 from chlsave");
while($row=mysqli_fetch_array($res))
{
?>
<option value="<?php echo $row['TxtSlno4'];?>"><?php echo
$row['TxtSlno4'];?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Student Name</td>
<td>:</td>
<td><input type="text" name="TxtSname" value="<?php echo $TxtSname3;?>">
</td>
</tr>
<tr>
<td>Address</td>
<td>:</td>
<td>
<textarea cols="35" rows="5" name="TxaAddr"><?php echo $TxaAddr3;?>
</textarea>
</td>
</tr>
<tr>
<td>Sex</td>
<td>:</td>
<td>
<?php
if($Rdbsex3==="Male")
{
$Gen1="checked";
}
if($Rdbsex3==="Female")
{
$Gen2="checked";
}
if($Rdbsex3==="Other")
{
$Gen3="checked";
}
?>
<input type="radio" name="Rdbsex" id="RdbMale" <?php echo $Gen1;?>
value="Male">Male
<input type="radio" name="Rdbsex" id="RdbFemale" <?php echo $Gen2;?>
value="Female">Female
<input type="radio" name="Rdbsex" id="RdbOther" <?php echo $Gen3;?>
value="Other">Other
</td>
</tr>
<tr>
<td>User Name</td>
<td>:</td>
<td><input type="text" name="TxtUname" value="<?php echo $TxtUname3;?>">
</td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input type="password" name="TxtPassword" value="<?php echo
$TxtPassword3;?>"></td>
</tr>
<tr>
<td>Confirm Password</td>
<td>:</td>
<td><input type="password" name="TxtCpassword" value="<?php echo
$TxtCpassword3;?>"></td>
</tr>
<tr>
<td>DOB</td>
<td>:</td>
<td><input type="date" name="DtpDob" value="<?php echo $DtpDob3;?>"></td>
</tr>
<tr>
<td>Mobile No.</td>
<td>:</td>
<td><input type="Number" name="TxtMobno" value="<?php echo $TxtMobno3;?>">
</td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input type="text" name="TxtEmail" value="<?php echo $TxtEmail3;?>">
</td>
</tr>
<tr>
<td>Security Questions</td>
<td>:</td>
<td>
<?php
if($CmbSecQues3==="What is Your Favourite Book")
{
$SecQues1="selected";
}
if($CmbSecQues3==="What is Your Favourite Teacher")
{
$SecQues2="selected";
}
if($CmbSecQues3==="What is Your Favourate Place")
{
$SecQues3="selected";
}
if($CmbSecQues3==="What is Your Favourate Pets")
{
$SecQues4="selected";
}
?>
<select name="CmbSecQues">
<option value="Choose One">Choose One</option>
<option <?php echo $SecQues1;?> value="What is Your Favourite Book">
What is Your Favourite Book</option>
<option <?php echo $SecQues2;?> value="What is Your Fav. Teacher">
What is Your Favourite Teacher</option>
<option <?php echo $SecQues3;?> value="What is Your Favourate Place">
What is Your Favourate Place</option>
<option <?php echo $SecQues4;?> value="What is Your Favourate Pets">
What is Your Favourate Pets</option>
</select>
</td>
</tr>
<tr>
<td>Security Answer</td>
<td>:</td>
<td><input type="text" name="TxtSecAns" value="<?php echo $TxtSecAns3;?>">
</td>
</tr>
<tr>
<td>Hobbies</td>
<td>:</td>
<td>
<?php
if($ChkCricket3==="Cricket")
{
$Ckt="checked";
}
if($ChkDance3==="Dance")
{
$Dnc="checked";
}
if($ChkMusic3==="Music")
{
$Msc="checked";
}
?>
<input type="checkbox" name="ChkCricket" <?php echo $Ckt;?> value=
"Cricket">Cricket
<input type="checkbox" name="ChkDance" <?php echo $Dnc;?> value=
"Dance">Dance
<input type="checkbox" name="ChkMusic" <?php echo $Msc;?> value=
"Music">Music
</td>
</tr>
<tr>
<td>Remarks</td>
<td>:</td>
<td><input type="text" name="TxtRem" value="<?php echo $TxtRem3;?>"></td>
</tr>
<tr>
<td></td>
<td></td>
<td><input type="submit" name="BtnSave" value="Save">
<input type="reset" name="BtnReset" value="Reset">
<input type="submit" name="BtnDel" value="Delete">
<input type="submit" name="BtnSrc" value="Search">
<input type="submit" name="BtnUpd" value="Update">
</td>
</tr>
</table>
</fieldset>
</center>
</form>
</body>
</html>
0 Comments