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.
[10:02 pm]
Symmetry -- I was really just figuring out how to compile
[10:02 pm]
Symmetry -- I didn't make it do anything
[09:17 pm]
Ultraviolet -- hell yeah. did you have trouble making the button functional, or just haven't gotten there yet?
[08:29 pm]
Symmetry -- I made the marine shoot lasers and gave the medic a nonfunctional button
[08:07 pm]
Ultraviolet -- Symmetry
Symmetry shouted: I did my first EUD thing today. Feels like me finding arsenal at age 8 again
haha for sure. in some ways it's even more exciting because you can play EUD maps on regular battle.net, don't need to convince someone to download your mod to play with you. what did you do?
[06:47 pm]
Symmetry -- I did my first EUD thing today. Feels like me finding arsenal at age 8 again
[03:20 pm]
l)ark_ssj9kevin -- le reddit
[02:55 pm]
Moose -- >reddit :rip2:
[02:07 pm]
IskatuMesk -- reddit 💀
Please log in to shout.


Members Online: RIVE