PHPMyAdmin

Standard

For this project we needed to create 2 databases on the PHPMyAdmin server. One was needed to record usernames and passwords and the second was to record the data from the profiles.

This is the database for the usernames and passwords:

Screen Shot 2015-04-17 at 16.37.51

This was the structure for that database:

Screen Shot 2015-04-17 at 16.39.18

The second database was slightly more confusing. We had to remember to make an ID row and name all of the elements appropriately so we could accurately link this table to the form we will create using PHP. This is the second table:

Screen Shot 2015-04-17 at 16.41.25

This was the structure for this database:

Screen Shot 2015-04-17 at 16.41.37

To add this to our code we needed to create a connect.php file and link this PHPMyAdmin database to our code. This is what it looks like:

Screen Shot 2015-04-17 at 16.42.51

Below is the code from the signup.php and is where we linked our PHPMyAdmin to the code and created the form where the user would be able to submit their information and then it would save on the PHPMyAdmin and then would be echoed out on the homepage as a profile.

<?php require_once("../includes/session.php"); ?>
<?php require_once("../includes/connect.php"); ?>
<?php require_once("../includes/functions.php"); ?>
<?php include_once("../includes/templates/header.php"); ?>

<a name="formlogin"></a>
<a name="formsignup"></a>

<?php

    if(isset($_POST["post"])) {
        $fullname = ucfirst($_POST["full_name"]);
        $email = ucfirst($_POST["email"]);
        $age = ucfirst($_POST["age"]);
        $gender = ucfirst($_POST["gender"]);
        $personalprofile = ucfirst($_POST["bio"]);
        $location = ucfirst($_POST["location"]);
        $user_id = $_SESSION["user_id"];
        //$photoupload = ucfirst($_POST["photo_upload"]);
        //$cvupload = ucfirst($_POST["cv_upload"]);

        $query = "INSERT INTO newpost (user_id, full_name, email, age,
 gender, bio, location) VALUES ('{$_SESSION['user_id']}', 
'{$fullname}', '{$email}', '{$age}', '{$gender}', '{$personalprofile}',
 '{$location}')";
        $result = mysqli_query($connection, $query);

        if($result) {
            $_SESSION["message"] = "Post successful";
        } else {
            $_SESSION["message"] = "Something went wrong!";
        }
    } else 

    
            {
            $fullname = "";
            $email = "";
            $age = "";
            $gender = "";
            $personalprofile = "";
            $location = "";
            //$photoupload = "";
            //$cvupload = "";
        }

?>

<div class="container">
    <h3 class="post">New Post</h3>
    <div class="jumbotronlogin">
	    <div class="row">
	        <div class="col-md-12">
	            <div id="form-box">

                <form action="profile.php" method="post">
                    <div class="form-group">
	<label for="inputName">Full Name</label>
		<input type="text" class="form-control" name="full_name" id="exampleInputName2" placeholder="Full Name">
                    </div>
                    <div class="form-group">
	<label for="inputName">Email Address</label>
		<input type="text" class="form-control" name="email" id="exampleInputName2" placeholder="Enter Your Email Address">
                    </div>

                    <div class="form-group">
	<label for="inputName">Age</label>
		<input type="text" class="form-control" name="age" id="exampleInputName2" placeholder="Age">
                    </div>

                    <div class="form-group">
	<label for="inputName">Gender</label>
						<select class="form-control" name="gender">
				            <option>Please Select</option>
				            <option value="male">Male</option>
				            <option value="female">Female</option>
				        </select>
                    </div>

                    <div class="form-group">
	<label for="inputName">Personal Profile</label>
                    <textarea name="bio" class="form-control" rows="3" placeholder="250 Characters"></textarea>
                    </div>

                    <div class="form-group">
	<label for="inputName">Location</label>
		<input type="text" class="form-control" name="location" id="exampleInputName2" placeholder="Location">
                    </div>
                    
                    
                     <!--<div class="form-group">
                        <label for="exampleInputFile">Photo Upload</label>
                        <input type="file" id="exampleInputFile">
                    </div>

                    <div class="form-group">
                        <label for="exampleInputFile">CV Upload (optional)</label>
                        <input type="file" id="exampleInputFile">
                    </div>-->
                    <input type="submit" name="post" class="btn btn-default">
                </form>
                </div>
            </div>
        </div>
    </div>

</div>


<?php include_once("../includes/templates/footer.php"); ?>

The signup would mean that a user could sign in and if the data was different to what was on the PHPMyAdmin then it would not log them in.Screen Shot 2015-04-17 at 16.43.08

Advertisements

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