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
https://forums.phpfreaks.com/topic/276228-registerlogin/
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
https://forums.phpfreaks.com/topic/276228-registerlogin/#findComment-1421446
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
https://forums.phpfreaks.com/topic/276228-registerlogin/#findComment-1421452
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
https://forums.phpfreaks.com/topic/276228-registerlogin/#findComment-1421460
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.