Jump to content
MakeWebGames

Database Wont update with $_POST


Uridium

Recommended Posts

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();
?>


Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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();
?>
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...