Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Navigation
Latest Addons
Xbox Leaderboards 5
Cookiebar Panel 70
AD Gallery 151
SyntaxHighlighte... 63
Newsletters v4.03 168
Facebook Like Box 202
Newsletters v4.02 79
Metro 235
Facebook Connect 215
Shoutbox Panel 185
Redactor for PHP... 127
MI Floating Side... 132
Facebook Login/R... 180
Avatar Studio v2.03 215
Relationship Sta... 121
Popular Addons
iTheme2 5907
Arise 5869
User Control v1.23 4680
Event Calendar 4129
Photowidget panel 3921
Radio-Theme red2... 3394
Highslide Gallery 3359
CSS/JavaScript D... 3275
Facebook Connect... 3055
Dynamic Menu 2945
Slideshow Lightb... 2768
L-AMANT 2689
Enigma 2670
2Dark 2624
Black 2618
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
Invalid Login Issues - No Database Functionality User Administration 3 14-06-2013 03:10
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