newguy2010 Posted February 14, 2011 Share Posted February 14, 2011 Everything on this page works the form loads and i can insert info into the form but when i click submit it just reloads the page(action="this page") and nothing happens. thanks in advance -Adam <?php require("connection/connection.php"); include("connection/functions.php"); ?> <HTML> <head> <meta content="yes" name="apple-mobile-web-app-capable" /> <meta content="index,follow" name="robots" /> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <link href="" rel="apple-touch-icon" /> <meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" /> <meta name="format-detection" content="telephone=no"/> <link href="css/style.css" rel="stylesheet" media="screen" type="text/css" /> <script src="javascript/functions.js" type="text/javascript"></script> <title>.: Bookmarks :.</title> <link href="" rel="apple-touch-startup-image" /> <meta content="apple-mobile-web-app-status-bar-style" content="default" /> </head> <body class="musiclist"> <div id="topbar"> <div id="title">.: Bookmarks :.</div> <div id="leftbutton"> <a href="default.html"><img src="images/home.png"></a> </div> <div id="rightbutton"> <a href="">Programs</a> </div> </div> <div id="tributton"> <div class="links"> <a id="pressed" href="Bookmarks/Bookmarks.php">Bookmarks</a><a href="Music/Music.html">Music</a><a href="">Movies</a> </div> </div> <div id="content" style="top: 36px"> <form method="post" action="AddBookmark.php"> <span class="graytitle">Add Bookmark</span> <ul class="pageitem"> <li class="bigfield"><input type="text" name="BookmarkName" placeholder="Bookmark Name" /></li> <li class="bigfield"><input type="text" name="BookmarkLink" placeholder="Bookmark Link" /></li> <li class="select"><select name="d"> <?php $getbookmarksections = mysql_query("SELECT * FROM bookmarksections"); confirm_query($getbookmarksections); while($getbm = mysql_fetch_array($getbookmarksections)){ $id = $getbm["ID"]; $sn = $getbm["SectionName"]; echo "<option value=\"$id\">$sn</option>"; } ?> </select><span class="arrow"></span></li> <li class="button"> <input name="AddBookmark" type="submit" value="Add Bookmark" /> </li> </ul> </form> <?php if(isset($_POST["AddBookmark"])){ $SectionID = $id; $Bookmark = $_POST["BookmarkName"]; $BookmarkLink = $_POST["BookmarkLink"]; $add = "INSERT INTO `bookmarks` (`ID` ,`SectionID` ,`Bookmark` ,`BookmarkLink`) VALUES ('NULL', '$SectionID', '$Bookmark', '$BookmarkLink')"; if(confirm_query($add)){ echo "<span class=\"graytitle\">Bookmark '$BookmarkName' in '$sn' Added.</span>"; } } ?> </div> <div id="footer"> </div> </body> </HTML> <?php //Close Connection if(isset($connection)){ mysql_close($connection); } ?> this is the code i suspect is not working <?php if(isset($_POST["AddBookmark"])){ $SectionID = $id; $Bookmark = $_POST["BookmarkName"]; $BookmarkLink = $_POST["BookmarkLink"]; $add = "INSERT INTO `bookmarks` (`ID` ,`SectionID` ,`Bookmark` ,`BookmarkLink`) VALUES ('NULL', '$SectionID', '$Bookmark', '$BookmarkLink')"; if(confirm_query($add)){ echo "<span class=\"graytitle\">Bookmark '$BookmarkName' in '$sn' Added.</span>"; } } ?> Link to comment https://forums.phpfreaks.com/topic/227606-cannot-insert-data-into-a-database-plz-help/ Share on other sites More sharing options...
trq Posted February 14, 2011 Share Posted February 14, 2011 I don't see anywhere where you actually execute the query. What does confirm_query() do? Link to comment https://forums.phpfreaks.com/topic/227606-cannot-insert-data-into-a-database-plz-help/#findComment-1173958 Share on other sites More sharing options...
newguy2010 Posted February 14, 2011 Author Share Posted February 14, 2011 Maybe that is what is wrong. confirm_query() is confirm_query($result_set){ if(!$result_set){ die("Database query failed: ".mysql_error()); } how do i execute the query? Link to comment https://forums.phpfreaks.com/topic/227606-cannot-insert-data-into-a-database-plz-help/#findComment-1173966 Share on other sites More sharing options...
trq Posted February 14, 2011 Share Posted February 14, 2011 how do i execute the query? mysql_query Link to comment https://forums.phpfreaks.com/topic/227606-cannot-insert-data-into-a-database-plz-help/#findComment-1173975 Share on other sites More sharing options...
newguy2010 Posted February 14, 2011 Author Share Posted February 14, 2011 that was the problem thank you. Link to comment https://forums.phpfreaks.com/topic/227606-cannot-insert-data-into-a-database-plz-help/#findComment-1173987 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.