Topic: this page wont write to database (Read 1371 times)
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 884
1636 credits Members referred : 4
« on: Jan 23, 2006, 10:06:06 PM »
Code:
<?php ob_start(); include("config.php"); if($logged[username] && $logged[level] ==5) { //checks to see if the user is logged in, and if their user level //is 5 (this is administrator) if($_GET[links]) { //checks to see if there is a ?user=username variable in the url. if (!$_POST[update]) { // the form hasn't been submitted. We continue... $data = mysql_query("SELECT * from links where id = '$_GET[links]'"); $data = mysql_fetch_array($data); //these lines get the user's information and put it in an array. //we will display the information in the html form echo(" <div align=\"center\"><form method=\"post\"> <table>
<tr> <td valign=\"top\">Links Title: </td> <td valign=\"top\"><input name=\"title\" type=\"text\" value=\"$data[title]\"></td> </tr> <tr> <td valign=\"top\">Links URL: </td> <td valign=\"top\"><input name=\"url\" type=\"text\" value=\"$data[url]\"></td> </tr> <tr> <td height=\"85\" valign=\"top\">Description: <br> </td> <td valign=\"top\"><textarea cols=\"30\" rows=\"5\" name=\"description\">$data[description]</textarea> </td> </tr> <tr> <td align=\"center\" colspan=2><input type=\"submit\" name=\"submit\" value=\"Update\"></td> </tr> </table> </form> </div>"); //displays the html form } else { $url = ($_POST[url]); $title = ($_POST[title]); $description = ($_POST[description]); // the above lines get rid of all html. echo ("The link has been successfully updated."); $update = mysql_query("Update links set url = '$url', title = '$title', description = '$description' where id = '$_GET[links]'"); // updates the information in the database. } } else { $getlinks = mysql_query("Select * from links order by id asc"); while($data = mysql_fetch_array($getlinks)) { //makes a list of all the links echo("<a href=\"?open=15&links=$data[id]\">$data[title]</a><br />"); //displays the link names } } } else { //the user's level is not 5! They cannot view this page echo("Sorry, but you are not allowed to view this page!"); }
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 884
1636 credits Members referred : 4
« Reply #4 on: Jan 24, 2006, 09:48:29 AM »
ive already done this, "$update = mysql_query... " so on & so forth, here is new code but still no luck:
Code:
<?php ob_start(); include("config.php"); if($logged[username] && $logged[level] == 5) { //checks to see if the user is logged in, and if their user level //is 5 (this is administrator) if($_GET[links]) { //checks to see if there is a ?user=username variable in the url. if (!$_POST[update]) { // the form hasn't been submitted. We continue... $data = mysql_query("SELECT * from links where id = '$_GET[links]'"); $data = mysql_fetch_array($data); //these lines get the user's information and put it in an array. //we will display the information in the html form echo(" <div align=\"center\"><form method=\"post\"> <table> <tr> <td valign=\"top\">Links Title: </td> <td valign=\"top\"><input name=\"title\" type=\"text\" value=\"$data[title]\"></td> </tr> <tr> <td valign=\"top\">Links URL: </td> <td valign=\"top\"><input name=\"url\" type=\"text\" value=\"$data[url]\"></td> </tr> <tr> <td height=\"85\" valign=\"top\">Description: <br> </td> <td valign=\"top\"><textarea cols=\"30\" rows=\"5\" name=\"description\">$data[description]</textarea> </td> </tr> <tr> <td align=\"center\" colspan=2><input type=\"submit\" name=\"submit\" value=\"Update\"></td> </tr> </table> </form> </div>"); //displays the html form } else { $url = $_POST[url]; $title = $_POST[title]; $description = $_POST[description]; // the above lines set variables used below $update = ("UPDATE links set url = '$url', title = '$title', description = '$description' where id = '$_GET[links]'"); mysql_query($update) or die(mysql_error()); // updates the information in the database. echo "The link has been successfully updated."; } } else { $getlinks = mysql_query("SELECT * from links order by id asc"); while($data = mysql_fetch_array($getlinks)) //makes a list of all the links { echo("<a href=\"?open=15&links=$data[id]\">$data[title]</a><br />"); //displays the link names } } } else { //the user's level is not 5! They cannot view this page echo("Sorry, but you are not allowed to view this page!"); }
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 884
1636 credits Members referred : 4
« Reply #10 on: Jan 24, 2006, 03:09:52 PM »
what u suggested for post update i already have in the page but i tried what u suggested and that also didnt work.. the url would look like ?open=15&links=13...
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 884
1636 credits Members referred : 4
« Reply #15 on: Jan 24, 2006, 04:31:56 PM »
yes! it works now. awesome..thx wineo.. im working on creating my own CMS for sleekpixel.net its turning out quite nicely thx to you and this forum as well as nikolas
aka J Love Community Supporter?
Bill Gates is my home boy
Gender:
Posts: 884
1636 credits Members referred : 4
« Reply #19 on: Jan 24, 2006, 05:04:47 PM »
another database update problem (man i suck with updating a database, thats the only probs i really have)
link_mod.php
Code:
<? ob_start(); include("config.php"); if ($logged[username] && $logged[level] >= 2) { // the user is logged in! We continue... if (!$_POST[update]) { // the form hasn't been submitted. We continue... $data2 = mysql_query("SELECT * from users where username = '$logged[username]'"); $data2 = mysql_fetch_array($data2); $urlid = $data2[urlid]; $data = mysql_query("SELECT * from links where id = '$urlid'"); $data = mysql_fetch_array($data); // the above lines get the information so that it can be displayed in the html form. echo(" <div align=\"center\"><form method=\"post\"> <table> <tr> <td valign=\"top\">Links Title: </td> <td valign=\"top\"><input name=\"title\" type=\"text\" value=\"$data[title]\"></td> </tr> <tr> <td valign=\"top\">Links URL: </td> <td valign=\"top\"><input name=\"url\" type=\"text\" value=\"$data[url]\"></td> </tr> <tr> <td height=\"85\" valign=\"top\">Description: <br> </td> <td valign=\"top\"><textarea cols=\"30\" rows=\"5\" name=\"description\">$data[description]</textarea> </td> </tr> <tr> <td align=\"center\" colspan=2><input type=\"submit\" name=\"update\" value=\"Update\"></td> </tr> </table> </form> </div>"); } else { $url = $_POST[url]; $title = $_POST[title]; $description = $_POST[description]; // the above lines set variables used below $update = ("UPDATE links set url = '$url', title = '$title', description = '$description' where id = '$urlid'"); mysql_query($update) or die(mysql_error()); // updates the information in the database. echo "Your link has been successfully updated."; } } else { // They aren't logged in! echo "You have either not paid for your link to even submit it, or you are not logged in."; } ?>