108PHP
108PHP
108PHP
-108
Create a website in PHP which have following pages.User Registration Page : (Apply proper validation)
Name: (*Only alphabet a(A) to z(Z) and space is allowed)
Password: (*Password must be between 5 to 10 characters)
Retype Password:
Mobile Number: (*Only 10 digit number is allowed) Hobbies: (Use checkbox)
Gender: (Use radio button)
City : (Use drop down select)
Home Address: (Use textarea)
Email Id : (*properemail address allowed)
Photo Upload : (*Must be less than 100kb)
User Home Page :Display user data (registration data of user) with his/her photo who have just login.
Put link or button, click on which open edit page to edit data. (Email Id cannot change) èLogout link (destroysession
variable)
Admin Home Page :Display all users registration data (Whole table) with photo, edit and delete links with each record.
Also all column namemust have order link.Search data (Use Ajax)
REGISTRATION :
<html>
<body>
<?php
$nm=$p1=$p2=$mb=$gender=$hb1=$hb2=$hb3=$hb4=$hb=$ct=$ad=$email=$image="";
$nmErr=$p1Err=$p2Err=$mbErr=$genderErr=$hbErr=$ctErr=$adErr=$emailErr=$imageErr="";
if(isset($_POST['btnsub']))
{
$nm = $_POST['nam'];
if(empty($nm))
{
$nmErr = "* Name is required";
}
else
{
if (!preg_match ("/^[a-zA-Z\s]*$/", $nm) )
{
$nmErr = "Only alphabat charaters is allowed.";
}
}
$p1 = $_POST['pass1'];
if(empty($p1))
{
$p1Err = "* Password is required";
}
else
{
if(strlen($p1)<8)
$p1Err = "* Length of password must be minimum of 8 characters";
}
$p2 = $_POST['pass2'];
if(empty($p2))
{
$p2Err = "* Retype password is required";
}
1
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
else
{
if($p1!=$p2)
$p2Err = "* Password not match. Try again.";
}
$mb = $_POST['mob'];
if(empty($mb))
{
$mbErr = "* Mobile number is required";
}
else
{
if (!preg_match ("/^[0-9]*$/", $mb) )
{
$mbErr = "* Only numeric value is allowed.";
}
else
{
if (strlen($mb) != 10)
{
$mbErr = "* Mobile no. must contain 10 digits.";
}
}
}
if(isset($_POST['gender']))
$gender = $_POST['gender'];
if(empty($gender))
{
$genderErr = "* Subject must have to select";
}
if(isset($_POST['hb1'])) { $hb1 =
$_POST['hb1'];
$hb = "$hb1";
}
if(isset($_POST['hb2'])) {
if ($hb!="") {
$hb .= " ,";
}
$hb2 = $_POST['hb2'];
$hb .= "$hb2";
}
if(isset($_POST['hb3'])) {
if ($hb!="") {
$hb .= " ,";
}
$hb3 = $_POST['hb3'];
$hb .= "$hb3";
}
if(isset($_POST['hb4'])) {
if ($hb!="") {
$hb .= " ,";
}
$hb4 = $_POST['hb4'];
$hb .= "$hb4";
}
if($hb=="") {
$hbErr = "* Must have to select at least one hobby";
}
$ct = $_POST['city'];
if(empty($ct) or $ct=='select')
{
2
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
$ctErr = "* Please select any one city";
}
$ad = $_POST['addr'];
if(empty($ad))
{
$adErr = "* Address is required.";
}
else
{
if(!preg_match('/^[A-Za-z0-9\-,.\s]+$/',$ad))
$adErr = "* special charaters not allow";
}
$email = $_POST['email'];
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
$emailErr = "Invalid Email Format! <br>";
}
if(isset($_FILES['image'])){
$file_ext=explode('.',$_FILES['image']['name']);
$file_ext=end($file_ext);
$file_ext=strtolower($file_ext);
$image = $email.".".$file_ext;
if($nmErr=="" and $emailErr=="" and $p1Err=="" and $p2Err=="" and $mbErr=="" and $genderErr=="" and
$hbErr=="" and $ctErr=="" and $adErr=="" and $imageErr=="" and isset($_POST['btnsub']))
{
move_uploaded_file($_FILES['image']['tmp_name'],"images/$image");
$query_str =
"btnsub=Submit&nam=$nm&pass1=$p1&mob=$mb&gender=$gender&city=$ct&addr=$ad&email=$email
&hb=$hb&image=$image";
header("location:regdatastore.php?$query_str");
}
}
?>
<form action="" method="POST" enctype="multipart/form-data">
<table border="5px" style="margin:auto;border-collapse:collapse;">
<tr>
<td></td>
<td><b>Registration Page</b></td>
<td></td>
</tr>
<tr>
<td>Enter Name:</td>
<td><input type="text" name="nam" id="nam" value="<?php echo $nm; ?>"></td>
<td><?php echo $nmErr;?></td>
</tr>
<tr>
<td>Enter Password:</td>
<td><input type="password" name="pass1" id="pass1" value=<?php echo $p1;?>></td>
3
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
<td><?php echo $p1Err;?></td>
</tr>
<tr>
<td>Retype Password:</td>
<td><input type="password" name="pass2" id="pass2" value=<?php echo $p2;?>></td>
<td><?php echo $p2Err;?></td>
</tr>
<tr>
<td>Enter Mobile:</td>
<td><input type="text" name="mob" id="mob" value=<?php echo $mb;?>></td>
<td><?php echo $mbErr;?></td>
</tr>
<tr>
<td>Select Hobbies:</td>
<td>
<input type="checkbox" name="hb1" id="hb1" value="Travelling" <?php if($hb1!="") echo "checked"
?>>Travelling
<input type="checkbox" name="hb2" id="hb2" value="Sports" <?php if($hb2!="") echo "checked" ?>>Sports
<input type="checkbox" name="hb3" id="hb3" value="Computers"
<?php if($hb3!="") echo "checked" ?>>Computers
<input type="checkbox" name="hb4" id="hb4" value="Arts & Music"
<?php if($hb4!="") echo "checked" ?>>Arts & Music
</td>
<td><?php echo $hbErr;?></td>
</tr>
<tr>
<td>Select Gender:</td>
<td>
<input type="radio" name="gender" id="gender" value="Male" <?php if($gender=='Male') echo "checked" ?>>Male
<input type="radio" name="gender" id="gender" value="Female"
<?php if($gender=='Female') echo "checked" ?>>Female
</td>
<td><?php echo $genderErr;?></td>
</tr>
<tr>
<td>City:</td>
<td>
<select name="city" id="city">
<option value="select" <?php if($ct=="select")echo "selected";
?>>---select---</option>
<option value="surat" <?php if($ct=='surat') echo "selected";
?>>surat</option>
<option value="ahmedabad" <?php if($ct=='ahmedabad') echo
"selected"; ?>>ahmedabad</option>
<option value="baroda" <?php if($ct=='baroda') echo
"selected"; ?>>baroda</option>
</select>
</td>
<td><?php echo $ctErr;?></td>
</tr>
<tr>
<td>Address:</td>
<td><textarea name="addr" id="addr"><?php echo $ad;?></textarea></td>
<td><?php echo $adErr;?></td>
<tr>
<tr>
<td>Enter Email Id:</td>
<td><input type="email" name="email" id="email" value="<?php echo $email; ?>"></td>
<td><?php echo $emailErr;?></td>
</tr>
4
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
<tr>
<td>Photo Upload:</td>
<td><input type="file" name="image" id="image"></td>
<td><?php echo $imageErr;?></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="btnsub"></td>
<td></td>
<tr>
</table>
</form>
</body>
</html>
REGISTRATIONDATASTORE :
<?php
$nm=$p1=$mb=$gender=$hb=$h4=$ct=$ad=$email=$image=""; if(isset($_GET['btnsub']))
{
$nm = $_GET['nam'];
$p1 = $_GET['pass1'];
$mb = $_GET['mob'];
$hb = $_GET['hb'];
$gender = $_GET['gender'];
$ct = $_GET['city'];
$ad = $_GET['addr'];
$email = $_GET['email'];
$image = $_GET['image'];
$conn = mysqli_connect("localhost","root","","db1");
$sql = "insert into REGISTRATION
(name,pass,mobile,hobbies,gender,city,address,email,image)
values('$nm','$p1','$mb','$hb','$gender','$ct','$ad','$email','$image')"; try {
mysqli_query($conn,$sql);
echo "<center>Data inserted successfully</center>";
}
catch(Exception $e) { if
($e->getCode() == 1062)
echo '<center>Your email is already registered plz try another email address or login</center>';
}
echo "<cener><form action='loginpage.php'>";
echo "<center><input type='submit' name='btnsub' value='Go to Login page'></center>"; echo
"</form></center>";
}
?>
5
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
LOGINPAGE :
<html>
<body>
<?php
$p1=$email="";
$p1Err=$emailErr="";
if(isset($_POST['btnsub']))
{
$p1 = $_POST['pass1'];
if(empty($p1))
{
$p1Err = "* Password is required";
}
else
{
if(strlen($p1)<8)
$p1Err = "* Length of password must be minimum of 8 characters";
}
$email = $_POST['email'];
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
$emailErr = "Invalid Email Format! <br>";
}
$conn = mysqli_connect("localhost","root","","db1");
$sql = "select * from REGISTRATION"; $res =
mysqli_query($conn,$sql);
while($row=mysqli_fetch_assoc($res)) {
if ($row['email']==$email) {
$emailErr = "";
if($row['pass']==$p1) {
$query_str = "btnsub=Submit &email=$email";
$_SESSION['email']=$email;
$_SESSION['pass']=$p1;
header("location:userhomepage.php?$query_str");
}
else{
$p1Err = "* Wrong password plz try again";
}
break;
}
else {
$emailErr = "* Email not found.";
}
}
}
?>
<form action="" method="POST" enctype="multipart/form-data">
<table border="5px" style="margin:auto;border-collapse:collapse;">
<tr>
<td></td>
<td><b>Login Page</b></td>
<td></td>
</tr>
<tr>
<td>Enter Email Id:</td>
<td><input type="email" name="email" id="email" value="<?php echo $email; ?>"></td>
<td><?php echo $emailErr;?></td>
</tr>
6
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
<tr>
<td>Enter Password:</td>
<td><input type="password" name="pass1" id="pass1" value=<?php echo $p1;?>></td>
<td><?php echo $p1Err;?></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="btnsub" value = "Login"></td>
<td></td>
<tr>
</table>
</form>
</body>
</html>
ADMINLOGINPAGE :
<html>
<body>
<?php
$p1=$email="";
$p1Err=$emailErr="";
if(isset($_POST['btnsub']))
{
$p1 = $_POST['pass1'];
if(empty($p1))
{
$p1Err = "* Password is required";
}
else
{
if(strlen($p1)<8)
$p1Err = "* Length of password must be minimum of 8 characters";
}
$email = $_POST['email'];
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
$emailErr = "Invalid Email Format! <br>";
}
$conn = mysqli_connect("localhost","root","","db1");
$sql = "select * from REGISTRATION"; $res =
mysqli_query($conn,$sql);
while($row=mysqli_fetch_assoc($res)) {
if ($row['email']==$email) {
$emailErr = "";
if($row['pass']==$p1) {
$_SESSION['email']=$email;
$_SESSION['pass']=$p1;
header("location:adminhomepage.php?btnsub=Submit");
}
else{
$p1Err = "* Wrong password plz try again";
7
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
}
break;
}
else {
$emailErr = "* Email not found.";
}
}
}
?>
<form action="" method="POST" enctype="multipart/form-data">
<table border="5px" style="margin:auto;border-collapse:collapse;">
<tr>
<td></td>
<td><b>Admin Login Page</b></td>
<td></td>
</tr>
<tr>
<td>Enter Email Id:</td>
<td><input type="email" name="email" id="email" value="<?php echo $email; ?>"></td>
<td><?php echo $emailErr;?></td>
</tr>
<tr>
<td>Enter Password:</td>
<td><input type="password" name="pass1" id="pass1" value=<?php echo $p1;?>></td>
<td><?php echo $p1Err;?></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="btnsub"></td>
<td></td>
<tr>
</table>
</form>
</body>
</html>
USERHOMEPAGE :
<?php
$nm=$p1=$mb=$gender=$hb=$h4=$ct=$ad=$email=$image=$query=""; if(isset($_GET['btnsub']))
{
$email = $_GET['email'];
$conn = mysqli_connect("localhost","root","","db1");
$sql = "select * from REGISTRATION";
$res = mysqli_query($conn,$sql);
while($row=mysqli_fetch_assoc($res)) { if
($row['email']==$email) {
$nm = $row['name'];
$p1 = $row['pass'];
$mb = $row['mobile'];
$hb = $row['hobbies'];
$gender = $row['gender'];
$ct = $row['city'];
$ad = $row['address'];
8
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
$email = $row['email'];
$image = $row['image'];
break;
}
}
}
?>
<table cellpadding=5 border="5px" style="margin:auto;border-collapse:collapse;">
<tr><td>Name :</td><td><?php echo $nm ?></td></tr>
<tr><td>Password :</td><td><?php echo $p1 ?></td></tr>
<tr><td>Mobile :</td><td><?php echo $mb ?></td></tr>
<tr><td>Hobbies :</td><td><?php echo $hb ?></td></tr>
<tr><td>Gender :</td><td><?php echo $gender ?></td></tr>
<tr><td>City :</td><td><?php echo $ad ?></td></tr>
<tr><td>Address :</td><td><?php echo $ct ?></td></tr>
<tr><td>Email Id :</td><td><?php echo $email ?></td></tr>
<tr><td>Photo Upload :</td><td><img src="./images/<?php echo $image ?>" alt="comming soon" width="100"
height="100"></td></tr>
<tr>
<td><center><a href="editpage.php?email=<?php echo $email; ?>" target="_blank">Edit Data</a></center></td>
<td><center><a href="loginpage.php">Logout</a></center></center></td>
</tr>
</table>
SEARCH PAGE :
<html>
<body>
<?php
$conn = mysqli_connect("localhost","root","","db1");
$response = "";
$response .= "<table border=1>";
$str = $_GET['q'];
$res = mysqli_query($conn,$sql);
while($row=mysqli_fetch_array($res))
{
$response .= "<tr>";
for($i=0;$i<10;$i++)
{
$response .= "<td>$row[$i]</td>";
}
$response .= "</tr>";
}
$response .= "</table>"; echo
$response;
?>
</body>
</html>
9
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
EDITPAGE :
<html>
<body>
<?php
$nm=$p1=$mb=$gender=$hb1=$hb2=$hb3=$hb4=$hb=$ct=$ad=$email=$image="";
$nmErr=$p1Err=$mbErr=$genderErr=$hbErr=$ctErr=$adErr=$imageErr="";
$email = $_GET['email'];
$conn = mysqli_connect("localhost","root","","db1");
$sql = "select * from REGISTRATION where email='$email'";
$res = mysqli_query($conn,$sql);
while($row=mysqli_fetch_assoc($res)) { if ($row['email']==$email) {
$nm = $row['name'];
$p1 = $row['pass'];
$mb = $row['mobile'];
$hb = $row['hobbies'];
$gender = $row['gender'];
$ct = $row['city'];
$ad = $row['address'];
$email = $row['email']; $image = $row['image'];
break;
}
}
if(isset($_GET['btnsub']))
{
$nm = $_GET['nam']; if(empty($nm))
{
$nmErr = "* Name is required";
}
else
{
if (!preg_match ("/^[a-zA-Z\s]*$/", $nm) )
{
$nmErr = "Only alphabat charaters is allowed.";
}
}
$p1 = $_GET['pass1'];
if(empty($p1))
{
$p1Err = "* Password is required";
}
else
{
if(strlen($p1)<8)
10
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
$p1Err = "* Length of password must be minimum of 8 characters";
}
$mb = $_GET['mob'];
if(empty($mb))
{
$mbErr = "* Mobile number is required";
}
else
{
if (!preg_match ("/^[0-9]*$/", $mb) )
{
$mbErr = "* Only numeric value is allowed.";
}
else
{
if (strlen($mb) != 10)
{
$mbErr = "* Mobile no. must contain 10 digits.";
}
}
}
if(isset($_GET['gender'])) $gender = $_GET['gender'];
if(empty($gender))
{
$genderErr = "* Subject must have to select";
}
if(isset($_GET['hb1'])) { $hb1 = $_GET['hb1'];
$hb = "$hb1";
}
if(isset($_GET['hb2'])) {
if ($hb!="") {
$hb .= " ,";
}
$hb2 = $_GET['hb2'];
$hb .= "$hb2";
}
if(isset($_GET['hb3'])) {
if ($hb!="") {
$hb .= " ,";
}
$hb3 = $_GET['hb3'];
$hb .= "$hb3";
}
if(isset($_GET['hb4'])) {
if ($hb!="") {
$hb .= " ,";
}
$hb4 = $_GET['hb4'];
$hb .= "$hb4";
}
if($hb=="") {
$hbErr = "* Must have to select at least one hobby";
}
$ct = $_GET['city'];
if(empty($ct) or $ct=='select')
{
$ctErr = "* Please select any one city";
}
$ad = $_GET['addr'];
if(empty($ad))
{
11
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
$adErr = "* Address is required.";
}
else
{
if(!preg_match('/^[A-Za-z0-9\-,.\s]+$/',$ad)) $adErr = "* special charaters not allow";
}
if(isset($_FILES['image'])){
$file_ext=explode('.',$_FILES['image']['name']);
$file_ext=end($file_ext);
$file_ext=strtolower($file_ext);
$image = $email.".".$file_ext;
if($nmErr=="" and $p1Err=="" and $mbErr=="" and $genderErr=="" and $hbErr=="" and $ctErr=="" and $adErr==""
and $imageErr=="" and isset($_GET['btnsub']))
{
$sql = "update REGISTRATION set name = '$nm',
pass = '$p1',
mobile = '$mb',
hobbies = '$hb',
city = '$ct',
address = '$ad',
image = '$image'
where email = '$email'";
mysqli_query($conn,$sql);
echo "<center>record updated successfully</center>";
?> }
<form action="" method="GET" enctype="multipart/form-data">
<table border="5px" style="margin:auto;border-collapse:collapse;">
<tr>
<td></td>
<td><big><b>Edit Data Page</b></big></td>
<td></td>
</tr>
<tr>
<td>Enter Name:</td>
<td><input type="text" name="nam" id="nam" value="<?php echo $nm; ?>"></td>
<td><?php echo $nmErr;?></td>
</tr>
<tr>
<td>Enter Password:</td>
<td><input type="password" name="pass1" id="pass1" value=<?php echo $p1;?>></td>
<td><?php echo $p1Err;?></td>
</tr>
<tr>
<td>Enter Mobile:</td>
<td><input type="text" name="mob" id="mob" value=<?php echo $mb;?>></td>
12
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
<td><?php echo $mbErr;?></td>
</tr> <tr>
<td>Select Hobbies:</td>
<td>
<input type="checkbox" name="hb1" id="hb1" value="Travelling" <?php if($hb1!="") echo "checked"
?>>Travelling
<input type="checkbox" name="hb2" id="hb2" value="Sports" <?php if($hb2!="") echo "checked" ?>>Sports
<input type="checkbox" name="hb3" id="hb3" value="Computers"
<?php if($hb3!="") echo "checked" ?>>Computers
<input type="checkbox" name="hb4" id="hb4" value="Arts & Music"
<?php if($hb4!="") echo "checked" ?>>Arts & Music
</td>
<td><?php echo $hbErr;?></td>
</tr>
<tr>
<td>Select Gender:</td>
<td>
<input type="radio" name="gender" id="gender" value="Male" <?php if($gender=='Male') echo "checked" ?>>Male
<input type="radio" name="gender" id="gender" value="Female"
<?php if($gender=='Female') echo "checked" ?>>Female
</td>
<td><?php echo $genderErr;?></td>
</tr>
<tr>
<td>City:</td>
<td>
<select name="city" id="city">
<option value="select" <?php if($ct=="select")echo "selected";
?>>---select---</option>
13
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
</body>
</html>
SEARCHUSINGAJEX :
<html>
<head> <script>
function showResult(str){ var xmlhttp=new
XMLHttpRequest();
xmlhttp.onreadystatechange=function(){ if
(this.readyState==4 && this.status==200) {
document.getElementById("livesearch").innerHTML=this.responseText;
}
}
xmlhttp.open("GET","livesearch.php?q="+str,true); xmlhttp.send();
}
</script>
</head>
<body>
<input type="text" size="30" onkeyup="showResult(this.value)">
<div id="livesearch">Diplay Data here</div>
</body>
</html>
ADMINHOMEPAGE :
<?php
if(isset($_GET['btnsub']))
{
$response = "";
$email="";
$conn = mysqli_connect("localhost","root","","db1");
$sql = "select * from REGISTRATION";
$res = mysqli_query($conn,$sql);
$response .= "<table border=1>";
while($row=mysqli_fetch_array($res))
{
$response .= "<tr>";
for($i=0;$i<12;$i++)
{
if($i==8) {
$email = $row[$i];
$response .= "<td>$row[$i]</td>";
}
elseif($i==9) {
$response .= "<td><img src='./images/$row[$i]' alt='comming soon' width='100'
height='100'></td>";
}
elseif($i==10) {
$response .= "<td><a href='editpage.php?email=$email' target='_blank'>Edit</a></center></td>";
}
elseif($i==11) {
$response .= "<td><a href='deletepage.php?email=$email' target='_blank'>Delete</a></center></td>";
}
else {
$response .= "<td>$row[$i]</td>";
}
}
$response .= "</tr>";
}
$response .= "</table>";
echo $response;
14
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
}
?>
<a href='searchUsingAjax.php' target='_blank'>Search</a></center>
Deletepage :
<?php
$email = $_GET['email'];
$conn = mysqli_connect("localhost","root","","db1"); $sql =
"delete from REGISTRATION where email='$email'";
mysqli_query($conn,$sql);
echo "<center>record deleted successfully</center>";
?>
Flask Website
Flask1.py:
mysql = MySQL(app)
if 'rec_email' in session:
15
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
mysql.connection.cursor() cursor.execute("drop table registration") mysql.connection.commit() cursor.close()
return "sucessfully drop table"
if request.method == 'POST': nm =
request.form['name'] ps =
request.form['pass'] rps =
request.form['retype'] mb =
request.form['mobile'] if
request.form.get('h1'):
h1 = b'1' else: h1 = b'0' if
request.form.get('h2'):
h2 = b'1' else: h2 = b'0' if
request.form.get('h3'):
h3 = b'1' else: h3 = b'0' if
request.form.get('h4'):
h4 = b'1' else:
h4 = b'0' gd =
request.form['g1'] ci = request.form['city']
ad = request.form['add'] em = request.form['email']
ph = request.files['file']
return render_template('login.html')
16
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
@app.route('/ad-login',methods=['POST','GET']) def ad_login(): if(request.method=='POST' and 'ad' in
request.form and 'ps' in request.form):
admin=request.form['ad'] pas=request.form['ps']
if(admin=='admin' and pas=='admin123'):
session['admin']=admin return
redirect(url_for('show')) return
"<script>alert('invalid !!')</script>" return
render_template('admin_login.html')
registration.html:
<html>
<header align="center">
<a href="ad-login">Admin</a>
<a href="login">Login</a>
<a href="registration">Registration</a>
<a href="show">Show</a>
<script> function
validate(){
if(myForm.name.value == ""){
alert("Please provide your Name..!") myForm.name.focus()
return false
}
if(!isNaN(myForm.name.value)){ alert("Please Enter only
character") myForm.name.focus() return false
}
if(myForm.pass.value == ""){
alert("Please fill up Password..!") myForm.pass.focus() return false
}
18
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
return false
}
}
</script>
</header>
<body style="background-color: rgb(170, 170, 177);">
<h2 align="center" style="color: rgb(5, 5, 75);">Registration</h2>
</tr>
<tr>
<td>Password :</td>
<td><input type="password" name="pass" placeholder="Password" pattern="(?=.*\d)(?=.*[az])(?=.*[A-Z]).{6,}"
pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}" title="Must contain at least one number and one uppercase and lowercase
letter and at least 6 or more character.."></td>
</tr>
<tr>
<td>Retype Password :</td>
<td><input type="password" name="retype" placeholder="Retype Password"></td>
</tr>
<tr>
<td>Mobile Number :</td>
<td><input type="number" name="mobile" placeholder="Enter Mobile number"></td>
</tr>
<tr>
<td>Hobbies :</td>
<td><input type="checkbox" name="h1" value="1" >Travelling
<input type="checkbox" name="h2" value="1">Reading
<input type="checkbox" name="h3" value="1">Coding
<input type="checkbox" name="h4" value="1">Dancing</td>
</tr>
<tr>
<td>Gender :</td>
<td><input type="radio" name="g1" value="Male">Male
<input type="radio" name="g1" value="Female">Female</td>
</tr>
<tr>
<td>City :</td>
<td>
<select name="city">
<option value="select" selected>---select---</option>
<option value="surat" >Surat</option>
<option value="ahemdabad" >Ahemdabad</option>
<option value="baroda">Baroda</option>
<option value="banglore">Banglore</option>
</select>
</td>
</tr>
<tr>
<td>Home Address :</td>
<td><textarea type="text" name="add" placeholder="Address"></textarea></td>
</tr>
<tr>
<td>
Email id :
19
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
</td>
<td><input name="email" name="email" placeholder="Email id"></td>
</tr>
<tr>
<td>
Photo :
</td>
<td><input type="file" name="file" ></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="btnsub" style="color: green;"></td>
</tr>
</table>
</form>
</body>
</html>
Login.html:
<html>
<header align="center">
<a href="ad-login">Admin</a>
<a href="login">Login</a>
<a href="registration">Registration</a>
<a href="show">Show</a>
<script>
function validate(){ if(document.myForm.email.value ==
""){ alert("Please provide your Email..!")
document.myForm.email.focus() return false
}
if(document.myForm.pass.value == ""){ alert("Please fill up Password..!")
document.myForm.pass.focus() return false
}
}
</script>
</header>
<body style="background-color: rgb(179, 179, 182);" align="center">
<h2 align="center" style="color: rgb(7, 7, 102);">Login </h2>
20
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="btnsub" style="color: green;">
</td>
</tr>
</table>
<br>
{% if get_flashed_messages() %}
{{ get_flashed_messages()[0] }}
{% endif %}
</form>
</body>
</html>
Show.html:
<html>
<head>
<a href="login">Login</a>
<a href="registration">Registration</a>
</head>
<body align="center" style="background-color: rgb(177, 176, 176);">
<h2 style="color: green;">Profile</h2>
<form>
</tr>
<tr>
<td>Name :</td>
<td>{{name}}</td>
</tr>
<tr>
<td>Password :</td>
<td>{{pas}}</td>
</tr>
<tr>
<td>Mobile Number :</td>
<td>{{mobil}}</td>
</tr>
<tr>
<td>Travelling :</td>
<td style="color: blue;">{{tv}}</td>
</tr>
<tr>
<td>Reading :</td>
<td style="color: blue;">{{red}}</td>
</tr>
21
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
<tr>
<td>Coding :</td>
<td style="color: blue;">{{code}}</td>
</tr>
<tr>
<td>Dancing :</td>
<td style="color: blue;">{{dance}}</td>
</tr>
<tr>
<td>Gender :</td>
<td>{{gender}}</td>
</tr>
<tr>
<td>City :</td>
<td>
{{cty}}
</td>
</tr>
<tr>
<td>Home Address :</td>
<td>{{addre}} </td>
</tr>
<tr>
<td> Email id :
</td>
<td>{{user}}</td>
</tr>
</table>
</form>
<a href="/logout">Logout</a>
<a href="{{url_for('edit',id=id)}}">Edit</a></body>
</html>
Home.html:
<html>
<body style="background-color: white;" align="center">
<header align="center">
<a href="login">Login</a>
<a href="registration">Registration</a>
<a href="show">Show</a>
</header>
<h2 align="center">Home page</h2>
<tr>
<td>{{row[0]}}</td>
<td>{{row[1]}}</td>
<td>{{row[2]}}</td>
<td>{{row[3]}}</td>
<td>{{row[4]}}</td>
<td>{{row[5]}}</td>
<td>{{row[6]}}</td><td>{{row[7]}}</td>
<td>{{row[8]}}</td>
<td>{{row[9]}}</td>
<td>{{row[10]}}</td>
<td>{{row[11]}}</td>
<td>{{row[12]}}</td>
<td><imgsrc="http://127.0.0.1:5000/static/image/{{row[13]}}" alt="profile" width="100" height="100"></td>
<td><a href="{{url_for('edit',id=row[0])}}">Edit</a></td>
<td><a href="{{url_for('delete',id=row[0])}}">Delete</a></td>
</tr>
{% endfor %}
</table>
<br>
<a href="/logout">Logout</a></body></html>
Edit.html:
<html>
<header align="center">
<script>
function validate(){
if(myForm.name.value == ""){
alert("Please provide your Name..!") myForm.name.focus()
return false
}
if(!isNaN(myForm.name.value)){
alert("Please Enter only character") myForm.name.focus() return
false
}
if(myForm.pass.value == ""){ alert("Please fill up
Password..!")
myForm.pass.focus() return false
}
if(myForm.retype.value == ""){
alert("Please Fill up Retype Password..!")
myForm.retype.focus()
return false
}
var pa1 = myForm.pass.value var pa2 =
myForm.retype.valueif(pa1
!= pa2){ alert("Not
match password..!") myForm.retype.focus()
return false
23
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
}
if(myForm.mobile.value == ""){
alert("Please Enter your Mobile number..!") myForm.mobile.focus() return
false
}
var gender = myForm.g1.value
if(gender.checked == false){ alert("please select
gender")
return false
}
}
</script>
</header>
<body style="background-color: rgb(170, 170, 177);">
<h2 align="center" style="color: rgb(5, 5, 75);">Registration</h2>
</tr>
<tr>
<td>Password :</td>
<td><input type="password" name="pass" placeholder="Password" value="{{user[2]}}" pattern="(?=.*\d)(?=.*[a-
z])(?=.*[A-Z]).{6,}" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,}" title="Must contain at least one number and one
uppercase and lowercase letter and at least 6 or more character.."></td>
</tr>
<tr>
<td>Retype Password :</td>
<td><input type="password" name="retype" placeholder="Retype Password" value="{{user[3]}}"></td>
</tr>
<tr>
<td>Mobile Number :</td>
<td><input type="number" name="mobile" placeholder="Enter Mobile number" value="{{user[4]}}"></td>
</tr>
<tr>
24
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
<td>Hobbies :</td>
<td><input type="checkbox" name="h1" value="1" {% if user[5]==1 %}{{"checked" }}{% endif %}>Travelling
<input type="checkbox" name="h2" value="1" {% if user[6]==1 %}{{"checked"}}{% endif %}>Reading
<input type="checkbox" name="h3" value="1" {% if user[7]==1 %}{{"checked"}}{% endif %}>Coding
<input type="checkbox" name="h4" value="1" {% if user[8]==1 %}{{"checked"}}{% endif %}>Dancing</td>
</tr>
<tr>
<td>Gender :</td>
<td><input type="radio" name="g1" value="Male" {% if user[9]=='Male' %}{{"checked"}}{% endif %}>Male
<input type="radio" name="g1" value="Female" {% if user[9]=='Female' %}{{"checked"}}{% endif %}>Female</td>
</tr>
<tr>
<td>City :</td>
<td>
<select name="city">
<option value="select" selected>---select---</option>
<option value="surat" {% if user[10]=='surat' %}{{"selected"}}{% endif %}>Surat</option>
<option value="ahemdabad" {% if user[10]=='ahemdabad' %}{{"selected"}}{% endif %}>Ahemdabad</option>
<option value="baroda" {% if user[10]=='baroda' %}{{"selected"}}{% endif %}>Baroda</option>
<option value="banglore" {% if user[10]=='banglore' %}{{"selected"}}{% endif %}>Banglore</option>
</select>
</td>
</tr>
<tr>
<td>Home Address :</td>
<td><textarea type="text" name="add" placeholder="Address" value="{{user[11]}}">{{user[11]}}</textarea></td>
</tr>
<tr>
<td>
Email id :
</td>
<td><input name="email" name="email" placeholder="Email id" value="{{user[12]}}"></td>
</tr>
<tr>
<td>
Photo :
</td>
<td><input type="file" name="file" value="{{user[13]}}"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="btnsub" value="update" style="color: green;"></td>
</tr>
</table>
</form>
</body>
</html>
Admin_login.html:
<html>
<header align="center">
<a href="login">Login</a>
<a href="registration">Registration</a>
<a href="show">Show</a>
<script> function validate(){
if(document.myForm.ad.value == ""){
alert("Please provide your Email..!")
25
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
document.myForm.ad.focus() return false
}
if(document.myForm.ps.value == ""){ alert("Please fill up
Password..!")
document.myForm.ps.focus() return false
}
}
</script>
</header>
<body style="background-color: rgb(179, 179, 182);" align="center">
<h2 align="center" style="color: rgb(7, 7, 102);">Login </h2>
</form></body></html>
Output:
26
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
27
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
28
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
29
TYBCA-SEM-5-DIV-2 PHP Roll no. -108
30