NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

check.php

<?php
$con= mysqli_connect("localhost","root","","sudipto2");

if(mysqli_connect_errno()){
echo "Error" . mysqli_error();
}
else{
//echo "Checked";
}

?>


index.php


<?php
include('check.php');

if(isset($_POST['Submit'])){
if(count($_POST['subjects'] > 0)){
$var='';
foreach($_POST['subjects'] as $aj){
$var .=$aj.',';
}
$var=rtrim($var,',');
}

$exist = mysqli_query($con, "select name from tuition where name='".$_POST['name']."'");
$result= mysqli_num_rows($exist);

if($result > 0)
{
echo " name already exists";
}
else
{
$insr= "insert into tuition set
name = '".$_POST['name']."',
gender = '".$_POST['gender']."',
email_id = '".$_POST['email_id']."',
phone_no = '".$_POST['phone_no']."',
subjects = '".$var."',
website = '".$_POST['website']."'";

if(mysqli_query($con, $insr)){
echo "data inserted";
}
else{
echo "Error" . mysqli_error($con);
}
}


}

?>

<form action="" method="POST">
<fieldset>

<b>Name</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="name"><br><br>

<b>Gender</b>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="gender" value="1">Male<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="gender" value="2">Female<br><br>

<b>Email Id</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="email_id"><br><br>

<b>Contact No.</b>&nbsp;
<input type="int=15" name="phone_no"><br><br>

<b>Subjects</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="checkbox" name="subjects[]" value="1">Physics</option>
<input type="checkbox" name="subjects[]" value="2">Chemistry</option>
<input type="checkbox" name="subjects[]" value="3">Biology</option>
<input type="checkbox" name="subjects[]" value="4">Maths</option><br><br><br>

<b>Website</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="website"><br><br><br>


<input type="submit" name="Submit" value="Submit"><br><br>


</fieldset>
</form>


listing.php

<!DOCTYPE html>
<html>
<head>
<style>

th,td{
border: 1px solid red;
padding: 5x;
}
th,td{
text-align: center;
}
th{
background-color: grey;
color: white;
}

</style>
</head>

<table style="width:50%">
<thead>
<caption>Class Registration</caption>
<tr>
<th>Name</th>
<th>Gender</th>
<th>E-mail Id</th>
<th>Contact No.</th>
<th>Subjects</th>
<th>Website</th>
<th>Action</th>
<th>Delete</th>
</tr>
</thead>

<tbody>

<?php
include('check.php');

$sql= "select id, name, gender, phone_no, subjects from tuition";
$result= mysqli_query($con, $sql);
//mysqli_num_rows($result);
if(mysqli_num_rows($result) > 0){
while($row= mysqli_fetch_array($result))
{

$sub = (explode(",",$row['subjects']));
$ac='';
if(count($sub) > 0)
{
foreach($sub as $dx){
if($dx == "1"){ $ac.= "Physics, ";}
elseif($dx == "2"){ $ac.= "Chemistry, ";}
elseif($dx == "3"){ $ac.= "Biology, ";}
elseif($dx == "4"){ $ac.= "Maths, ";}
}
$ac=rtrim($ac,', ');
}
?>

<tr>
<td><?php echo $row["name"]?></td>
<td><?php if ($row["gender"] == "1"){ echo "Male";}
elseif ($row["gender"] == "2"){ echo "Female";}
?></td>
<td><?php echo $row["email_id"]?></td>
<td><?php echo $row["phone_no"]?></td>
<td><?php echo $ac; ?></td>
<td><?php echo $row["website"]?></td>
<td><a href="editing.php?id=<?php echo $row['id']?>">Edit</a></td>
<td><a href="deleting.php?id=<?php echo $row['id']?>">Delete</a></td>
</tr>

<?php
}
}
else{
echo "Retry";
}
?>
</tbody>
</table>
</html>


editing.php


<?php

include('check.php');
$qry= "select name, gender, phone_no, subjects from tuition where id=$_GET[id]";
$result= mysqli_query($con, $qry);
$row= mysqli_fetch_array($result);

$subjects= explode(',',$row['subjects']);

if(isset($_POST['Submit']))
{
$exist = mysqli_query($con, "select name from tuition where name='".$_POST['name']."' && id<>$_GET[id]");
$result= mysqli_num_rows($exist);

if($result > 0)
{
echo " name already exists";
}
else
{

$updt = "update tuition set
name = '".$_POST['name']."',
gender = '".$_POST['gender']."',
email_id = '".$_POST['email_id']."',
phone_no = '".$_POST['phone_no']."',
subjects = '".implode(',',$_POST['subjects'])."',
website = '".$_POST['website']."'
where id = '".$_GET['id']."'";

if(mysqli_query($con, $updt))
{
echo "Data Inserted";
//header('Location: listing.php');
}
else{
echo "Error" . mysqli_error($con);
}
}
}
?>

<form action="" method="POST">
<fieldset>
<p id="msg"></p>
<b>Name</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="name" id="name" value="<?php echo $row["name"]?>"><br><br>

<b>Gender</b>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="gender" value="1" <?php echo $row['gender'] === '1' ? 'checked="checked"':'' ?>/>Male<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="gender" value="2" <?php echo $row['gender'] === '2' ? 'checked="checked"':'' ?>/>Female<br><br>

<b>Email Id</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="email_id" id="email_id" value="<?php echo $row["email_id"]?>"><br><br>

<b>Contact No.</b>
<input type="int=15" name="phone_no" id="phone_no" value="<?php echo $row["phone_no"]?>"><br><br>

<b>Subjects</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="checkbox" name="subjects[]" value="1" <?php if(in_array("1",$subjects)) { echo "checked='checked'";} ?>/>Physics</option>
<input type="checkbox" name="subjects[]" value="2" <?php if(in_array("2",$subjects)) { echo "checked='checked'";} ?>/>Chemistry</option>
<input type="checkbox" name="subjects[]" value="3" <?php if(in_array("3",$subjects)) { echo "checked='checked'";} ?>/>Biology</option>
<input type="checkbox" name="subjects[]" value="4" <?php if(in_array("4",$subjects)) { echo "checked='checked'";} ?>/>Maths</option><br><br><br>

<b>Website</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="text" name="website"><br><br><br>

<input type="submit" name="Submit" id="btnSubmit" value="Submit"><br><br>

</fieldset>
</form>

<script src="jquery.min.js"></script>
<script>
$(function(){
$('#btnSubmit').click(function(){
var email = $('#email_id').val();
if ($.trim(email).length == 0 || $("#name").val()=="" || $("#phone_no").val()=="")
{
alert('Name, Email and Phone no. are mandatory');
e.preventDefault();
}
if (validateEmail(email))
{
alert('Your Email is valid, Please continue..');
}
else{
alert('Invalid Email Address');
e.preventDefault();
}
});
});

function validateEmail(email) {
var filter = /^[w-.+]+@[a-zA-Z0-9.-]+.[a-zA-z0-9]{2,4}$/;
if (filter.test(email)) {
return true;
}
else {
return false;
}
}

</script>


deleting.php


<?php
include('check.php');

if(isset($_GET['id'])){
$del= " delete from tuition where id ='".$_GET['id']."'";

if(mysqli_query($con, $del))
{
header('Location: listing.php');
}
else
{
echo "Error" . mysqli_error($con);
}
}

?>
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.