JammeH Posted August 7, 2008 Share Posted August 7, 2008 Hey guys, I'm having trouble with the following code. It goes to the "secretpage.php" once button is clicked but it doesnt seem to input the results into my table. Any help would be awesome "<? include("dbstuff.inc"); $cxn = mysql_connect($host,$user,$password,$database) or die("Couldn't connect to server"); mysql_select_db($database); if($_POST['formid'] != "true") { echo ' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title><style type="text/css"> <!-- body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; } .style1 { font-family: tahoma; color: #0F7D04; font-size: 10px; } .style2 {font-size: 12px} .style4 {font-family: tahoma; color: #0F7D04; font-size: 14px; font-weight: bold; } .style5 { font-family: tahoma; color: #0F7D04; font-size: 12px; font-weight: bold; } .style8 {color: #0F7D04; font-size: 12px; font-family: tahoma;} --> </style></head> <body> <form id="form" name="form" method="post" action=""> <table width="788" border="0" cellspacing="0" cellpadding="0"> <tr> <td><div align="center"><img src="http://www.lsrag.co.uk/images/admin/adduser.jpg"></div></td> </tr> <tr> <td><table width="788" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="3"> <label></label> <div align="center"><span class="style5">Account Information</span><br /> <br /> </div> </td> </tr> <tr> <td width="40"><p align="center" class="style4">1</p></td> <td width="214"><span class="style1"><span class="style2">Username</span><br /> Enter the desired username to be created</span></td> <td width="534"> <label> <input name="addusername" type="text" id="addusername" size="45" maxlength="45" /> </label> </td> </tr> <tr> <td><p align="center" class="style4">2</p></td> <td><span class="style1"><span class="style2">Name</span><br /> Enter the users\' first name</span></td> <td> <label> <input name="addfirstname" type="text" id="addfirstname" size="45" maxlength="45" /> </label> </td> </tr> <tr> <td><p align="center" class="style4">3</p></td> <td><span class="style1"><span class="style2">Surname</span><br /> Enter the users\' surname</span></td> <td> <label> <input name="addsurname" type="text" id="addsurname" size="45" maxlength="45" /> </label> </td> </tr> <tr> <td><p align="center" class="style4">4</p></td> <td><span class="style1"><span class="style2">Email Address</span><br /> Enter the users\' email address</span></td> <td> <label> <input name="addemail" type="text" id="addemail" size="45" maxlength="45" /> </label> </td> </tr> <tr> <td><p align="center" class="style4">5</p></td> <td><span class="style1"><span class="style2">Mobile Number</span><br /> Enter the users\' mobile number</span></td> <td> <label> <input name="addmobile" type="text" id="addmobile" size="45" maxlength="45" /> </label> </td> </tr> <tr> <td><p align="center" class="style4">6</p></td> <td><span class="style1"><span class="style2">Hall</span><br /> Select the users\' hall</span></td> <td> <label> <select name="addhall" id="addhall"> <option selected="selected">Butler Court</option> <option value="Cayley">Cayley</option> <option value="David Collett">David Collett</option> <option value="Elvyn Richards">Elvyn Richards</option> <option value="Falkner Eggington">Falkner Eggington</option> <option value="Faraday">Faraday</option> <option value="Harry French">Harry French</option> <option value="Hazlerigg Rutland">Hazlerigg Rutland</option> <option value="Royce">Royce</option> <option value="Rutherford">Rutherford</option> <option value="Telford">Telford</option> <option value="The Holt">The Holt</option> <option value="Towers">Towers</option> <option value="William Morris">William Morris</option> <option value="Towles Mill">Towles Mill</option> <option value="Community">Community</option> </select> </label> </td> </tr> <tr> <td><p align="center" class="style4">7</p></td> <td><span class="style1"><span class="style2">Password</span><br /> Enter a password for the user</span></td> <td><label> <input name="addpassword" type="password" id="addpassword" size="45" maxlength="45" /> </label> </td> </tr> <tr> <td><p align="center" class="style4">8</p></td> <td><span class="style1"><span class="style2">ID Number</span><br /> Users ID Number (Exclude the A)</span></td> <td> <label> <input name="addidnumber" type="text" id="addidnumber" size="45" maxlength="45" /> </label> </td> </tr> <tr> <td colspan="3"> <label></label> </td> </tr> <tr> <td colspan="3"> <label></label> <div align="center"> <p><span class="style5">Permissions</span><br /> </p> <table width="788" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="39"> </td> <td width="280" class="style8">Add User</td> <td width="50" class="style5"><label> <input type="checkbox" name="adduser" id="adduser" /> </label></td> <td width="50" class="style5"> </td> <td width="280" class="style8">Edit Forum</td> <td width="50"><input type="checkbox" name="editforum" id="editforum" /></td> <td width="39"> </td> </tr> <tr> <td> </td> <td class="style8">Edit User</td> <td class="style5"><input type="checkbox" name="edituser" id="edituser" /></td> <td class="style5"> </td> <td class="style8">Delete Forum</td> <td><input type="checkbox" name="deleteforum" id="deleteforum" /></td> <td> </td> </tr> <tr> <td> </td> <td class="style8">Delete User</td> <td class="style5"><input type="checkbox" name="deleteuser" id="deleteuser" /></td> <td class="style5"> </td> <td class="style8">Add Raid</td> <td><input type="checkbox" name="addraid" id="addraid" /></td> <td> </td> </tr> <tr> <td> </td> <td class="style8">List User</td> <td class="style5"><input type="checkbox" name="listuser" id="listuser" /></td> <td class="style5"> </td> <td class="style8">Edit Raid</td> <td><input type="checkbox" name="editraid" id="editraid" /></td> <td> </td> </tr> <tr> <td> </td> <td class="style8">Find User</td> <td class="style5"><input type="checkbox" name="finduser" id="finduser" /></td> <td class="style5"> </td> <td class="style8">Delete Raid</td> <td><input type="checkbox" name="deleteraid" id="deleteraid" /></td> <td> </td> </tr> <tr> <td> </td> <td class="style8">Add Main News</td> <td class="style5"><input type="checkbox" name="addmainnews" id="addmainnews" /></td> <td class="style5"> </td> <td class="style8">Add Marshalling</td> <td><input type="checkbox" name="addmarshalling" id="addmarshalling" /></td> <td> </td> </tr> <tr> <td> </td> <td class="style8">Edit Main News</td> <td class="style5"><input type="checkbox" name="editmainnews" id="editmainnews" /></td> <td class="style5"> </td> <td class="style8">Edit Marshalling</td> <td><input type="checkbox" name="editmarshalling" id="editmarshalling" /></td> <td> </td> </tr> <tr> <td> </td> <td class="style8">Delete Main News</td> <td class="style5"><input type="checkbox" name="deletemainnews" id="deletemainnews" /></td> <td class="style5"> </td> <td class="style8">Delete Marshalling</td> <td><input type="checkbox" name="deletemarshalling" id="deletemarshalling" /></td> <td> </td> </tr> <tr> <td> </td> <td class="style8">Add Event News</td> <td class="style5"><input type="checkbox" name="addeventnews" id="addeventnews" /></td> <td class="style5"> </td> <td class="style8">Add Main Calendar Event</td> <td><input type="checkbox" name="addmaincalendarevent" id="addmaincalendarevent" /></td> <td> </td> </tr> <tr> <td> </td> <td class="style8">Edit Event News</td> <td class="style5"><input type="checkbox" name="editeventnews" id="editeventnews" /></td> <td class="style5"> </td> <td class="style8">Add Hall Calendar Event</td> <td><input type="checkbox" name="addhallcalendarevent" id="addhallcalendarevent" /></td> <td> </td> </tr> <tr> <td> </td> <td class="style8">Delete Event News</td> <td class="style5"><input type="checkbox" name="deleteeventnews" id="deleteeventnews" /></td> <td class="style5"> </td> <td class="style8">Edit Main Calendar Event</td> <td><input type="checkbox" name="editmaincalendarevent" id="editmaincalendarevent" /></td> <td> </td> </tr> <tr> <td> </td> <td class="style8">Add Hall News</td> <td class="style5"><input type="checkbox" name="addhallnews" id="addhallnews" /></td> <td class="style5"> </td> <td class="style8">Edit Hall Calendar Event</td> <td><input type="checkbox" name="edithallcalendarevent" id="edithallcalendarevent" /></td> <td> </td> </tr> <tr> <td> </td> <td class="style8">Edit Hall News</td> <td class="style5"><input type="checkbox" name="edithallnews" id="edithallnews" /></td> <td class="style5"> </td> <td class="style8">Delete Main Calendar Event</td> <td><input type="checkbox" name="deletemaincalendarevent" id="deletemaincalendarevent" /></td> <td> </td> </tr> <tr> <td> </td> <td class="style8">Delete Hall News</td> <td class="style5"><input type="checkbox" name="deletehallnews" id="deletehallnews" /></td> <td class="style5"> </td> <td class="style8">Delete Hall Calendar Event</td> <td><input type="checkbox" name="deletehallcalendarevent" id="deletehallcalendarevent" /></td> <td> </td> </tr> <tr> <td> </td> <td class="style8">Add Forum Posts</td> <td class="style5"><input type="checkbox" name="addforumposts" id="addforumposts" /></td> <td class="style5"> </td> <td class="style8">View Administration Control Panel</td> <td><input type="checkbox" name="viewadministrationcontrolpanel" id="viewadministrationcontrolpanel" /></td> <td> </td> </tr> <tr> <td> </td> <td class="style8">Edit Forum Posts</td> <td class="style5"><input type="checkbox" name="editforumposts" id="editforumposts" /></td> <td class="style5"> </td> <td class="style8">View User Administration</td> <td><input type="checkbox" name="viewuseradministration" id="viewuseradministration" /></td> <td> </td> </tr> <tr> <td> </td> <td class="style8">Add Important Forum Posts</td> <td class="style5"><input type="checkbox" name="addimportantforumposts" id="addimportantforumposts" /></td> <td class="style5"> </td> <td class="style8">View News Administration</td> <td><input type="checkbox" name="viewnewsadministration" id="viewnewsadministration" /></td> <td> </td> </tr> <tr> <td> </td> <td class="style8">Edit Important Forum Posts</td> <td class="style5"><input type="checkbox" name="editimportantforumposts" id="editimportantforumposts" /></td> <td class="style5"> </td> <td class="style8">View Forum Administration</td> <td><input type="checkbox" name="viewforumadministration" id="viewforumadministration" /></td> <td> </td> </tr> <tr> <td> </td> <td class="style8">Delete Forum Posts</td> <td class="style5"><input type="checkbox" name="deleteforumposts" id="deleteforumposts" /></td> <td class="style5"> </td> <td class="style8">View Raid Administration</td> <td><input type="checkbox" name="viewraidadministration" id="viewraidadministration" /></td> <td> </td> </tr> <tr> <td> </td> <td class="style8">Add Forum</td> <td class="style5"><input type="checkbox" name="addforum" id="addforum" /></td> <td class="style5"> </td> <td class="style8">View Calendar Administration</td> <td><input type="checkbox" name="viewcalendaradministration" id="viewcalendaradministration" /></td> <td> </td> </tr> </table> <p> <input type="hidden" name="formid" value="true" /><input type="submit" name="Add User" id="Add User" value="Add User" /> </p> </div> </td> </tr> </table></td> </tr> <tr> <td><div align="center"> </div></td> </tr> </table></form></body></html>'; } else { $addusername = $_POST["username"]; $addfirstname = $_POST["firstname"]; $addsurname = $_POST["surname"]; $addemail = $_POST["email"]; $addmobile = $_POST["mobile"]; $addhall = $_POST["hall"]; $addpassword = $_POST["password"]; $addidnumber = $_POST["idnumber"]; $adduser = $_POST["adduser"]; $edituser = $_POST["edituser"]; $deleteuser = $_POST["deleteuser"]; $listuser = $_POST["listuser"]; $finduser = $_POST["finduser"]; $addmainnews = $_POST["addmainnews"]; $editmainnews = $_POST["editmainnews"]; $deletemainnews = $_POST["deletemainnews"]; $addeventnews = $_POST["addeventnews"]; $editeventnews = $_POST["editeventnews"]; $deleteeventnews = $_POST["deleteeventnews"]; $addhallnews = $_POST["addhallnews"]; $edithallnews = $_POST["edithallnews"]; $deletehallnews = $_POST["deletehallnews"]; $addforumposts = $_POST["addforumposts"]; $editforumposts = $_POST["editforumposts"]; $addimportantforumposts = $_POST["addimportantforumposts"]; $editimportantforumposts = $_POST["editimportantforumposts"]; $deleteforumposts = $_POST["deleteforumposts"]; $addforum = $_POST["addforum"]; $editforum = $_POST["editforum"]; $deleteforum = $_POST["deleteforum"]; $addraid = $_POST["addraid"]; $editraid = $_POST["editraid"]; $deleteraid = $_POST["deleteraid"]; $addmarshalling = $_POST["addmarshalling"]; $editmarshalling = $_POST["editmarshalling"]; $deletemarshalling = $_POST["deletemarshalling"]; $addmaincalendarevent = $_POST["addmaincalendarevent"]; $addhallcalendarevent = $_POST["addhallcalendarevent"]; $editmaincalendarevent = $_POST["editmaincalendarevent"]; $edithallcalendarevent = $_POST["edithallcalendarevent"]; $deletemaincalendarevent = $_POST["deletemaincalendarevent"]; $deletehallcalendarevent = $_POST["deletehallcalendarevent"]; $viewadministrationcontrolpanel = $_POST["viewadministrationcontrolpanel"]; $viewuseradministration = $_POST["viewuseradministration"]; $viewnewsadministration = $_POST["viewnewsadministration"]; $viewforumadministration = $_POST["viewforumadministration"]; $viewraidadministration = $_POST["viewraidadministration"]; $viewcalendaradministration = $_POST["viewcalendaradministration"]; $sql = "INSERT INTO User (username,firstname,surname,email,mobile,hall,password,idnumber,adduser,edituser,deleteuser,listuser,finduser,addmainnews,editmainnews,deletemainnews,addeventnews,editeventnews,deleteeventnews,addhallnews,edithallnews,deletehallnews,addforumposts,editforumposts,addimportantforumposts,editimportantforumposts,deleteforumposts,addforum,editforum,deleteforum,addraid,editraid,deleteraid,addmarshalling,editmarshalling,deletemarshalling,addmaincalendarevent,addhallcalendarevent,editmaincalendarevent,edithallcalendarevent,deletemaincalendarevent,deletehallcalendarevent,viewadministrationcontrolpanel,viewuseradministration,viewnewsadministration,viewforumadministration,viewraidadministration,viewcalendaradministration) VALUES ('$addusername','$addfirstname','$addsurname','$addemail','$addmobile','$addhall','$addpassword','$addidnumber','$adduser','$edituser','$deleteuser','$listuser','$finduser','$addmainnews','$editmainnews','$deletemainnews','$addeventnews','$editeventnews','$deleteeventnews','$addhallnews','$edithallnews','$deletehallnews','$addforumposts','$editforumposts','$addimportantforumposts','$editimportantforumposts','$deleteforumposts','$addforum','$editforum','$deleteforum','$addraid','$editraid','$deleteraid','$addmarshalling','$editmarshalling','$deletemarshalling','$addmaincalendarevent','$addhallcalendarevent','$editmaincalendarevent','$edithallcalendarevent','$deletemaincalendarevent','$deletehallcalendarevent','$viewadministrationcontrolpanel','$viewuseradministration','$viewnewsadminsitration','$viewforumadministration','$viewraidadministration','$viewcalendaradministration')"; $result = mysql_query($sql); header("Location: Secretpage.php"); } ?>" Quote Link to comment Share on other sites More sharing options...
elflacodepr Posted August 7, 2008 Share Posted August 7, 2008 the "code" tags aren't there for styling, use them for better reading Quote Link to comment Share on other sites More sharing options...
JammeH Posted August 7, 2008 Author Share Posted August 7, 2008 Taken your advice Quote Link to comment Share on other sites More sharing options...
JammeH Posted August 7, 2008 Author Share Posted August 7, 2008 Taken your advice Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 7, 2008 Share Posted August 7, 2008 Before I read the rest of your script, I see a GLARING problem. You have your database connection info in a .inc rather than a .php. That means that if someone navigates to that script, they have all your connection details. Add the .php extension to the filename. Quote Link to comment Share on other sites More sharing options...
JammeH Posted August 7, 2008 Author Share Posted August 7, 2008 Ah cheers DarkWater, *changed* - Any luck with the script ? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 7, 2008 Share Posted August 7, 2008 Try changing: $result = mysql_query($sql); To: $result = mysql_query($sql) OR die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
JammeH Posted August 7, 2008 Author Share Posted August 7, 2008 $result = mysql_query($sql) Gives an error on line 404 eg: the line below it die(mysql_error()); Doesnt direct to Secretpage.php And displays a white blank apge after clicking submit Quote Link to comment Share on other sites More sharing options...
DarkWater Posted August 7, 2008 Share Posted August 7, 2008 What? Did you put $result = mysql_query($sql)or die(mysql_error()); as the new line? What error does it give? Quote Link to comment Share on other sites More sharing options...
JammeH Posted August 7, 2008 Author Share Posted August 7, 2008 Sorry, Tried what you suggested now and error is: "Duplicate entry '' for key 1" Quote Link to comment Share on other sites More sharing options...
JammeH Posted August 7, 2008 Author Share Posted August 7, 2008 Anyone help with this? xx Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.