SmItH197 / SteamAuthentication

A simple PHP Authentication that enables steam users to log into their steam account to access content!
MIT License
446 stars 147 forks source link

Weird steamid when sending forms to database #248

Closed tholeb closed 5 years ago

tholeb commented 5 years ago

Hi! I'm experiencing a weird issue when i send the steamid via sql form (pdo). For exemple, my steamid is: 76561198095981948 and when i send my form, on the database, my steamid is 2147483647 (that is not a steam id at all, but return to someone, not me...). I echoed the steamid, and he was right. And that's weird because, when the users log into my website, they got the right steamid, but not in this page 🤔 .

(Here is a part of my code (only where there is the form action), if you need it.)


<?php
if (isset($_POST["submit"]))
 {
     #retrieve file title
        $title = $_POST["title"];
        $steamid = $_POST["steamid"];

    #file name with a random number so that similar dont get replaced
     $pname = rand(1000,10000)."-".$_FILES["file"]["name"];
     $allowed = array("image/jpeg", "image/gif", "image/png");

    #temporary file name to store file
    $tname = $_FILES["file"]["tmp_name"];

     #upload directory path
$uploads_dir = 'assets/img/gallery/';
    #TO move the uploaded file to specific location
    move_uploaded_file($tname, $uploads_dir.'/'.$pname);

    #sql query to insert into database
    $sql = "INSERT INTO images (CreationTimestamp,title,image,steamid,steamname) VALUES(NOW(),'$title','$pname','".$steamprofile['steamid']."','".$steamprofile['personaname']."')";

    if($bdd->query($sql)){

    echo "<script>console.log('File Sucessfully uploaded'),</script>";
    }
    else{
        echo "Error";
    }
}

?>```
Any answers ?
Thanks.
bman46 commented 5 years ago

Your SQL data type is incorrect, int maxes out at 2147483647. So try using BigInt instead of int.

tholeb commented 5 years ago

Thanks, i will try.

EDIT: It's good thanks.