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.
[2026-7-18. : 2:27 am]
Symmetry -- https://staredit.net/topic/18903/ THE REVIEWS ARE HERE! "ok these are pretty good memes" - ssj9Kevin
[2026-7-17. : 2:58 pm]
Ultraviolet -- Symmetry
Symmetry shouted: Man I wish we had this tech back in the day when people played ums lmao
fr fr
[2026-7-17. : 2:39 am]
Symmetry -- Man I wish we had this tech back in the day when people played ums lmao
[2026-7-16. : 6:28 am]
NudeRaider -- EUD actions, specifically. The conditions remained. Today we can even have actions again, but they're all virtualized/whitelisted (not sure on the actual technical implementation) so you can only use them for specific intended purposed, not arbitrary code injections.
[2026-7-16. : 6:26 am]
NudeRaider -- I mean yes, maps - through EUDs - were theoretically able to do that as well, but that was patched quickly.
[2026-7-16. : 6:25 am]
NudeRaider -- Symmetry
Symmetry shouted: Ohhh imagine a SC map that could delete itself
not the map, the editor
[2026-7-16. : 2:28 am]
Symmetry -- I vaguely remember Voy doing some ACE back in the day, but I had no idea EUDs could do that kind of shit. I am very much catching up on the technology
[2026-7-16. : 2:28 am]
Symmetry -- Ohhh imagine a SC map that could delete itself
[2026-7-15. : 8:51 pm]
NudeRaider -- Symmetry
Symmetry shouted: NudeRaider Is EUD editor capable of writing shit onto the player's harddrive? That seems like it would be dangerous
yeah an editor that isn't allowed to write files sounds rather pointless, so I'd assume it can. Like most other programs too btw. and yes, obviously that's dangerous, but also kinda necessary. MS introduced that virtualization for exactly that reason.
[2026-7-15. : 4:10 am]
Ultraviolet -- I don't think so. I think they shut that shit down after 1.16, maybe even earlier
Please log in to shout.


Members Online: Roy