I understand that it won't update the SteamID, but with your script there are several possible reasons why:
- the username was missing
- the password was missing
- the username and password don't match
For the above reasons the script won't return an error or notice. To make it do so, you could use this:
PHP Code:
<?php
function print_form()
{
echo "<form action='edit_steamid.php' method='post'>";
echo "Name: <input name='szUser' type='text' value='username' /><br />";
echo "Password: <input name='szPass' type='password' value='password' /><br />";
echo "SteamID: <input name='szSteamID' type='text' value='SteamID' /><br />";
echo "<input type='submit' value='Submit!' />";
echo "</form>";
}
if($_POST)
{
//print the POST array to see what's been submitted
echo "<pre>"; //comment this out if you are not debugging
print_r($_POST);//comment this out if you are not debugging
echo "</pre>";//comment this out if you are not debugging
if(isset($_POST["szSteamID"]) && isset($_POST["szUser"]) && isset($_POST["szUser"]))
{
$szSteamID = strtoupper($_POST["szSteamID"]);
$szPass=sha1(strtolower($szUser) . $_POST["szPass"]); //assuming this is the hashing that SMF uses
if(preg_match("/^STEAM_0:[0-1]:[0-9]{1,9}$/", $szSteamID))
{
echo 'valid';
mysql_connect("localhost", "username", "password");
mysql_select_db("databasename") or die(mysql_error());
$szUser = mysql_real_escape_string($_POST["szUser"]);
$sql="UPDATE smf_members SET steam_id = '$szSteamID' WHERE member_name = '$szUser' AND passwd = '$szPass')";
//print the query to see what's going on. you can use this query on the command line or in phpMyadmin to see what's wrong
echo $sql."<br />"; //comment this out if you are not debugging
if(mysql_query($sql))
{
if(mysql_affected_rows()==1) "<p>Thanks. Your SteamID has been updated and you will now be able to play on our servers.</p>";
else echo "<p>You provided non-matching data.</p>";
}
else
{
echo mysql_error();
echo "<p>Your SteamID has not been updated.";
}
}
else echo "<p>Please enter a valid SteamID.</p>";
}
else
{
echo "<p>All fields are required, some were left blank.</p>";
print_form();
}
}
else
{
echo "<p>No POST data</p>";//comment this out if you are not debugging
print_form();
}
?>
mysql_affected_rows returns the number of rows that were updated by the query.
__________________