help on php please.
#1

hey there,
i was trying to make an ucp but im kinda new to this php / css and other stuff so i need some help out if you guys could , now the problem is that i have created an login system and also the checker if the player exists on a mysql database so , this part works okay the problem is i've created another style.css where i have couple tables and now i dont know how to direct for example once the player was checked if password and user matches to redirect him to those tables (styles2.css) ?? how to please help me out.

this how i check if player's password is same as he wrote also the username
Код HTML:
<?php
   
   $username = $_POST['user'];
   $password = $_POST['pass'];

   $username = stripcslashes($username);
   $password = stripcslashes($password);
   $username = mysql_real_escape_string($username);
   $password = mysql_real_escape_string($password);

   mysql_connect("localhost","root","");
   mysql_select_db("dbtest");

   $result = mysql_query("select * from username where PlayerName = '$username' and password = '$password'") 
                       or die("Failed to query database".mysql_error());

    $row = mysql_fetch_array($result);
 
    if ($row ['username'] == $username  && $row ['password'] == $password ) 
    {
    	echo "Login Sucess".$row['username'];
        
    } else {
    	echo "Failed to Login";
    }
    
?>
if you need the tables let me know.
Reply
#2

style2.css is a css file that you include in a page, you can't redirect someone to a css file... but you can redirect someone to the page where you included the css file using
PHP код:
header("location: page.php"); 
Why don't you read some tutorials before starting to work on an UCP? Those are basic things that you ask...
Reply
#3

oh i tried to locate it somewhere but i located it to .css file as you said its not possible -_- im dump xD but thanks mate you saved my ass , can you please also help me on password hash - i save on hashed way the passwords on my database so and i dont know how to load the password hash on the php , can you help me ? thanks mate.
Reply
#4

I can't just write you the code here because you won't learn too much, you will probably copy it, but I'll give you some help.

First, don't use mysql, use mysqli or PDO, mysql is old.

Check this out to learn how to load the password: https://www.w3schools.com/php/php_mysql_select.asp
and this: http://php.net/manual/ro/mysqli.query.php

This is how you should do it, load the hash from the database that you saved once he registered then get his input again, the password that he wrote in the database and hash it, again, then compare it with the hash that you got from the database.

If you also want this to work with SAMP then you will need to make the hash upper case, use
PHP код:
strtoupper(string); 
to do that.
Read more here: http://php.net/manual/ro/function.strtoupper.php
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)