0

I have been looking for a mistake in my php and mysql for the past 5 hours. I have no clue what I have done wrong or if there is just a problem with my mamp. I think it may be a problem with my mamp. This is where I believe the problem would be taking place. Basically my goal with all of this was to make so when I click submit it displays the username and password that the user entered in the two fields. Thanks.

site/core/init.php

<?php
session_start();
error_reporting(0);

require 'database/connect.php';
require 'functions/users.php';

$errors = array();
?>

site/login

<?php
include 'core/init.php';
if(empty($_post) === false) {

$username = $_post['username'];
$password = $_post['password'];

echo $username, ' ', $password;

}
?>

site/core/database/users.php

NOTHING HERE YET

site/includes/widgets/logins

        <aside>         
            <div class = "rightsidebar">
                <h2>Log in/Register</h2>
                <form action = "login.php" method = "post">
                    <ul id = ".login">
                        <li>
                            Username:<br>
                            <input type = "text" name = "username">
                        </li>
                        <li>
                            Password:<br>
                            <input type = "password" name = "password">
                        </li>
                        <li>
                            <input type = "submit" value = "Log In">
                        </li>                                                       
                        <li>
                            <a href = "register.php"><p>Register</p></a>
                        </li>                       
                    </ul>
                </form>
            </div>
        </aside>

site/core/database/connect.php

  <?php
  mysql_connect('localhost', 'root', 'root');
  mysql_select_db('lr');



  ?>
bendouglas
  • 147
  • 8
  • Is there any error message? – Harry Dec 25 '13 at 19:10
  • Yeah, what goes wrong where? What doesn't work? – Pekka Dec 25 '13 at 19:11
  • 1
    [**Please, don't use `mysql_*` functions in new code**](http://bit.ly/phpmsql). They are no longer maintained [and are officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). See the [**pink box**](http://j.mp/Te9zIL)? Learn about [*prepared statements*](http://j.mp/T9hLWi) instead, and use [PDO](http://php.net/pdo) or [MySQLi](http://php.net/mysqli) - [this article](http://j.mp/QEx8IB) will help you decide which. If you choose PDO, [here is a good tutorial](http://j.mp/PoWehJ). – h2ooooooo Dec 25 '13 at 19:12
  • 1
    `$_POST`, not `$_post`. http://stackoverflow.com/questions/2749781/why-are-functions-and-methods-in-php-case-insensitive – Jessica Dec 25 '13 at 19:14
  • A number of issues - you use a comma in your call to `echo`, i think you wanted to use a period `.` here (for glueing strings together). You gave an element an `id` beginning with a period `.` - this is not valid for `id` properties/attributes. – SquareCat Dec 25 '13 at 19:14
  • `echo` can be used with commas too – u_mulder Dec 25 '13 at 19:16
  • I have never go ten an error message when using it just when I hit submit it goes to login.php and then displays nothing – bendouglas Dec 25 '13 at 19:19

1 Answers1

0

Change your $_post with $_POST

Also, in development environment, you better use error_reporting(E_ALL); than error_reporting(0); At least you will see what is going wrong.

MillaresRoo
  • 3,808
  • 1
  • 31
  • 37