PHP Code
PHP Code
php
include 'connection.php';
session_start();
if(isset($_REQUEST['stdlog'])) //Login for Student
{
$u=$_POST['suname'];
$p=$_POST['spass'];
$result=mysql_query("select id from studreg where userstud='$u'and
passtud='$p'");
$row= mysql_fetch_assoc($result);
$id=$row['id'];
if(mysql_num_rows($result)>0)
{
$_SESSION['uid']=$id;
header("location:stuhome.php");
?>
<script>
alert("You have logged in");
</script>
<?php
}
else
{
?>
<script>
alert("Please Sign-Up first");
</script>
<?php
}
}
if(isset($_REQUEST['faclog'])) //Login for Faculty
{
$u=$_POST['funame'];
$p=$_POST['fpass'];
$result=mysql_query("select id from facreg where userfac='$u' and
password='$p'");
$row= mysql_fetch_assoc($result);
$id=$row['id'];
if(mysql_num_rows($result)>0)
{
$_SESSION['uid']=$id;
header("location:fachome.php");
?>
<script>
alert("You have logged in");
</script>
<?php
}
else
{
?>
<script>
alert("Please Sign-Up first");
</script>
<?php
}
}
if(isset($_REQUEST['adminlog'])){ //Login for Admin
$u=$_POST['adusn'];
$p=$_POST['adpass'];
$result=mysql_query("select * from adminreg where username='$u' and
password='$p'");
if(mysql_num_rows($result)>0)
{
$_SESSION['useradmin']=$u;
header("location:adhome.php");
?>
<script>
alert("You have logged in");
</script>
<?php
}
else
{
?>
<script>
alert("Please Sign-Up first");
</script>
<?php
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>
College Social Network
</title>
<link rel="stylesheet" href="navdes.css">
<script>
function val()
{
if(!/^[a-zA-Z]*$/g.test(document.myForm.suname.value))
{
alert('Enter Only Name');
document.myForm.suname.focus();
return false;
}
return true;
}
function val1()
{
if(!/^[a-zA-Z]*$/g.test(document.myForm1.adusn.value))
{
alert('Enter Only Name');
document.myForm.adusn.focus();
return false;
}
return true;
}
function val2()
{
if(!/^[a-zA-Z]*$/g.test(document.myForm2.funame.value))
{
alert('Enter Only Characters');
document.myForm.funame.focus();
return false;
}
return true;
}
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
</script>
</head>
<link href="css/bootstrap.css" rel="stylesheet" />
<link href="css/bootstrap-theme.css" rel="stylesheet" />
<meta name="viewport" content="width=device-width intital-scale=1">
<style>
.box/* Used for the rectangular Div */
{
width:85%;
margin-left:auto;
margin-right:auto;
border: 1px solid;
padding:154px;
margin-top:10%;
text-align:center;
border-style:double;
}
.nav-pills /*used for the Menu Bar */
{
font-size:20px;
background-color:#20282e;
margin-top:0px;
padding:25px;
}
.header
{
position: sticky;
top: 0;
z-index: 100;
background-color:black;
}
.login {
margin: 20px auto;
width: 800px;
.login-screen {
background-color: #FFF;
padding: 20px;
border-radius: 5px
}
.app-title {
text-align: center;
color: #777;
}
.login-form {
text-align: center;
}
.control-group {
margin-bottom: 10px;
}
input {
text-align: center;
background-color: #ECF0F1;
border: 2px solid transparent;
border-radius: 3px;
font-size: 16px;
font-weight: 200;
padding: 10px 0;
width: 250px;
transition: border .5s;
}
input:focus {
border: 2px solid #3498DB;
box-shadow: none;
}
.btn {
border: 2px solid transparent;
background: #3498DB;
color: #ffffff;
font-size: 16px;
line-height: 25px;
padding: 10px 0;
text-decoration: none;
text-shadow: none;
border-radius: 3px;
box-shadow: none;
transition: 0.25s;
display: block;
width: 250px;
margin: 0 auto;
}
.btn:hover {
background-color: #2980B9;
}
.login-link {
font-size: 12px;
color: #444;
display: block;
margin-top: 12px;
}
.container-fluid {
padding-right: 0px !important;
padding-left: 0px !important;
}
#myPageContent, section {
height:100% !important;
width:100% !important;
/* Slider */
#textSlider.row {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100% !important;
}
#textSlider div {
color: #FFF;
font-family: 'Lato', sans-serif;
text-transform: uppercase;
.iamCol {
text-align: right;
float: left;
font-weight: 300;
font-size:30pt;
}
.iamCol p:nth-child(2) { margin-top: -20pt !important; }
.slideCol {
text-align: left;
overflow: hidden;
font-weight: 900;
font-size:70pt;
display: block;
white-space: nowrap;
}
.slideCol p { margin: 0px !important; }
.scroller {
height: 70pt;
line-height: 70pt;
overflow: hidden;
}
.scroller .inner { animation: 10s normal infinite running scroll; }
@keyframes scroll {
0% {margin-top: 0px;}
15% {margin-top: 0px;}
0px !important; }
.iamCol { text-align: center; font-size:20pt; }
.iamCol p { display: inline !important; }
.slideCol { font-size: 25pt; text-align: center; margin-top:
-20px; }
}
0px !important; }
.iamCol { text-align: center; font-size:25pt; }
.iamCol p { display: inline !important; }
.slideCol { font-size: 38pt; text-align: center; margin-top:
-20px; }
}
0px !important; }
5px; }
}
0px !important; }
}
</style>
<script src="js/bootstrap.min.js"></script>
<link href="backdes.css" rel="stylesheet" />
<body >
</div>
<a href="javascript:void(0);" class="icon"
onclick="myFunction()">☰</a>
</div>
<div class="container" id="about" >
<div class="row " >
onmouseover="this.style.background='#3498DB';"
onmouseout="this.style.background='white';this.style.color='black';"><!--
For Student -->
<h3 class="well" style="margin-bottom:10%;"> <center> Login </center></h3>
<h3><center> Student Login </center> </h3>
<form method="POST" name="myForm" sttyle="margin-top:90%" >
<div class="login-screen">
<div class="app-title">
</div>
<div class="login-form">
<div class="control-group">
<span class="glyphicon glyphicon-user"></span> <input type="text"
maximum="8" name="suname" placeholder="Username" >
</div>
<div class="control-group">
<span class="glyphicon glyphicon-lock"></span> <input
type="password" maximum="8" name="spass" placeholder="Password" >
<label class="login-field-icon fui-lock"
for="login-pass"></label>
</div>
onmouseover="this.style.background='#3498DB';"
onmouseout="this.style.background='white';this.style.color='black';" ><!--
For Faculty -->
<form method="POST" name="myForm2" >
<h3 class="well" style="margin-bottom:10%;"> <center> Login
</center></h3><center> <h3> Faculty Login </h3> </center><div
class="login-screen" >
<div class="app-title"></div>
<div class="login-form" >
<div class="control-group">
<span class="glyphicon glyphicon-user"></span> <input type="text"
class="login-field" id="utxt" maximum="8" name="funame"
placeholder="Username">
<label class="login-field-icon fui-user" for="login-name"></label>
</div>
<div class="control-group">
<span class="glyphicon glyphicon-lock"></span> <input type="password"
class="login-field" placeholder="password" maximum="8" name="fpass"
placeholder="Password" >
<label class="login-field-icon fui-lock" for="login-pass"></label>
</div>
<button class="btn btn-primary btn-large btn-block" onclick="val2()"
name="faclog"><span class="glyphicon glyphicon-log-in"> </span>
Login</button>
<a href="fchangepass.php" style="text-decoration:none;color:black; " >
Forget/Reset Password </a></div>
</div>
</form>
</div>
</div>
</div>
<div class="navbar navbar-default navbar-fixed-bottom">
<div class="container">
<p class="text-justify"><strong><center> College Social Network
©</center> </strong> </p>
</div>
</div>
</body>
</html>
<?php
include 'connection.php';
if(isset($_REQUEST['rfac']))
{
$fname=$_POST['fname'];
$fdes=$_POST['fdesig'];
$fdob=$_POST['dob'];
$fmail=$_POST['femail'];
$funame=$_POST['funame'];
$fpass=$_POST['fpass'];
$fmob=$_POST['mob'];
$fprofile=$_FILES['fProfile']['name'];
$ftemp=$_FILES['fProfile']['tmp_name'];
if($_FILES['fProfile']['size'] > 2000000 )
{
echo "<script>alert('File to Large Please Select another
File')</script>";
}
else
{
move_uploaded_file($ftemp,"profile/$fprofile");
$val=mysql_query("select userfac,password from facreg where
userfac='$funame' and password='$fpass' ");
if(mysql_num_rows($val)>0)
{
echo "<script> alert('Already Registered'); </script>";
}
else
{
/*Start of SMS Package */
// Authorisation details.
$username = "[email protected]";
$hash =
"486dbbf9b90cbe85b8e6581058e0616b8d8747ecb537d3dbc1000d1e0df76b66";
// Config variables. Consult http://api.textlocal.in/docs for more info.
$test = "0";
$ch = curl_init('http://api.textlocal.in/send/?');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch); // This is the result from the API
curl_close($ch);
/*
echo "<pre>";
print_r($result);
exit;
End of SMS Package */
$query=mysql_query("INSERT INTO
facreg(name,Designation,DOB,email,fac_pic,mob,userfac,password)
Values('$fname','$fdes','$fdob','$fmail','$fprofile','$fmob','$funame','$fp
ass')");
if($query)
{
echo "<script> alert('Faculty Member Registered');</script>";
// die(mysql_error());
// echo "<script> window.location.href='adhome.php';</script>" ;
}
}
}
}
if (isset($_REQUEST['rstud'])){
$sname=$_POST['sname'];
$suname=$_POST['suname'];
$spass=$_POST['spass'];
$sem=$_POST['sem'];
$sreg=$_POST['sreg'];
$dob=$_POST['dob'];
$smob=$_POST['smob'];
$smail=$_POST['smail'];
$sprofile=$_FILES['sProfile']['name'];
$stemp=$_FILES['sProfile']['tmp_name'];
if($_FILES['sProfile']['size'] > 2000000 )
{
echo "<script>alert('File to Large Please Select another
File')</script>";
}
else
{
move_uploaded_file($stemp,"sprofile/$sprofile");
$val1=mysql_query("select userstud,passtud from studreg where
userstud='$suname' and passtud='$spass' ");
if(mysql_num_rows($val1)>0) //Checking the value already exists.
{
?>
<script>
alert(" You have already Registered");
</script>
<?php
}
else {
/*Start of SMS Package */
// Authorisation details.
$username = "[email protected]";
$hash =
"486dbbf9b90cbe85b8e6581058e0616b8d8747ecb537d3dbc1000d1e0df76b66";
// Config variables. Consult http://api.textlocal.in/docs
$test = "0";
// Data for text message. This is the text message data.
$sender = "TXTLCL"; // This is who the message appears to be
from.
// $numbers = "8879920190,$smob";
// A single number or a comma-seperated list of numbers
$message = " Your Username=".$suname." and password=".$spass." now you are a
part of College Socail Network .";
$message = urlencode($message);
$data = "username=".$username."&hash=".$hash."&message=".$message."&sender=".
$sender."&numbers=".$smob."&test=".$test;
$ch = curl_init('http://api.textlocal.in/send/?');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch); // This is the result from the
APIcurl_close($ch);
$query=mysql_query("INSERT INTO
studreg(name,semester,reg_no,dob,stu_pic,mob,email,userstud,passtud)
Values('$sname','$sem','$sreg','$dob','$sprofile','$smob','$smail','$suname
','$spass')");
if($query)
{
}
.header
{
position: sticky;
top: 0;
z-index: 100;
}
</style>
<script>
function alert_once() {
var size=2000000;
var file_size=document.getElementById('file_upload').files[0].size;
if(file_size>size)
{
alert('File Size to Large');
return false;
}
return true;
}
function validate1() {
var size=2000000;
var file_size=document.getElementById('file_up').files[0].size;
if(file_size>size)
{
alert('File Size to Large');
return false;
}
return true;
}
function myFunction() {
var x = document.getElementById("myTopnav");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}
</script>
<body>
</div>
<a href="javascript:void(0);" class="icon"
onclick="myFunction()">☰</a>
</div>
<?php
session_start();
if($_SESSION['useradmin']=="")
{
header("location:index.php");
}
?>
<div id="regfact" class="container" style="border:solid ;background:
#3AAFAB;
color: black;">
<h3 class="text-center">Register Faculty</h3>
<ul class="flex-outer">
<li>
</li>
<li>
</li>
<button class="btn btn-primary pull-right " name="rfac" ><span
class="glyphicon glyphicon-pencil"></span>Register </button>
<button type="reset " class="btn btn-primary " name="refac" >Reset
</button>
</form>
</div>
<div id="regstud" class="container" style="border:solid ;background:
#3AAFAB;margin-top:10%;
color: black;">
<h3 class="text-center">Register Student</h3>
<ul class="flex-outer">
<li>
<select class="form-control"
name="sem"><option>1<sup>st</sup> Semester</option>
<option>2<sup>nd</sup> Semester</option>
<option>3<sup>rd</sup> Semester</option>
<option>4<sup>th</sup> Semester</option>
<option>5<sup>th</sup> Semester</option>
<option>6<sup>th</sup> Semester</option>
</select>
</li>
<li>
<li>
</form>
</div>
<div class="box1" id="apppost" style="padding:90px;">
<?php
$st=0;
$tb=mysql_query("select * from Feed where app_post='$st' order
by id DESC ");
$res=mysql_num_rows($tb);
if($res == 0)
{
echo "<h3 ><center> No Post Uploaded</center></h3>";
}
else
{
echo "<div class='table'>
?>
<div class="row">
<div class="cell" data-title="Name">
<?php echo $res['id']; ?>
</div>
<div class="cell" data-title="Username">
<?php echo $res['username']; ?>
</div>
<div class="cell" data-title="PostText">
<?php echo $res['ptext']; ?>
</div>
<div class="cell" data-title="Image">
<?php echo "<img src='images/$p1' width='100px'
height='100px' >" ?>
</div>
<div class="cell" data-title="Upload Time">
<?php echo $res['uptime']; ?>
</div>
<div class="cell" data-title="Upload Date">
<?php echo $res['upldate']; ?>
</div>
<div class="cell" data-title="Approve">
<form method="POST"> <input type="text" name="pid"
value="<?php echo $res['id'] ?>" style="display:none;"/> <button
class="btn btn-primary" name="sub" type="submit">Approve</button> <br/>
<br/> <button class="btn btn-primary" name="del" type="submit"
onclick="return confirm('Do You want to delete it');" >Delete</button>
</form>
</div>
</div>
<?php
}}
?>
</div>
<?php
if(isset($_POST['sub'])){
$query=mysql_query("Update feed set app_post='1' where app_post='0' ");
if($query)
{
echo "<script> alert('Post Approved'); </script>";
echo "<script> window.location.href='adhome.php'</script>";
}
else
{
die(mysql_error());
}
}
if(isset($_POST['del'])){
$pid=$_POST['pid'];
$del=mysql_query("delete from feed where id='$pid'");
if($del)
{
echo "<script> alert('Post Deleted');</script>";
echo "<script> window.location.href='adhome.php'; </script>";
}
else
{
die(mysql_error());
}
}
?>
</div>
<div id="footer">
</div>
</body>
</html>