Jump to content

fintastik

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

fintastik's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I spoke to soon, if (mysql_num_rows($result) == 1) { echo "You already have this item."; exit(); } Now it echos 'You already have this item' even when it successfully updates a row. Here is how I am using it, possibly wrong? if ($valid == true) { $accquery = "UPDATE tblBillID set Password = '".$_POST['NewPassword']."' where BillID = '".$_POST['loginID']."' and Password = '".$_POST['Password']."'"; $accresult = odbc_exec($conn,$accquery); odbc_close($conn);} if (mssql_num_rows($accquery) == 0) { echo "Incorrect Password"; exit; } else {echo "<b>Account Has Been Updated</b>"; exit; } }
  2. Ok, I got it to work using this: if ($valid == true) { $accquery = "UPDATE tblBillID set Password = '".$_POST['NewPassword']."' where BillID = '".$_POST['loginID']."' and Password = '".$_POST['Password']."'"; $accresult = odbc_exec($conn,$accquery); odbc_close($conn); echo "<b>Account Has Been Updated</b>"; exit; } if ($valid == false) { echo "<b>Please type your information again, make sure it matches!</b>";} } } ?> <script type="text/javascript"> <!-- var letters='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ' var numbers='1234567890' var custom='@.?' function alpha(e,allow) { var k; k=document.all?parseInt(e.keyCode): parseInt(e.which); return (allow.indexOf(String.fromCharCode(k))!=-1); } //form clear function function clearDefault(el) { if (el.defaultValue==el.value) el.value = "" } // --> </script> <form action="" method="post"> <table><tr><td> Login:</td><td> <input name="loginID" type="text" maxlength="14" onkeypress="return alpha(event,letters+numbers+custom)" ONFOCUS="clearDefault(this)"></td></tr> <tr><td> Password:</td><td> <input name="Password" type="password" maxlength="28" onkeypress="return alpha(event,letters+numbers+custom)" ONFOCUS="clearDefault(this)"></td></tr> <tr><td> Retype Password:</td><td> <input name="Password2" type="password" width="100" onkeypress="return alpha(event,letters+numbers+custom)" ONFOCUS="clearDefault(this)"></td></tr> <tr><td> New Password:</td><td> <input name="NewPassword" type="text" maxlength="30" onkeypress="return alpha(event,letters+numbers+custom)" ONFOCUS="clearDefault(this)"></td></tr> <tr><td> Retype New Password:</td><td> <input name="NewPassword2" type="text" width="100" onkeypress="return alpha(event,letters+numbers+custom)" ONFOCUS="clearDefault(this)"></td></tr> <tr> <td><input type="submit" name="Create" value="Update Account!"></td> </tr> </table> </form> Now I ran into a different problem. The script works and only updates the database information if the login and password match with the database, but if it doesnt match, no rows get updated in the database, but it still displays the 'Account has been updated' because the query was completed even though it updated no rows. I realize I should probably have posted this in the MSSQL forum, but it doesnt seem to active so I tried here first. Any help to get it to display Account has been updated only if rows were changed in the db?
  3. I am trying to write a script, that will let users change their password for their accounts on a online game. Their account information is stored in a tblBillID mssql database, the fields are BillID and Password. Now I obviously dont want everyone being able to change everyone elses password, so I am thinking I will have to create a form with a Login and Password field, and a New Password field. If the Login and Password match with the account on the database, then it will run a sql query to update the password field with the 'NewPassword' field on the form. Im just stuck with regards to matching the Login and Password from my web form, with the account information stored on the database. I have a query that I think should work $accquery = "UPDATE tblBillID set Password = '".$_POST['NewPassword']."' where BillID = '".$_POST['loginID']."'"; $accresult = odbc_exec($conn,$accquery); odbc_close($conn); echo "<b>Account Has Been Updated</b>"; exit; This is the form I will use: <form action="" method="post"> <table><tr><td> Login:</td><td> <input name="loginID" type="text" maxlength="14" onkeypress="return alpha(event,letters+numbers+custom)" ONFOCUS="clearDefault(this)"></td></tr> <tr><td> Password:</td><td> <input name="Password" type="password" maxlength="28" onkeypress="return alpha(event,letters+numbers+custom)" ONFOCUS="clearDefault(this)"></td></tr> <tr><td> Retype Password:</td><td> <input name="Password2" type="password" width="100" onkeypress="return alpha(event,letters+numbers+custom)" ONFOCUS="clearDefault(this)"></td></tr> <tr><td> New Password:</td><td> <input name="NewPassword" type="text" maxlength="30" onkeypress="return alpha(event,letters+numbers+custom)" ONFOCUS="clearDefault(this)"></td></tr> <tr><td> Retype New Password:</td><td> <input name="NewPassword2" type="text" width="100" onkeypress="return alpha(event,letters+numbers+custom)" ONFOCUS="clearDefault(this)"></td></tr> <tr> <td><input type="submit" name="Create" value="Update Account!"></td> </tr> </table> </form> If anyone could explain how would be the best way to make sure my loginID and Password form values match with my database BillID and Password fields before updating the Password field with 'NewPassword' it would be greatly appreciated.
  4. thank you very much guys, your awesome
  5. I am making a php ranking page for a game i play, I pull all the characters from the database and sort them by their level using: <table width="100%"> <tr> <th>Rank</th> <th>Name</th> <th>Character</th> <th>Level</th> </tr> <?php $data = array(); if (isset($gp_army)) { $data[] = $gp_army; } $chars = $db->query(" SELECT g.GameID, Face, Lvl FROM tblGameID1 g WHERE g.GameID NOT LIKE 'GM%' AND g.GameID NOT LIKE 'GC%' AND Permission < 65535 " . (isset($gp_type) ? ("AND Face = " . intval($gp_type)) : '' ) . " ORDER BY Lvl DESC", $data); $i = 0; while ($i < $maxdisp && $chars->fetch()) { ?> <tr> <td><-- rank cell --></td> <td ><?= htmlspecialchars($chars->GameID) ?></td> <td><?= character_type($chars->Face) ?></td> <td><?= $chars->Lvl ?></td> </tr> the problem I am having is, i want the rank cell in the table to go from 1-1000, but not sure exactly how to do it since the table is made on the fly.I messed around using a numbered list, but could only make it repeat #1 <tr> <td><ol><li></td> <td ><?= htmlspecialchars($chars->GameID) ?></td> <td><?= character_type($chars->Face) ?></td> <td><?= $chars->Lvl ?></td> </tr> any help or ideas would be appreciated. Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.