Uridium Posted December 3, 2008 Posted December 3, 2008 Got a little problem and its bugging the heck out of me. Ive made a theme changer script and it did actually work until my PC crashed whilst sending a file back also the text Editor Corrupted the file i was editing so ive had to start again from scratch.. I have a colum ni the users table called ThemeDATA which stores the Css links... When a user tried to update a new theme it just empties the ThemeDATA im using this for the UPDATE.... $db->query("UPDATE users SET ThemeDATA='{$_POST['Theme']}' WHERE userid=$userid",$c); if i mispell the word $userid obviously i get an error but wanted to see if the ThemeDATA='{$_POST['Theme']}' was working which it was as i coulod see the snowflake.css link that i wanted to add as a theme. again this also worked for the userid which is correct... if i mispelt the other query But when i put the whole code corrected it accepts it without any errors at all but the ThemeDATA column is blank... I cant for the life of me work it out.. So i'll Post.. and hope :) <?php include "globals.php"; switch($_GET['action']) { case 'accept': accept_theme_begin(); break; case 'accepttheme': accept_theme(); break; default: print "Error: This script requires an action."; break; } function accept_theme_begin() { global $db,$ir,$c,$h,$userid; $q = $db->query("SELECT * FROM Theme WHERE ThemeDATA='{$_POST['Theme']}'"); $r = $db->fetch_row($q); print "<h3>Choose Your Theme</h3> <form action='choose.php?action=accepttheme' method='post'> Theme: ".Theme_dropdown($r,'Theme')." <input type='submit' value='Choose Theme' /></form>"; } function accept_theme() { global $db,$ir,$c,$h,$userid; if($r['Theme'] > 10) { die(" <h1>Theme Error Css Not Found or Numerator out of Range</h1>"); } $oq=$db->query("SELECT * FROM Theme WHERE ThemeDATA='{$_POST['Theme']}'"); $rm=$db->fetch_row($oq); $db->query("UPDATE users SET ThemeDATA='{$_POST['Theme']}' WHERE userid=$userid",$c); print " <h1>Theme</h1><h3><font color='yellow'> {$_POST['Theme']} </h3></font><h1> Updated.... Successfully</h1> <a href='index.php'> <h2>[Refresh Theme]</h2>"; } $h->endpage(); ?> Quote
Guest Anonymous Posted December 3, 2008 Posted December 3, 2008 Re: Database Wont update with $_POST You are joking right...? Quote
Uridium Posted December 3, 2008 Author Posted December 3, 2008 Re: Database Wont update with $_POST Afraid not ive been up all night im shattered can you try explain what you think maybe wrong by the way thats only one part of the script the INSERT is on another script and Obviously the global_func is handling the dropdown... Can ya put me out of my misery. Quote
Cronus Posted December 3, 2008 Posted December 3, 2008 Re: Database Wont update with $_POST First things first, don't leave that form open to so many injections lol Quote
Haunted Dawg Posted December 3, 2008 Posted December 3, 2008 Re: Database Wont update with $_POST First of all. ThemeID row in users table is only for numbers! Second of all. Here is a better choose.php. <?php include("globals.php"); switch($_GET['action']) { case 'accept': accept_theme_begin(); break; default: print "Error: This script requires an action."; break; } function accept_theme_begin() { global $ir,$h; if($_POST['Theme']) { $theme = abs(@intval($_POST['Theme'])); $rows = mysql_num_rows(mysql_query("SELECT ThemeID FROM Theme WHERE ThemeID=".$theme)); if($rows == 0) { echo 'This theme does not exist. Go AWAY!'; $h->endpage(); exit; } mysql_query("UPDATE users SET ThemeID=".$theme." WHERE userid=".$ir['userid']); echo 'You now are using a different theme.'; $h->endpage(); exit; } $q = $db->query("SELECT ThemeID FROM Theme"); $r = mysql_fetch_assoc($q); echo ' <h3>Choose Your Theme</h3> <form action="choose.php?action=accept" method="post"> Theme: '.Theme_dropdown($r,'Theme').' <input type="submit" value="Choose Theme"> </form>'; } $h->endpage(); ?> Quote
Uridium Posted December 3, 2008 Author Posted December 3, 2008 Re: Database Wont update with $_POST Cheers Kyle how do i change the method so its not abs(@intval as i redid the script and am using characters now abs(@intval ??? Quote
Uridium Posted December 3, 2008 Author Posted December 3, 2008 Re: Database Wont update with $_POST kyle your a star cheers matey :) Its been driving me nuts for hours lol i can finally get some sleep :) zzzzzzzzzzzzzzzzz Quote
Haunted Dawg Posted December 3, 2008 Posted December 3, 2008 Re: Database Wont update with $_POST $theme = abs(@intval($_POST['Theme'])); To $theme = mysql_real_escape_string(htmlentities($_POST['Theme'])); But then you will need: $theme = $theme".css"; underneath Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.