Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Navigation
Latest Addons
AD Gallery 63
SyntaxHighlighte... 51
Newsletters v4.03 114
Facebook Like Box 132
Newsletters v4.02 60
Metro 170
Facebook Connect 173
Shoutbox Panel 129
Redactor for PHP... 107
MI Floating Side... 109
Facebook Login/R... 155
Avatar Studio v2.03 180
Relationship Sta... 98
Sexual Orientati... 116
Fisherman 144
Popular Addons
iTheme2 5808
Arise 5805
User Control v1.23 4623
Event Calendar 4053
Photowidget panel 3888
Radio-Theme red2... 3359
Highslide Gallery 3315
CSS/JavaScript D... 3234
Facebook Connect... 2989
Dynamic Menu 2895
Slideshow Lightb... 2727
L-AMANT 2660
Enigma 2637
2Dark 2608
Black 2580
View Thread
Official Home of PHP-Fusion » General Addon and Modification Support » Code Snippet and functions
Who is here? 1 guest(s)
 Print Thread
Updating database with form
jofamannen
Hi!

I'm having problems updating database via a form.
Page displays as it should but nothing gets updated in the database.
What am I doing wrong?

<?php
require_once "../../maincore.php";
require_once THEMES."templates/header.php";
define("XXXX", DB_PREFIX."YYYY");

opentable("Save User");

if (isset($_POST['savecat'])) {

$Name = $_POST['Name'];
$Points = $_POST['Points'];


$result = dbquery("UPDATE ".XXXX." SET Points='$Points' WHERE Name='$Name'");

}



$formaction = FUSION_SELF;


echo "<form name='addcat' method='post' action='$formaction'>";

echo "<table width='100%' cellspacing='0' cellpadding='0' border='0' class='tbl'>
<tr><td width=140 valign=top>Name:</td><td></td><td><input type='text' align='left' name='Name' value='' class='textbox' style='width:200px;'><br><br></td></tr>
<tr><td width=140 valign=top>Points:</td><td></td><td><input type='text' align='left' name='Points' value='' class='textbox' style='width:200px;'><br><br></td></tr>

<tr><td valign=top><input type='submit' name='savecat' value='Save' class='button'></td>
</form>\n</tr>
</table>";


closetable();
require_once THEMES."templates/footer.php";
?>


Merged on Jun 16 2012 at 12:34:17:
Itīs only updating points if name is already in database.

If entering a non existing user nothing happens.
Edited by MarcusG on 16-06-2012 14:04
 
MarcusG
Which table(s) do you want to update? There is nothing defined when you use
Download source  Code
DB_PREFIX."YYYY"


What is YYYY ??
Ex Senior Dev.
 
http://phpfusion.marcusg.de
jofamannen
YYYY is my table
Edited by jofamannen on 16-06-2012 19:46
 
MarcusG
Ah okay.

So there is only the insert command missing.

This line only updates an existing entry:
Download source  Code
dbquery("UPDATE ".XXXX." SET Points='$Points' WHERE Name='$Name'")




If you want to add a new entry you have to use INSERT.
Ex Senior Dev.
 
http://phpfusion.marcusg.de
jofamannen
Thank you I will test that.
 
Travis
I've faced with the same problem.Thank's for in time help!
 
Jump to Forum:
Similar Threads
Thread Forum Replies Last Post
Database errors Upgrading issues 8 17-05-2013 09:13
database backup not working System Administration 5 14-05-2013 14:16
Subscribe Form Panel Panels and Infusions 7 19-04-2013 09:52
Help with Register form for Ajax Caht Code Ideas for Modifications and Requests 1 10-04-2013 11:22
Custom Contact Form Panels and Infusions 3 09-04-2013 17:38
Official Home of PHP-Fusion uses cookies. Some may already have been set. Read more about our Cookies here.
Please click the button I Consent Cookies to hide this bar and accept our cookies. If you continue to use the site with no action taken, we'll assume that you consent our cookies anyway.
Cookiebar Panel byVenue