Jump to content

register/login


cabbie

Recommended Posts

In trying to program a register login site I have tried every combo possible. Even with simple code the username is not passed to the login page IE echo $username yields nothiing .  What would cause this? Actual link to try.  In test database  ollie & cab1234 are valid,,  http://libertarian-forum.com/sim/login.php

 

Codes:

<form action = "loginscript.php" method = "post">

Username : <input type = "text" name = "username">

Password : <input type = "password" name = "password">
$username = $_POST['username'];
echo $username;
<input type = "submit" value = "Login">

</form>

 

<?php
include 'main.php';
include 'connect.php';


$username = $_POST['username'];
echo $username;
$password = md5($_POST['password']);

$query = mysql_query("SELECT id,username, password FROM users WHERE username = '$username'");

if(!$query)

echo "There is no such user with the entered username";

else{

$details = mysql_fetch_assoc($query);

$usr = $details['username'];

$pass = $details['password'];

$id = $details['id'];

if($pass == $password){

$_SESSION['id'] = $id;

header("Location: loggedin.php");

}

else

echo "The username and password combination does not match";

}

?>

Link to comment
Share on other sites

Sorry Maq With the condition of this Nation I am very political active and when I am wasting time on a simple problem I need a quick answer. This was a quick join the forum and post. Also at the time I had several issue on this old senile mind LOL

 

Yes with the includes commented out it gives the same result..

Link to comment
Share on other sites

I just cut and pasted your code, commented out the two includes, added a print_r($_POST) ran it on my local machine and I get the expected results:

Array ( [username] => davidannis [password] => test ) davidannisThere is no such user with the entered username

try print_r($_POST); before and after the includes.

Link to comment
Share on other sites

So, after the include print_r($_POST) shows a value in $_POST['username'] but you can not echo it with?


$username = $_POST['username'];

echo $username;

FWIW: you should salt (add some unique per user characters) the password and use a more up to date function than md5.

 

Anyone else have any ideas on the inability to echo the username?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.