Board index   FAQ   Search  
Register  Login
Board index PHP PHP General

[Help] Login system

General discussions related to php

Moderators: macek, egami, gesf

[Help] Login system

Postby ganjaboss » Sun Jan 19, 2014 1:17 pm

Hello all coders out there! :)
Well i'm new in this coding thing, and i'm not good at it - at all...
So i thought maybe some of you could help me out :)

Here is my code..

<?php

session_start();

?>

<html>
<head>
<title>Login</title>
</head>
<body>


<form action="login.php" method="post">
<fieldset>
<legend>
<div class="logo">

<span id="logo_holder">
<a href="localhost/login.php">
<img src="logo.png" width="176" height="44">
</a>
</span>
</div>
</legend>
Username: <input type="text" name="username"/><br/>
Password: <input type="password" name="password"/><br/>
<input type="submit" name="submit" value="Login"/>
</fieldset>
</form>

<?php

include 'config.php';
mysql_connect($host, $user, $password) or die(mysql_error());
mysql_select_db($database) or die(mysql_error());

if ($_POST['submit']) {

//Get Form-Data
$myusername = $_POST['username']();
$mypassword = $_POST['password']();

//Check The Fields
if ((!$myusername) || (!mypassword) ) {

echo "Please fill in all fields!";
exit;

}

//Check the form in the db



}
?>
</body>

</html>


And my config..


<?php

$user = "root";
$host = "localhost";
$password = "";
$database = "userdb";
$usertable = "users";

?>

Check out the picture..
http://i.imgur.com/r2rUdfH.png



What can cause this, and what have i done wrong? :P
Thanks in advance!
ganjaboss
New php-forum User
New php-forum User
 
Posts: 1
Joined: Sun Jan 19, 2014 1:04 pm

Re: [Help] Login system

Postby MarioParty » Sat Feb 08, 2014 9:42 am

Nothing wrong, you just need to check that the variable has been defined, otherwise PHP can't access it.

Replace
Code: Select all
if ($_POST['submit']) {

with
Code: Select all
if (isset($POST['submit'])) {
MarioParty
New php-forum User
New php-forum User
 
Posts: 42
Joined: Tue Aug 02, 2011 2:52 am


Return to PHP General

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.