[SA:MP UCP help]
#1

Hi. I created a login box on my page

http://vestigedayz.com/ucp/testplm.html


I want to connect it to my database, and when a player presses Loghează-te ! it should redirect him to another page (/index/ucp/characterpage)


How can I make it?

PHP Code:
.login 
    
positionabsolute;
    
top75%;
    
left50%;
    
margin: -150px 0 0 -150px;
    
width:300px;
    
height:300px;
}
input 
    
width100%; 
    
margin-bottom10px
    
backgroundrgba(0,0,0,0.3);
    
bordernone;
    
outlinenone;
    
padding10px;
    
font-size13px;
    
color#fff;
    
text-shadow1px 1px 1px rgba(0,0,0,0.3);
    
border1px solid rgba(0,0,0,0.3);
    
border-radius4px;
    
box-shadowinset 0 -5px 45px rgba(100,100,100,0.2), 0 1px 1px rgba(255,255,255,0.2);
    -
webkit-transitionbox-shadow .5s ease;
    -
moz-transitionbox-shadow .5s ease;
    -
o-transitionbox-shadow .5s ease;
    -
ms-transitionbox-shadow .5s ease;
    
transitionbox-shadow .5s ease;
}
input:focus box-shadowinset 0 -5px 45px rgba(100,100,100,0.4), 0 1px 1px rgba(255,255,255,0.2); }
<
div class="login">
    <
form method="post">
        <
input type="text" name="u" placeholder="Username" required="required" />
        <
input type="password" name="p" placeholder="Password" required="required" />
        <
button type="submit" class="btn btn-primary btn-block btn-large">Logheaz&#259;-te !</button>
    
</form>
</
div

Thanks
Reply
#2

Post it in Server Help. This is the wrong section for such kind of a post.
Reply
#3

Ok, thanks
Reply
#4

Bullshit.
This is only samp indirectly.

This ssction ist okay.
Watch this https://sampforum.blast.hk/showthread.php?tid=290824 - its perfect
Reply
#5

http://vestigedayz.com/ucp/login.php

It gives me error

Warning: mysql_connect(): Connection timed out in /home/vestiged/public_html/ucp/config.php on line 3
I can't connect to the server!


Everything is good, login details.


PHP Code:
<?php 
    $connect 
mysql_connect("93.119.26.250""zp_hid11784""password ") or die("I can't connect to the server!"); //connecting to mysql, change setting if you have to 
    
mysql_select_db("zp_hid11784") or die ("I can't find the database!"); //selecting database, change name to your database name! 
     
    
function sanitize($string//function for sanitize from xss and mysql and csrf... Thanks to XFlawless 
    
{  
        
$string strip_tags($string);  
        
$string mysql_real_escape_string($string);  
        return 
$string;  
    } 
?>
Reply
#6

If you're writing this UCP from scratch, then I recommend you NOT to use mysql_* functions since they're deprecated and it is most likely you will leave backdoors (if you're not experienced, of course).
Use mysqli or PDO instead.

http://stackoverflow.com/questions/1...nctions-in-php
Reply
#7

I used a tutorial

Now it works, but it won't show login box.

PHP Code:
<?php 
include("config.php"); //including our config.php where is connecting to mysql... 
session_start(); //starting session for profile.php (Dunno how to explain better) look little down 
error_reporting(0); //without this we will always get some stupid notice that variable isn't defined.... 
$submit $_POST['submit']; //variable for submit button, in this variable we save button that player press in <input type='submit' name="submit" value='Login' />.... 
$username sanitize($_POST['username']); //variable for username, in this variable we save text that user type in <input type="text" name="username".... 
$password sanitize($_POST['password']); //variable for password, in this variable we save text that user type in <input type="password" name="password".... 
if($submit//if he press submit button 
{     
    if(
$username && $password//if he type both of username and password not just one of them 
    

        
$query mysql_query("SELECT username, password FROM users WHERE username = '$username'"); //selecting user name and password, change it to your field names,  chage users to your table name, $username means username that he type... 
        
if(mysql_num_rows($query) == 1//if user exists 
        

            while(
$row mysql_fetch_assoc($query)) //loop thought table that we select in mysql_query 
            

                
$dbusername $row['username']; //setting dbusername as variable from table, change 'username' to your field! 
                
$dbpassword $row['password']; //setting dbpassword as variable from table, change 'password' to your field! 
            

            if(
$username == $dbusername && $password == $dbpassword//if username is same as one from table and if password is the same as one from table... 
            

                
$_SESSION['username'] = $dbusername//setting session username to one from table, this is useful if you login, that restart your browser and than you go in url where is your profile.php... Anyway this is useful :D 
                
echo header('location: profile.php'); //redirecting user to his profile page (profile.php) 
            

            else echo 
"Wrong password!"//else if user type wrong password he will get this... 
        

        else echo 
"Username doesn't exist!"//if username doesn't exist in table user will get this 
    

    else echo 
"Type name and password!"//else if user doesn't type all fields he will get this... 

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Basic UCP</title>
nuj..
<form action='login.php' method='POST'> 
<input type="text" name="username" value='<?php echo $username?>'/> 
<input type="password" name="password"/> 
<input type='submit' name="submit" value='Login' /> 
</form>
</head>
</html>
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)