Staredit Network > Forums > Technology & Computers > Topic: Me again with PHP problem :D
Me again with PHP problem :D
Nov 30 2008, 9:08 pm
By: Devourer  

Nov 30 2008, 9:08 pm Devourer Post #1

Hello

Hi there... first of all: thanks for the support and help
second: I've got 2 small problems again:


#1: In the Input-text is my server address enterd... why? (it's automatly enterd! when i'm opening that page)
#2: Why is there always standing "You are logged in now"? it just should stay there when the password and username is true...
(im talking about my login page)

here is it: login.php

<?php

session_start();

echo "<form action='?act=login' method='post'>"
."Username: <input type='text' name='user' size='30'><br>"
."Password: <input type='password' name='pass' size='30'><br>"
."<input type='submit' value='Login'>"
."</form>"
."</br> <a href=index.php> Index </a>";


$pass = md5($_POST[pass]);
$user = $_POST[user];

//Connecting to database
$connect = mysql_connect("localhost", "browsergamesc", "------------------------------------------------------");
if(!$connect){
die(mysql_error());
}

mysql_select_db("browsergamesc",$connect);

$search = "SELECT * FROM users WHERE username='$user'";
$res = mysql_query($search) OR die(mysql_error());

$check = mysql_fetch_array($res);

if($check[username] == $user && md5($check[password]) == $pass)
{
$_SESSION[login] = TRUE;
$_SESSION['user'] = $user;
$_SESSION['pass'] = $pass;
$_SESSION['geld'] = $check['geld'];
echo "</br>You are now Logged in! <a href=index.php> </br>Back to Index </a>";
}
else
{
echo "</br>";
echo "</br> Wrong username or password";
session_destroy(); }

?>


Help me pls, thanks



Please report errors in the Staredit.Network forum.

Dec 1 2008, 3:21 am Matt Burch Post #2



Code
if($check[username] == $user && md5($check[password]) == $pass)

You store unencrypted passwords in your database? Very insecure.

Code
$pass = md5($_POST[pass]);
$user = $_POST[user];

need to change that to this:
Code
$pass = md5($_POST['pass']);
$user = $_POST['user'];


And...

Code
if($check[username] == $user && md5($check[password]) == $pass)

Need to change that to this:
Code
if($check['username'] == $user && md5($check['password']) == $pass)


It is thinking that those values are variables, which have null in them. Which will result in showing it every time.

Edit:
And in response to your first problem. That is your cache or something. Which browser are you using? (Auto-fill is on?)

Post has been edited 1 time(s), last time on Dec 1 2008, 3:54 am by Matt Burch.



None.

Dec 1 2008, 2:10 pm Devourer Post #3

Hello

Quote from Matt Burch
Code
if($check[username] == $user && md5($check[password]) == $pass)

You store unencrypted passwords in your database? Very insecure.

Code
$pass = md5($_POST[pass]);
$user = $_POST[user];

need to change that to this:
Code
$pass = md5($_POST['pass']);
$user = $_POST['user'];


And...

Code
if($check[username] == $user && md5($check[password]) == $pass)

Need to change that to this:
Code
if($check['username'] == $user && md5($check['password']) == $pass)


It is thinking that those values are variables, which have null in them. Which will result in showing it every time.

Edit:
And in response to your first problem. That is your cache or something. Which browser are you using? (Auto-fill is on?)

The first part I don't understand, sorry
to your help to question2....
it didn't really helped... any other idea?

to your help to question1... Firefox, and if autofill, I don't know, I didn't find anythign about Auto-fill.

and something else, I made a shoutbox with a color-selection... how to color a word INSIDE a selection-option? I tried it and it didn't worked... here is my shoutbox.php

Shoutbox.php
<?php



//This will start a session
session_start();

$username = $_SESSION['user'];
$password = $_SESSION['pass'];
$geld = $_SESSION['geld'];





echo "Welcome ".$_SESSION['user']." (<a href=logout.php>Logout</a> | <a href=members.php> Members</a> | <a href=index.php> Index</a>)";
echo "</br>";
echo "<br>";



$con = mysql_connect("localhost","browsergamesc","----------------------");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("browsergamesc", $con);

$result = mysql_query("SELECT * FROM shoutbox ORDER BY `id2` DESC LIMIT 0 , 5");


while($row = mysql_fetch_array($result))
{
echo "<font color='0000FF'> " . $row['time'] . " </font>- ";
echo "<font color='66FF00'> " . $row['username'] . " </font>- ";
echo "<font color=' " . $row['color'] . " '> ";
echo " " . $row['message'] . " </font> </br>";
}


echo '<form action="insertshout.php" method="post"></br>';
echo '<select name="color" size="">';
echo '<option value="000000"> <font color="000000"> Black </font></option>';
echo '<option value="FF0000"> <font color="FF0000"> Red </font></option>';
echo '<option value="00CC00"> <font color="00CC00"> Green </font></option>';
echo '<option value="0000FF"> <font color="0000FF"> Blue </font></option>';
echo '</select>';
echo ' - ';
echo 'Message: <input type="text" name="message" /> </br>';
echo '<input type="submit" />';
echo '</form>';

?>

Help please :)



Please report errors in the Staredit.Network forum.

Dec 1 2008, 8:52 pm Matt Burch Post #4



Like i said your variables are null:
$check[user] = null;
$pass = null;
$check[pass] = null;
$user = null;

An easier way to fix this is to add some more if statements.

Code
if (count($_POST) > 0)
{
   $pass = md5($_POST[pass]);
   $user = $_POST[user];
}

...
...

$search = "SELECT * FROM users WHERE username='$user'";
$res = mysql_query($search) OR die(mysql_error());

if ($res)
{

   $check = mysql_fetch_array($res);

   if($check[username] == $user && md5($check[password]) == $pass)
   {
       ...
       ...
   }
}




None.

Dec 1 2008, 8:59 pm Devourer Post #5

Hello

Thanks, I'll try it tomorrow, I will edit the post if when I've got results...



Please report errors in the Staredit.Network forum.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[05:47 pm]
NimoStar -- If its any consolation, the human brain would still mop the floor with this bot if it wasn't limited by the mechanical interface
[05:34 pm]
NimoStar -- Well. The bot didn't come up with any new strategy. It just has superhuman micro. Hard to beat that. I reckon even the simplest dedicated chess engines are unbeatable for humans now.
[02:13 pm]
Oh_Man -- all g
[10:54 am]
NudeRaider -- Oh_Man
Oh_Man shouted: NudeRaider did u watch the entire video? it's not one game. it's currently dominating the ladder at number 1 position. do ur research first!
Oops, caught me there, no I haven't. :( I was imagining how the game went. Sorry for that. Watching it now. brb
[10:52 am]
NudeRaider -- NimoStar
NimoStar shouted: They were not "Unprepared" that was their fifth loss in a row against the bot. The other replays are also available
that doesn't mean he was prepared. When humans come around with new strategies it often takes weeks until the pros figure out how to shut it down. Oh_Man that's certainly a way more convincing argument for micro being "too good to beat".
[09:43 am]
DiearAnother -- wirefram
[08:35 am]
NimoStar -- Well, pros showed that long ago... half of zerg pros just ling muta rush
[08:35 am]
NimoStar -- " its shown is that you can trade 1000's of apm to make up for lack of strategy"
[03:25 am]
Oh_Man -- https://youtu.be/R_6bsf9REkY anyone ever tried playing SC ghost?
Please log in to shout.


Members Online: l)ark_ssj9kevin, O)FaRTy1billion[MM]