Hi Guys hope that you are all well.

I have statred to use the bootstrap framework to create my website, I have got all of my pages working and linking correctly using bootstrap and its looking pritty awesome now!

I have found a video on youtube to help me to crreate my register form (this is the link) Click Here

Below is my bootstrap code

<!DOCTYPE html> 
<html> 
    <head> 
        <title>Richard Hemmings  </title>
        <meta name="viewpoint" content="width=device-width, intail-scale=1.0"> 
        <link href = "css/bootstrap.min.css"rel = "stylesheet"> 
        <link href = "css/stylesheet.css" rel = "stlesheet"> 

        </head>
        <body>

            <div class = "navbar navbar-inverse navbar-static-top">
                <div class = "contrainer"> 

 <?php
include('inc/header.php'); ?>





    <div class="container padding-top-10"> 
    <div class="panel panel-deafult"> 
    <div class "panel-heading">Registration</div>
            <P> Please fill in the form below to register for an account with this website,you need to fill in ALL feilds to enable to register!</P>
            </div>
            <form> 
                <div class= "row"> 
               <input type="text" class="form control;" id= "UserName" placeholder="User Name"/></input>
                <input type="password" class="form control;" id= "Password" placeholder="Password"/></input>
                 <input type="password" class="form control;" id= "Confirm Password" placeholder="Confirm Password"/></input>
                  <input type="text" class="form control;" id= "Name" placeholder="Name"/></input>

                </div> 
                <input type="submit" value="Register">
    <input type="hidden" name="token" value="<?php echo Token::generate(); ?>">
            </form>




                <div class = "navbar navbar-default navbar-fixed-bottom"> 

                <div class = "container"> 
                    <P class = "navbar-text">Site build and belongs to Richard Hemmings (C) 2015</P> 

                </div> 

                </div>








       <script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
       <script src = "js/bootstrap/js" ></script>




        </body>

        </html> 

Here is the PHP code that I want to use but I get an error message everytime I want to use it, this is the code that I used when I crated a regsiter page for another website that I created a few months ago. Please note that the form feilds are not the same as in the code above!

<?php

if(Input::exists()) {

    if(Token::check(Input::get('token'))) {
        $validate = new Validate();
        $validation = $validate->check($_POST, array(
            'username' => array(
                'required' => true,
                'min' => 2,
                'max' => 20,
                'unique' => 'users'),
            'password' => array(
                'required' => true,
                'min' => 6),
            'password_again' => array(
                'required' => true,
                'matches' => 'password'),
            'name' => array(
                'required' => false,
                'min' => 2,
                'max' => 50)
        ));

        if($validation->passed()) {
            $user = new User();

            $salt = Hash::salt(32);

            try {
                $user->create(array(
                    'username'  => Input::get('username'),
                    'password'  => Hash::make(Input::get('password'), $salt),
                    'salt'      => $salt,
                    'name'      => Input::get('name'),
                    'joined'    => date('Y-m-d H:i:s'),
                    'group'     => 1
                ));

                Session::flash('home', 'You have been registered and can now log in!');
                Redirect::to('index.php');

            } catch(Exception $e) {
                die($e->getMessage());
            }

        } else {
            foreach($validate->errors() as $error) {
                echo $error, '<br>';
            }
        }
    }
}
?>

<form action="" method="post">

    <div class="field">
        <label for="username">Choose a username</label>
        <input type="text" name="username" id="username" value="<?php echo escape(Input::get('username')); ?>">
    </div>

    <div class="field">
        <label for="password">Choose a password</label>
        <input type="password" name="password" id="password">
    </div>

    <div class="field">
        <label for="password_again">Enter your password again</label>
        <input type="password" name="password_again" id="password_again">
    </div>

    <div class="field">
        <label for="name">Your name</label>
        <input type="text" name="name" id="name" value="<?php echo escape(Input::get('name')); ?>">
    </div>

    <input type="submit" value="Register">
    <input type="hidden" name="token" value="<?php echo Token::generate(); ?>">
</form>

If anyone could help me it would be much appreicated as I really want to try and get this done asap.

Sorry again for been such apain

Regards

Richard

Recommended Answers

All 7 Replies

Member Avatar for diafol

The php code looks very much like Laravel. Is it? If you're using a php framework, as it appears that you are, please tell use which one.

to be honest i have no idea

Member Avatar for diafol

to be honest i have no idea

But in your opening salvo, you said:

Here is the PHP code that I want to use but I get an error message everytime I want to use it, this is the code that I used when I crated a regsiter page for another website that I created a few months ago.

I can't understand how you can use this code unless you've got a PHP framework installed. So you've used it successfully before - then find out which framework it was. As I said, it looks like a bit like Laravel - maybe an early version - but it may be something else entirely.

These frameworks tend to use MVC, so your 2nd snippet is at odds with this.

ok i will do. I cant remember where I had the code from last time. To be honest. I can remember I did not have a PHP framework installed and it worked perfect

Member Avatar for diafol

To be honest. I can remember I did not have a PHP framework installed and it worked perfect

That's impossible as there are static calls all over the place. It may not be a full blown framework, but you've got the guts of it there with Input::xxx, Toekn::xxx, Redirect::xxx etc.

When I try and load the page on my local host I get the following error

Fatal error: Class 'Input' not found in C:\xampp\htdocs\register.php on line 19

Member Avatar for diafol

Ok, there you go. It's looking for the class 'Input' with the static method 'get'. So find out which framework you were using. You will never be able to use this code without the original "framework" files, so any further discussion here is pretty pointless until you sort that out.

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.