List of each functionality featured in Media Link

I thought this would be a useful blog to create in order to ensure that every functionality feature implemented is noted during the marking process.

1) Randomisation of user profiles:

$minicheckquery = “SELECT * FROM users ORDER BY RAND() LIMIT 1”;

2) View my Profile:

<a href=”profile.php?user=<?php echo $myprofile;?>”><?php echo $myfirstname; ?></a>

<?php
$profile = true;
require_once(‘connectpage.php’);
$user=$_GET[‘user’];

$checkquery = “SELECT * FROM users WHERE USERID=’$user'”;
$checkresult = mysqli_query($db_server, $checkquery) or die(mysqli_error($db_server));
if ($row = mysqli_fetch_array($checkresult))
{
$profilefirstname = $row[‘firstname’];
$profilelastname = $row[‘lastname’];
$profilecountry = $row[‘country’];
$profileareaofexpertise = $row[‘areaofexpertise’];
$profileusername = $row[’email’];
$profilepicurl = $row[‘profilepicture’];
}
require_once(‘homestart.php’);
require_once(‘cleanstring.php’);
require_once(‘encryptpage.php’);
?>

<?php
require_once(‘homeend.php’);
?>

3) Edit my Profile:

<?php
if ($profileusername == $username) {
?>

<a href=”#” data-reveal-id=”editprofile”>
<div id=”pencil”><a href=”editprofile.php?user=<?php echo $myprofile;?>”><img src=”pennn.jpg”></a></div>
</a>

<?php
}
else {
?>
<div id=”nopen”></div>
<?php
}
?>

<?php
require_once(‘connectpage.php’);
$editprofile = true;

$user=$_GET[‘user’];

$checkquery = “SELECT * FROM users WHERE USERID=’$user'”;
$checkresult = mysqli_query($db_server, $checkquery) or die(mysqli_error($db_server));
if ($row = mysqli_fetch_array($checkresult))
{

$profilepicture = $row[‘profilepicture’];
$firstnameedit = $row[‘firstname’];
$lastnameedit = $row[‘lastname’];
$emailedit = $row[’email’];
$check = $row[‘USERID’];
}

$detailsupdated = true;

require_once(‘homestart.php’);
require_once(‘cleanstring.php’);
require_once(‘encryptpage.php’);

?>

4) Upload a Profile Picture:

<?php
session_start();
require_once(‘connectpage.php’);
$id = $_POST[‘user’];

$target_dir = “php/images/”;
$target_file = $target_dir . basename($_FILES[“fileToUpload”][“name”]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST[“submit”])) {
$check = getimagesize($_FILES[“fileToUpload”][“tmp_name”]);
if($check !== false) {
$uploadOk = 1;
} else {
echo “File is not an image.”;
$uploadOk = 0;
}
}
// Check if file already exists
if (file_exists($target_file)) {
echo “Sorry, file already exists.”;
$uploadOk = 0;
}
// Check file size
if ($_FILES[“fileToUpload”][“size”] > 500000) {
echo “Sorry, your file is too large.”;
$uploadOk = 0;
}
// Allow certain file formats
if($imageFileType != “jpg” && $imageFileType != “png” && $imageFileType != “jpeg”
&& $imageFileType != “gif” ) {
echo “Sorry, only JPG, JPEG, PNG & GIF files are allowed.”;
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo “Sorry, your file was not uploaded.”;
// if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES[“fileToUpload”][“tmp_name”], $target_file)) {

$profilepicurl = basename( $_FILES[“fileToUpload”][“name”]);

$query = “UPDATE users SET profilepicture = ‘$profilepicurl’ WHERE USERID = $id”;
mysqli_query($db_server, $query) or die(“Insert failed. ” . mysqli_error($db_server));

$successphotouploaded = true;
require_once(‘homestart.php’);

} else {
echo “Sorry, there was an error uploading your file.”;
}
}
?>

5) Change Password:

<?php
session_start();
require_once (‘encryptpage.php’);
require_once (‘cleanstring.php’);
require_once (‘connectpage.php’);

$user=$_GET[‘user’];
$password1 = mysqli_real_escape_string($db_server, $_POST[‘newpassword’]);
$password2 = mysqli_real_escape_string($db_server, $_POST[‘repeatnewpassword’]);

if ($password1 <> $password2) { echo “Your passwords do not match.”;}
else { (mysqli_query($db_server,”UPDATE users SET password=’$password1′ WHERE USERID=’$user'”)); }

$passwordchanged = true;
require_once (‘homestart.php’);
mysqli_close($db_server);
?>

6) Encryption 

<?php

function encrypt($password)
{
$salt = “1g9”;
$salt2 = “7sn”;
$password = md5($salt . $password . $salt2);
return $password;
}

?>

7) Drop down selections (Area of Expertise + Country)

Links to the files, countriesedit.php and areaofexpertiseedit.php containing every option.

<?php
require_once(‘countriesedit.php’);
?>
<label for=”areaofexpertise”>Area of Expertise</label>
<?php
require_once(‘areaofexpertiseedit.php’);
?>

8) Log In

<?php
session_start();
require_once(‘../connectpage.php’);
$username = $_POST[‘username’];
$password = $_POST[‘password’];

$query = mysqli_query($db_server, “select * from users where email=’$username’ AND password=’$password'”);
$rows = mysqli_num_rows($query);
if ($rows == 1) {
$_SESSION[‘session’]=$username; // calling session username and starting it
header(“location: ../maphomepage.php”); // redirect to home page after logged in
} else {
$error = “Please enter correct username or password”;
echo $error;
}

9) Register

<?php
require_once(‘../connectpage.php’);
require_once(‘../cleanstring.php’);
require_once(‘../encryptpage.php’);

if (isset($_POST[‘submit’]))
{

// checking for errors

$message = “”;
if ($_POST[‘firstname’] == “”) $message.= “Please enter your First Name”;
if ($_POST[‘lastname’] == “”) $message.= “Please enter your Last Name”;
if ($_POST[’email’] == “”) $message.= “Please enter your Email Address”;
else
{
$email = $_POST[’email’];
$checkquery = “SELECT * FROM users WHERE email=’$email'”;
$checkresult = mysqli_query($db_server, $checkquery) or die(mysqli_error($db_server));
if ($row = mysqli_fetch_array($checkresult))
{
$message= “This email already exists”;
echo $message;
}
else
{
// THIS CODE CLEANS MY REGISTER FORM AND INSERTS MY USERS

$firstname = mysqli_real_escape_string ($db_server, $_POST[‘firstname’]);
$lastname = mysqli_real_escape_string ($db_server, $_POST[‘lastname’]);
$email = $_POST[’email’];
$country = $_POST[‘country’];
$areaofexpertise = $_POST[‘areaofexpertise’];
$password = $_POST[‘createpassword’];

$query = “INSERT INTO users (firstname, lastname, email, country, areaofexpertise, password) VALUES (‘$firstname’, ‘$lastname’, ‘$email’, ‘$country’, ‘$areaofexpertise’, ‘$password’)”;
mysqli_query($db_server, $query) or die(“Insert failed. ” . mysqli_error($db_server));
header(‘location: ../maphomepage.php’); //redirect to home page;
}
}
}

exit();

$message = “”;

if(isset($_POST[‘password’])) {
if ($_POST[‘password’] == “”) { $message.= “Please enter your password <br/>”; }

if ($_POST[‘repeatpassword’] == “”) { $message.= “Please repeat the password <br/>”; }

if (strlen($_POST[‘repeatpassword’]) < 6) { $message.= “Your password must be 6 characters or more <br/>”; }

if ($_POST[‘password’] != $_POST[‘repeatpassword’]) { $message.= “Passwords do not match <br/>”; }

if (!isset($_POST[‘recaptcha_challenge_field’])) { $error.= “<p class=’error’> You did not attempt the reCAPTCHA human verification. </p>”; }

if ($_POST[‘name’] == “”) { $message.= “Please enter your First Name <br/>”; }

if ($_POST[‘LastName’] == “”) { $message.= “Please enter your Last Name <br/>”;}

if ($_POST[‘EmailAddress’] == “”) { $message.= “Please enter your Email Address <br/>”;}

if ($_POST[‘username’] == “”) { $message.= “Please enter your username <br/>”;}

}
mysqli_close($db_server);
?>

10) Log Out

<?php
session_start();
session_destroy();
header(‘location: ../maphomepage.php’); //redirect to home page after log out;
?>

11) Other dynamically displayed user details (Hello, [Name] + Events and Conferences for a [Area of Expertise]) 

<a href=”profile.php?user=<?php echo $myprofile;?>”><?php echo $myfirstname; ?></a>

EVENTS AND CONFERENCES FOR A <?php echo $areaofexpertise;?>:

12) Mini Profile

<?php
$miniprofile = true;
require_once(‘connectpage.php’);

$minicheckquery = “SELECT * FROM users ORDER BY RAND() LIMIT 1”;
$minicheckresult = mysqli_query($db_server, $minicheckquery) or die(mysqli_error($db_server));
if ($row = mysqli_fetch_array($minicheckresult))
{
$miniprofilefirstname = $row[‘firstname’];
$miniprofilelastname = $row[‘lastname’];
$miniprofilecountry = $row[‘country’];
$miniprofileareaofexpertise = $row[‘areaofexpertise’];
$miniprofilepicurl = $row[‘profilepicture’];
//$minifeaturedwork = $row[‘featuredwork’];
$miniprofileid = $row[‘USERID’];
}
require_once(‘homestart.php’);
require_once(‘cleanstring.php’);
require_once(‘encryptpage.php’);
?>

<?php
require_once(‘homeend.php’);
?>

13) Landing Page

if ($_SESSION[‘session’] == “”)
{
$landing = true;
}
else
{
$landing = false;
}

<?php if($landing): ?>
$(document).ready(function() {
$(‘#landing’).foundation(‘reveal’, ‘open’);
});
<?php endif; ?>

<?php
if ($_SESSION[‘session’] == “”) {
?>
<style type=”text/css”>
body {
background: url(“lightsnew.jpg”) no-repeat center center fixed;
webkit-background-size: cover;
moz-background-size: cover;
o-background-size: cover;
background-size: cover;
}
</style>

 

Advertisements
This entry was posted in Code. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s