<?php
require_once('includes/dbconn.php');
error_reporting (E_ALL ^ E_NOTICE);
session_start();
$userid = $_SESSION['userid'];
$username = $_SESSION['username'];

?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Home</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
                <!--Header-->
        <div class="header">
            <div class="logo">
                <img src="images/logo.gif" alt="logo" />
            </div>
        </div>
        <!--Start of content-->
        <div class="content">
         <div class="padding">
            <div class="contentarea">
            <!--Video Player-->
                 <div class="video">
                    <div class="padding">
                    <video tabindex = "0" height="370px" width="480px" controls= "controls">
                      <source src='frontvid.mp4' />
                      <p>Download Safari to view this video</p>
                    </video>
                    </div>
                </div>
                    <!--registration page-->
              <div class="padding">
                <div class="place">

                        <?php


                    $reg ="<div class ='padding'>
                       <form method='post' action=''>
                       <table width='380' border='0' cellspacing='3' cellpadding='0'>
                       <tr>
                        <h2>Registration</h2>
                       </tr>
                       <tr>
                        Enter your details below and all fields are required
                       </tr>
                       <tr>
                        <td>First Name:</td>
                        <td><input type='text' name='fname' class='fields'/></td>
                       </tr>
                       <tr>
                        <td>Last Name:</td>
                        <td><input type='text' name='lname' class='fields'/><br></td>
                       </tr>
                       <td>Sex</td>
                       <td><select name='sex' class= 'sbtn'>
                              <option value='1'>Male</option>
                              <option value='2'>Female</option>
                            </select><br></td>
                       </tr>
                       <tr>
                        <td>Username:</td>
                        <td><input type='text' name='uname' class='fields'/><br></td>
                       </tr>
                       <tr>
                        <td>Password:</td>
                        <td><input type='password' name='pass' class='fields'/><br></td>
                       </tr>
                       <tr>
                       <td>Confirm Password:</td>
                       <td><input type='password' name='cpass' class='fields'/><br></td>
                       </tr>
                       <tr>
                       <td>Email:</td>
                       <td><input type='text' name='email' class='fields'/><br></td>
                       </tr>
                       <tr>
                       <tr>
                       <td>Confirm Email:</td>
                       <td><input type='text' name='cemail' class='fields'/><br></td>
                       </tr>
                       <tr>
                       <td></td>
                       <td><input type='submit' name='regbtn' value='Register' class='sbtn' /></td>
                       </tr>

                       </table>
                       </form>
                       </div>";
                       if(isset($_POST['register']))
                     {
                         echo $reg;
                         } 


                     if ($_POST['login']){
                      $username = $_POST['username'];
                     $password = $_POST['password'];

           if($username){
               if ($password){

                 $password = md5(md5("HJ87GHChgj".$password."kku89CHJGT"));
                   // makes sure login info is correct
                   $query = ("SELECT * FROM registration WHERE username='$username'");

                   if ($numrows == 1){
                       $row = mysql_fetch_assoc($query);
                       $dbid = $row['id'];
                       $dbuser = $row['username'];
                       $dbpass = $row['password'];

                       if ($password == $dbpass){
                    if ($username == $dbuser){
                               // set session info
                               $_SESSION['userid'] = $dbid;
                               $_SESSION['username'] = $dbuser;
                               echo "You have been logged in as <b>$dbuser</b>. <a href='./profile.php'>Click here</a>";
                    }

                       }

                       else
                        echo "You did not enter the correct password.";
                   }
                   else
                    echo "The username you entered was not found.";

                    mysql_close();
               }
               else
                echo"You must enter your password.";
           }
           else
             echo "You must enter your username.";
       }
                    //Registration details
                     $message = "";
                     if(isset($_POST['regbtn']))
                     {
                        $fname = $_POST['fname'];
                        $lname = $_POST['lname'];
                        $uname = $_POST['uname'];
                        $pass = $_POST['pass'];
                        $cpass = $_POST['cpass'];
                        $email = $_POST['email'];
                        $cemail = $_POST['cemail'];
                        $sex = $_POST['sex']; 

                if(empty($fname)){ $message .= "<strong>First name can't be empty</strong><br>";}
                if(empty($lname)){ $message .= "<strong>Last Name can't be empty</strong><br>";}
                if(empty($pass)){ $message .=  "<strong>Password can't be empty</strong><br>";}
                if(empty($cpass)){$message .=  "<strong>Confirm Password can't be empty</strong><br>";}
                if(empty($email)){$message .=  "<strong>E-mail can't be empty</strong><br>";}
                if(empty($cemail)){$message .=  "<strong>Confirm E-mail can't be empty</strong><br>";} 
                if(empty($sex)){$message .=  "<strong>Sex can't be empty</strong><br>";}       
                if(empty($message))
                {   

                        $fname = $_POST['fname'];
                        $lname = $_POST['lname'];
                        $uname = $_POST['uname'];
                        $pass = $_POST['pass'];
                        $cpass = $_POST['cpass'];
                        $email = $_POST['email'];
                        $cemail = $_POST['cemail'];
                        $sex =$_POST['sex'];

                        if($pass == $cpass)
                        {
                            if($email == $cemail)
                            {
                                $pass = md5(md5("HJ87GHChgj".$pass."kku89CHJGT"));
                                $query ="INSERT INTO registration (`username`, `password`, `first_name`, `last_name`, `email`, `sex`)
                                VALUES ('$uname', '$pass', '$fname', '$lname', '$email', '$sex')";
                                $result = mysql_query($query);

                                 echo "You've successfully registered you account now sign in to watch videos.";


                            }
                            else
                            echo "<strong>The E-mail addresses you entered are not the same</strong>";
                        }
                        else 
                            echo "<strong>The Passwords are not the same</strong>";


                            }
                    else
                    {
                        echo $message. $reg;
                    }

                     }

                 ?>   

                  </div>
              </div>
           </div>
         </div>
            <!--Login-->
            <div class="login">
            <form method="post" action="">
            <div class="padding"><h2>Login</h2></div>
            <div class="padding">Username:  <input type="text" name="username" class="fields" /></div>
            <div class="padding">Password: <input type="password" name="password" class="fields" /></div>
            <div class="padding"><input type="submit" name="login" value="Login" class="sbtn" /></div>
            <div class="padding">New member? Register here</div>
            <hr />
            <div class="padding">
            <input type="submit" name="register" value="Register" class="sbtn"  />
            </div>
            </form>
            </div>

            <!--end of content -->
        </div>
        <div class="clear" ></div>
        <div class="padding">&nbsp;</div>        
        <div class="footer">
          <div class="fright">
        <div class="padding">        
        e-Learning Tool for Catering<br/>
        </div>
        </div>
        </div>
</body>
</html>

Recommended Answers

All 2 Replies

Just dumping code, won't get you an answer. What is supposed to happen, what doesn't, any errors?

yh, and assigning all these html to one variable is a really bad practise

commented: yeah true. +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.