Error in working code wtf?

ok, heres the code

[code]
Give to

<?php $cgin = $_POST['cgin']; $ginu = $_POST['ginu']; if (isset($_POST['submit1'])){ mysqli_query($conn, "UPDATE users SET gin=gin + '$cgin' WHERE username='$ginu'"); } ?>[/code]

Now the code works perfectly fine, adds the gin and everything but i keep getting these errors on the webpage

Notice: Undefined index: cgin in C:\xampp\htdocs\therisingkingdom\admin.php on line 31
Notice: Undefined index: ginu in C:\xampp\htdocs\therisingkingdom\admin.php on line 32

That’s because you are trying to use the values before they are set. Also, you NEVER EVER EVER send user supplied data directly to the database. You need to use prepared queries. Also, depending on the name of a button to be submitted will completely fail in certain circumstances.

Sponsor our Newsletter | Privacy Policy | Terms of Service