I am quite new to php and mysql. I have added a registration field "Referral" to my index. I added it the easiest way i came up with was to just add ref row in player table. When the user inputs a referral during the registration it gets stored to the database without checking if username inputed by the new user is valid or not.
if (isset($_POST['register'])) {
$username = $_POST['username'];
$password = hash('sha256', $_POST['password']);
$email = $_POST['email'];
$ref = $_POST['ref'];
$sql = mysqli_query($connect, "SELECT username FROM `players` WHERE username='$username'");
if (mysqli_num_rows($sql) > 0) {
echo '<br /><div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' . lang_key("username_taken") . '</div>';
} else {
$sql2 = mysqli_query($connect, "SELECT email FROM `players` WHERE email='$email'");
if (mysqli_num_rows($sql2) > 0) {
echo '<br /><div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' . lang_key("email_taken") . '</div>';
} else {
$money = $row['startmoney'];
$gold = $row['startgold'];
$themeid = $rowtd['id'];
$langcode = $rowld['langcode'];
$insert = mysqli_query($connect, "INSERT INTO `players` (username, password, email, ref, money, gold, theme, language) VALUES ('$username', '$password', '$email', '$ref', '$money', '$gold', '$themeid', '$langcode')");
Today i'm looking to give incentives upon referring people. So I have been breaking down the ways I got to do this. I came up with something like this.
$sql3 = mysqli_query($connect, "SELECT ref FROM `players` WHERE ref='$ref'");
if (mysqli_num_rows($sql3) > 0) {
echo $player_update = mysqli_query($connect, "UPDATE `players` SET money=money+'5000' WHERE ref='$ref'");';
}else{
This does not work and i'm unsure if this is how I should be doing in the first place.. I'm a beginner and learned all myself so tip would be highly appreciated, thank you to anyone reading/helping!
How to kill a query running by pd.read_sql and connected by sqlalchemy (or mysql.connector)
Radio and checkbox cannot be checked when inside BootStrap Modal
I have created a script that goes through all my WordPress posts and replaces the first occurrence of a word with a link
I'm try to solve a task which uses new functions php7 uniform variable syntax nested () support foo()() (https://wikiphp
I believe hash('sha256', $pw) is FIPS compliant, but I know for certain that an attack vector is possible with using that functionAlso, there is no salt (so I would have to encounter that implementation and I would rather not)
Need some help with a MySQL query to be used in a larger databaseSimplified here, I need to find the number of orders related to each order size