Skip to content

Commit

Permalink
New Files added
Browse files Browse the repository at this point in the history
  • Loading branch information
maniyaom committed Oct 24, 2023
1 parent aad1141 commit ea4e785
Show file tree
Hide file tree
Showing 15 changed files with 1,361 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vscode
95 changes: 95 additions & 0 deletions OtherPages/contactus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php
session_start();
if (!((isset($_SESSION["email_id"]) && isset($_SESSION['loggedin'])) && $_SESSION['loggedin'] == true)){
header("Location: login.php");
exit();
}
?>

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Contact Us</title>
<link rel="stylesheet" href="../utils.css">
<style>
#messageBox {
padding: 12px 15px;
border-radius: 8px;
outline: none;
border: none;
background-color: #eeeeee;
font-size: 16px;
}
</style>
<link rel="stylesheet" href="../style.css">
</head>

<body>
<nav class="navbar">
<div class="logo" onclick="document.location.href='index.php'">E - News</div>
<div class="nav-links">
<ul>
<li><a href="../index.php">Home</a></li>
<li><a href="#">About Us</a></li>
<li><a href="contactus.php">Contact Us</a></li>
<li><a href="review.php">Review Us</a></li>
</ul>
</div>
<div class="loginBtn">
<button class="btn" onclick="document.location.href = 'OtherPages/login.php'">Login</button>
<button class="btn" style="margin-right: -80px; margin-left: 20px;" onclick="document.location.href = 'OtherPages/signup.php'">Sign Up</button>
</div>
</nav>

<div class="main">
<form onsubmit="sendEmail(); reset(); return false;" autocomplete="off">
<span>Contact Us</span>
<input type="text" name="fname" id="fname" class="inputFields" placeholder="First Name" value="<?php echo $_COOKIE['First_Name'] ?>" readonly>
<input type="text" name="lname" id="lname" class="inputFields" placeholder="Last Name" value="<?php echo $_COOKIE['Last_Name'] ?>" readonly>
<input type="text" name="title" id="title" class="inputFields" placeholder="Title" required>
<input type="email" name="email" id="email" class="inputFields" placeholder="Email" value="<?php echo $_SESSION['email_id'] ?>" readonly>
<textarea name="message" id="messageBox" cols="45" rows="10" placeholder="Enter Your Message" required></textarea>

<button type="submit" class="btn" style="width: 100%; margin-top: 20px">Submit</button>
</form>
</div>

<script src="https://smtpjs.com/v3/smtp.js"></script>

<script>
function sendEmail(){
Email.send({
Host : "smtp.elasticemail.com",
Username : "ommaniya000@gmail.com",
Password : "8C621CCF7ECEB431CBA080D3F6BDA681FFC3",
To : 'newswebsite02@gmail.com',
From : "ommaniya000@gmail.com",
Subject : title.value,
Body : "First Name : "+document.getElementById("fname").value+
"<br>Last Name : "+document.getElementById("lname").value+
"<br>Email : "+document.getElementById("email").value+
"<br>Query : "+document.getElementById("messageBox").value
}).then(
message => alert(message)
);

// Email.send({
// Host : "smtp.elasticemail.com",
// Username : "ommaniya000@gmail.com",
// Password : "8C621CCF7ECEB431CBA080D3F6BDA681FFC3",
// To : document.getElementById("email").value,
// From : "ommaniya000@gmail.com",
// Subject : title.value,
// Body : "Dear "+document.getElementById("fname").value+" "+document.getElementById("lname")+
// "<br>We have Successfully received your message<br>Thank you for contacting us, we will respond to your message within 24-48 hours..."
// }).then(
// message => alert(message)
// );
}
</script>
</body>

</html>
157 changes: 157 additions & 0 deletions OtherPages/login.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
<?php
session_start();

// Check if the user is already logged in
if (((isset($_SESSION["email_id"]) && isset($_SESSION['loggedin'])) && $_SESSION['loggedin'] == true)) {
header("Location: ../index.php");
exit();
}
?>

<!DOCTYPE html>
<html>
<head>
<title>Login</title>
<link rel="stylesheet" href="../utils.css">
<style>
form{
width: 30%;
padding: 40px 45px;
}

.inputFields{
width: 90%;
margin-bottom: 0px;
background-color: white;
}

.btn{
width: 100%;
}

#usr_err_msg{
color: red;
font-size: 13px;
margin-top: -15px;
margin-bottom: 10px;
margin-left: 5px;
}

.user-icon-div{
display: flex;
align-items: center;
border: 1px solid rgba(128, 128, 128, 0.329);
padding: 5px 25px;
border-radius: 8px;
margin-bottom: 20px;
}

.user-icon-div > i{
margin-right: 10px;
}

.show-password-div{
margin-bottom: 20px;
font-size: 16px;
display: flex;
align-items: center;
}

.show-password-div > input{
width: 16px;
height: 16px;
margin-right: 6px;
accent-color: rgb(254,64,102);
}

</style>
<link rel="stylesheet" href="../style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<script>
function showPassword(eleId){
let passwordField = document.getElementById(eleId);
if(passwordField.type == "password"){
passwordField.type = "text";
}
else{
passwordField.type = "password";
}
}
</script>
</head>
<body>
<nav class="navbar">
<div class="logo" onclick="document.location.href='index.php'">E - News</div>
<div class="nav-links">
<ul>
<li><a href="../index.php">Home</a></li>
<li><a href="#">About Us</a></li>
<li><a href="contactus.php">Contact Us</a></li>
<li><a href="review.php">Review Us</a></li>
</ul>
</div>
<div class="loginBtn">
<button class="btn" onclick="document.location.href = 'OtherPages/login.php'">Login</button>
<button class="btn" style="margin-right: -80px; margin-left: 20px;" onclick="document.location.href = 'OtherPages/signup.php'">Sign Up</button>
</div>
</nav>

<div class="main">
<form action="login.php" method="post" autocomplete="off">
<span>Login</span>
<div class="user-icon-div">
<i class="fa fa-user" style="font-size:36px"></i>
<input type="email" id="email" class="inputFields" name="email" placeholder="Email" required>
</div>
<div class="user-icon-div">
<i class="fa fa-key" aria-hidden="true" style="font-size: 30px;"></i>
<input type="password" id="password" class="inputFields" name="password" placeholder="Password" required>
</div>
<div class="show-password-div">
<input type="checkbox" name="showPasskey" id="showPasskey" onclick=showPassword("password")>
<span>Show Password</span>
</div>
<span id="usr_err_msg"></span>
<input type="submit" class="btn" style="width : 100%" value="Login">
</form>
</div>

<?php
$usr_err_msg = "";
// Check if the form is submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Retrieve user input
$email_id = $_POST["email"];
$user_password = $_POST["password"];

include("../dbconnection.php");
$conn = establishConnection();

$query = "SELECT * FROM USER_DETAILS WHERE EMAIL_ID = '$email_id'";
$result = mysqli_query($conn, $query);
$row = $result->fetch_assoc();

if (password_verify($user_password, $row['PASSWORD'])) {
// Redirect to the welcome page if a matching user is found

$_SESSION['email_id'] = $email_id;
$_SESSION['loggedin'] = true;

setcookie("First_Name", $row['FIRST_NAME'], time() + 60 * 60 * 24 * 365, '/');
setcookie("Last_Name", $row['LAST_NAME'], time() + 60 * 60 * 24 * 365, '/');

closeConnection($conn);
header("Location: ../index.php");
exit();
} else {
// Invalid email or password
$usr_err_msg = "Invalid Email or Password !!";
}
}
?>
<script>
document.getElementById("usr_err_msg").innerHTML = "<?php echo $usr_err_msg ?>";
</script>
</body>
</html>
109 changes: 109 additions & 0 deletions OtherPages/review.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php
session_start();
if (!((isset($_SESSION["email_id"]) && isset($_SESSION['loggedin'])) && $_SESSION['loggedin'] == true)){
header("Location: login.php");
exit();
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Review Us</title>
<link rel="stylesheet" href="../utils.css">
<style>
form{
width: 40%;
padding: 40px 40px;
}

#review-info {
padding: 12px 15px;
border-radius: 8px;
outline: none;
border: none;
background-color: #eeeeee;
font-size: 16px;
}

</style>
<link rel="stylesheet" href="../style.css">
</head>
<body>

<nav class="navbar">
<div class="logo" onclick="document.location.href='index.php'">E - News</div>
<div class="nav-links">
<ul>
<li><a href="../index.php">Home</a></li>
<li><a href="#">About Us</a></li>
<li><a href="contactus.php">Contact Us</a></li>
<li><a href="review.php">Review Us</a></li>
</ul>
</div>
<div class="loginBtn">
<button class="btn" onclick="document.location.href = 'OtherPages/login.php'">Login</button>
<button class="btn" style="margin-right: -80px; margin-left: 20px;" onclick="document.location.href = 'OtherPages/signup.php'">Sign Up</button>
</div>
</nav>

<div class="main">
<form action="review.php" method="post" onsubmit="reset();">
<span>Review Us</span>
<input type="text" id="fname" class="inputFields" name="fname" placeholder="First Name" value="<?php echo $_COOKIE['First_Name'] ?>" readonly>
<input type="text" id="lname" class="inputFields" name="lname" placeholder="Last Name" value="<?php echo $_COOKIE['Last_Name'] ?>" readonly>
<input type="email" id="email" class="inputFields" name="email" placeholder="Email" value="<?php echo $_SESSION['email_id'] ?>" readonly>
<textarea name="review-info" id="review-info" placeholder="Feedback" cols="30" rows="10"></textarea>
<input type="submit" class="btn" value="Submit" style="width: 100%; margin-top: 30px">
</form>
</div>

</body>
</html>

<?php
include("../dbconnection.php");
function addReview($conn,$first_name,$last_name,$email_id, $review_info)
{
$query = "CREATE TABLE IF NOT EXISTS REVIEW_DETAILS (
Sr_No int(11) AUTO_INCREMENT,
FIRST_NAME varchar(255),
LAST_NAME varchar(255),
EMAIL_ID varchar(255) NOT NULL,
REVIEW_INFO varchar(1000),
PRIMARY KEY (Sr_No,EMAIL_ID)
)";
#FOREIGN KEY (EMAIL_ID) REFERENCES USER_DETAILS(EMAIL_ID)

if (mysqli_query($conn, $query)) {
echo "Table REVIEW_DETAILS created or already exists.";

$query = "INSERT INTO REVIEW_DETAILS (FIRST_NAME, LAST_NAME, EMAIL_ID, REVIEW_INFO) VALUES ('$first_name', '$last_name', '$email_id', '$review_info')";

if (!(isExists($conn, $email_id,"REVIEW_DETAILS"))) {
if (mysqli_query($conn, $query)) {
echo "Review Added Successfully!";
} else {
echo "Error Adding Review: " . mysqli_error($conn);
}
} else {
echo "Error Adding Review : User has Already Reviewed !!";
}
} else {
echo "Error creating table: " . mysqli_error($conn);
}
}

if($_SERVER["REQUEST_METHOD"] == "POST"){
$first_name = $_POST["fname"];
$last_name = $_POST["lname"];
$email_id = $_POST["email"];
$review_info = $_POST["review-info"];

$conn = establishConnection();
addReview($conn,$first_name,$last_name,$email_id, $review_info);
closeConnection($conn);
}
?>
Loading

0 comments on commit ea4e785

Please sign in to comment.