Jump to content

Skewled

Members
  • Posts

    387
  • Joined

  • Last visited

Everything posted by Skewled

  1. Robert answered your question, it's really the way to go for this type of setup. If you are asking for someone to write all the scripts for your back-end administration area then you'd have to look at the freelance section of the forum. If you have some code you've come up with and are looking for help fixing it then we'd all be pretty happy to help you out. Setup a field in your database for admin flag 0 or 1. Make each script check it or store it in a session for a quick check, encode it or do whatever to secure it. Then make your forms and db features for altering events.
  2. // Delete the hash, username and visited cookies by setting their expiration's to an hour ago (3600) setcookie('knxn_hash', ' ', time() - 3600); setcookie('knxn_username', ' ', time() - 3600); setcookie('knxn_visited', ' ',time() -3600) Just curious if you're deleting the cookies if the user isn't selecting stay logged in, even still you should make them expire 30 days out or so. Is the form defaulting to selected for the stay logged in box? If you've tested it checked then your going to be able to log out and back in without any issues, you'd have to clear your browser data.
  3. I'm pretty sure PHP doesn't work this way, but I may be wrong. I'm not familiar with (&$variable) in php, now c++ I know your passing a reference but that's off topic so I'll stop there. Typically you'll be using $_GET and $_POST to deal with form data, and you'd be smart to secure input and validate everything or your going to be really mad at yourself when someone takes advantage of it. Either way you face it, you will be passing the information to a function but not the way your doing it in the code you posted. I don't know how your structuring your web application, and right now I'm super sleepy to continue on this one. I'd suggest googling some tutorials on functions in PHP, and even more using them with classes.
  4. Because you're using the same query as your registration which INSERTS data as a new row. if (count($setArray) > 0) { $setstr = join (', ', $setArray); $query ="INSERT INTO `companies` (company_name, what_services, website, contact_name, location, postcode, street1, street2, city, phone,phone2, email, premiumuser_description, username, password, salt, approved, upload) VALUES ('$company_name', '$what_services', '$website', '$contact_name', '$location', '$postcode', '$street1', '$street2', '$city', '$phone', '$phone2', '$email', '$premiumuser_description', '$username', 'SHA($password)', '$salt', '$approved', '$upload')"; mysql_query($query); } You will need to use UPDATE and a WHERE statement to resolve your issue.
  5. The form has no action set and won't do anything... <form name="form2" method="post" action=""> <label for="theyWant">Games They Want</label> <textarea name="theyWant" id="theyWant" cols="45" rows="5"></textarea> <label for="myGames">Games I Have</label> <textarea name="myGames" id="myGames" cols="45" rows="5"></textarea> <label for="wantedGames"><br> Games I Want</label> <textarea name="wantedGames" id="wantedGames" cols="45" rows="5"></textarea> <label for="thierGmaes">Games They Have</label> <textarea name="thierGmaes" id="thierGmaes" cols="45" rows="5"></textarea> <textarea name="textarea" id="textarea" cols="45" rows="5"></textarea> </form>
  6. How is your database structured? What is the current PHP code your using to query and then output the results? --- Quick & Dirty --- Add a field in the database to store the link to the image for each country. When retrieving the results from the database simply apply the value into <img> </img> tags and output the picture.
  7. I'm tagging this to see where it leads because I'm interested myself now as to what advantages this has over using a traditional class, it certainly is clear now as to what you want lol!
  8. Kay - That's the best non-bashing post I've seen in a good while! OP - what is not working in the 2nd code that you posted? Can you be more specific with the errors your receiving? The more you limit down to what is causing your issue the better you can be helped.
  9. Why would you want to over complicate it though? I'm curious now...
  10. This is what I'm using can't recall the reference I used but as far as speed, I never tested it as it just worked fine for what I needed. <?php /* Class for working with the databases */ class Database { var $Host = "localhost"; // Hostname of our MySQL server. var $Database = ""; // Logical database name on that server. var $User = ""; // User and Password for login. var $Password = ""; var $Link_ID = 0; // Result of mysql_connect(). var $Query_ID = 0; // Result of most recent mysql_query(). var $Record = array(); // current mysql_fetch_array()-result. var $Row; // current row number. var $LoginError = ""; var $Errno = 0; // error state of query... var $Error = ""; //------------------------------------------- // Connects to the database //------------------------------------------- function connect() { if( 0 == $this->Link_ID ) $this->Link_ID=mysql_connect( $this->Host, $this->User, $this->Password ); if( !$this->Link_ID ) $this->halt( "Link-ID == false, connect failed" ); if( !mysql_query( sprintf( "use %s", $this->Database ), $this->Link_ID ) ) $this->halt( "cannot use database ".$this->Database ); } // end function connect //------------------------------------------- // Queries the database //------------------------------------------- function query( $Query_String ) { $this->connect(); $this->Query_ID = mysql_query( $Query_String,$this->Link_ID ); $this->Row = 0; $this->Errno = mysql_errno(); $this->Error = mysql_error(); if( !$this->Query_ID ) $this->halt( "Invalid SQL: ".$Query_String ); return $this->Query_ID; } // end function query //------------------------------------------- // If error, halts the program //------------------------------------------- function halt( $msg ) { printf( "</td></tr></table><b>Database error:</b> %s<br>n", $msg ); printf( "<b>MySQL Error</b>: %s (%s)<br>n", $this->Errno, $this->Error ); die( "Session halted." ); } // end function halt //------------------------------------------- // Retrieves the next record in a recordset //------------------------------------------- function nextRecord() { @ $this->Record = mysql_fetch_array( $this->Query_ID ); $this->Row += 1; $this->Errno = mysql_errno(); $this->Error = mysql_error(); $stat = is_array( $this->Record ); if( !$stat ) { @ mysql_free_result( $this->Query_ID ); $this->Query_ID = 0; } return $stat; } // end function nextRecord //------------------------------------------- // Retrieves a single record //------------------------------------------- function singleRecord() { $this->Record = mysql_fetch_array( $this->Query_ID ); $stat = is_array( $this->Record ); return $stat; } // end function singleRecord //------------------------------------------- // Returns the number of rows in a recordset //------------------------------------------- function numRows() { return mysql_num_rows( $this->Query_ID ); } // end function numRows } // end class Database ?>
  11. Your welcome.. you don't need to learn anything crazy at the moment, all you have to do is follow the tutorial displayed and you'll get what you need without too much difficulty.
  12. The first portion you have to update with your table that stores the information to the images. // Query that gathers the total number of rows returned $numrows = "SELECT * FROM sometable"; This is where you will format your output for each picture.. wrap it in a div to contain the content while ($row = mysqli_fetch_array($data)) { // echo img location here } Then you can specify the options here: // Calculate pagination information $cur_page = isset($_GET['pg']) ? $_GET['pg'] : 1; $results_per_page = 5; // Number of results per page $skip = (($cur_page - 1) * $results_per_page); Any clearer now?
  13. And I just realized I didn't answer your question grr. I am using update to SET fields in mySQL table, my question is; do i have to update hash/salt as well as password or can i just update password as hash and salt are unique? If they are unique and compared on a login.php type script then yes you will need to generate both of them just like it's done at sign up time. function createSalt() { $string = md5(uniqid(rand(), true)); return substr($string, 0, 3); } $hash = hash('sha256', $salt, $password); But from the login side I don't know how it's being compared.
  14. I would just use SHA: SHA('$password') Then for the update you just apply SHA('$password') to update the password in the database. <?php if (isset($_GET['password']) && $_GET['password']) { // These are the same so you'd need to make them different if your comparing the password to ensure they entered it correctly ex: $_GET['password1'] for another field in your form $password= mysql_real_escape_string($_GET['password']); // This is fine if the 2 values above are first compared $setArray[] = "password = SHA('$password')"; // If they are compared and validation checks out then just do the query to update the password here.. } ?> EDIT: $query ="INSERT INTO `companies` (company_name, what_services, website, contact_name, location, postcode, street1, street2, city, phone,phone2, email, premiumuser_description, username, password, salt, approved, upload) VALUES ('$company_name', '$what_services', '$website', '$contact_name', '$location', '$postcode', '$street1', '$street2', '$city', '$phone', '$phone2', '$email', '$premiumuser_description', '$username', 'SHA($password)', '$salt', '$approved', '$upload')";
  15. https://www.dougv.com/2009/06/13/sorting-your-mysql-results-set-in-php-using-jquery-and-a-more-traditional-approach/ See the JQuery portion.
  16. Sure, google is your best friend... http://stackoverflow.com/questions/9604078/how-do-i-populate-a-select-list-in-jquery-with-data-from-php There is a practical walk through on that page that will show you how it's done, but you will need to apply what your learning to your own needs. You'll also notice how the code is broken up into manageable chunks to make the flow easier to read and understand. http://codeassembly.com/Simple-chained-combobox-plugin-for-jQuery/ Taken from the same page this is an easy to follow solution. http://remysharp.com/2007/01/20/auto-populating-select-boxes-using-jquery-ajax/ A 3rd example encase the other two don't work for you.
  17. Firebug shows for the footer: <section id="footertop"> <section id="templatecopy"> </section> </section> So that appears to be opened and closed correctly. Now the below code is for what is contained in the footer: <footer> <section id="templatecopy"><?php include("../includes/subs/templatecopy.php"); ?></section> <? } ?> <? /** * Just a little page footer, tells how many registered members * there are, how many users currently logged in and viewing site, * and how many guests viewing site. Active users are displayed, * with link to their user information. */ echo "<center><b>Totaal leden:</b>".$database->getNumMembers()."<br/></center>"; echo "<center>Er zijn $database->num_active_users geregistreerde leden en "; echo "$database->num_active_guests gasten online.</center>"; include("login/include/view_active.php"); ?> The CSS applied to that: section#templatecopy { border-top: 1px dotted #333333; clear: both; font-size: 12px; line-height: 22px; padding: 20px; text-align: center; width: 900px; } It was displaying the footer correctly but then you moved the templatecopy into the footer and lost the contents from what I can see. It was: <footer> <section id="footertop"> <aside class="footer-column"> <h4>Info</h4> Html5 en css3 beste resultaat in google chrome. </aside> <aside class="footer-column"> <h4>Mc bevers</h4> <address> <span>Postcode:</span>1547<br/> <span>Land:</span>Belgie<br/> <span>Plaats:</span>Bever<br/> <!--<span>Telefoon 1:</span>0<br/> <span>Telefoon 2:</span>0<br/> <span>Fax:</span>0<br/>--> <span>Email:</span><a href="mailto:info@mcbevers.be">info@mcbevers.be</a> </address> </aside> </section> <!--<section id="copyright"> <h4>Copyright</h4> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta.</p> </section>--> <section id="banners"> <ul class="banners"> <li><span><span><span><img src="../images/icon1.gif" alt="sponsor"><strong>Sponsor</strong>Sponsor worden?<a href="../contactnl.html" class="new_window"><br/>Klik hier</a></span></span></span></li> <li><span><span><span><img src="../images/icon2.gif" alt="sponsor"><strong>Sponsor</strong>Sponsor worden?<a href="../contactnl.html" class="new_window"><br/>Klik hier</a></span></span></span></li> <li class="last"><span><span><span><img src="../images/icon3.gif" alt="sponsor"><strong>Sponsor</strong>Sponsor worden?<a href="../contactnl.html" class="new_window"><br/>Klik hier</a></span></span></span></li> </ul> </section> <br> <section id="templatecopy"> <p>Edited by DeWezze</p> <p>Template design by <a title="derby web design" href="http://www.tristarwebdesign.co.uk">tristar web design</a></p> </section> <? } /** * Just a little page footer, tells how many registered members * there are, how many users currently logged in and viewing site, * and how many guests viewing site. Active users are displayed, * with link to their user information. */ echo "<center><b>Member Total:</b>".$database->getNumMembers()."<br/></center>"; echo "<center>There are $database->num_active_users registered members and "; echo "$database->num_active_guests guests viewing the site.</center>"; include("login/include/view_active.php"); ?> </footer> </div> </body> </html> Make sure that the css file is correct and has those items defined in it, revert it and see what you get.. the footer will probably appear again. Then work from there moving the css into the stylesheet and see what happens from there. footertop, footer-column have appeared to vanish from the new modifications. I also want to applaud you on fixing what you have, I know it's frustrating at times but it's really the best way to learn.. trial and error.
  18. I don't have the time required to write up the script for you, but you can google AJAX examples far faster then I can write one up! I would suggest using AJAX so that you can do it without refreshing the page with each click, and just refresh the needed data.
  19. If you want to auto populate the information when selecting the first option you can either use AJAX, or you'll have to update the page using a $_GET option and reload the entire page.
  20. You can paginate the results to get what you desire.. Example: <?php // Function to build navigational page links function generate_pg_links($cur_page, num_pages) { $page_links1 = ''; // If this page is not the first page, generate the previous link if ($cur_page > 1) { $page_links .='<a href="' . $_SERVER['PHP_SELF'] . '?=' . '&pg=' . ($cur_page - 1) . '"><-</a> '; } else { $page_links .= '<- '; } // Loop through the pages generating the page number links for ($i = 1; $i <= $num_pages; $i++) { if ($cur_page == $i) { $page_links .= ' ' . $i; } else { $page_links .= ' <a href="' . $_SERVER['PHP_SELF'] . '?=' . '&pg=' . $i . '"> ' . $i . '</a>'; } } // If this page is not the last page, generate the next link if ($cur_page < $num_pages) { $page_links .= ' <a href="' . $_SERVER['PHP_SELF'] . '?=' . '&pg=' . ($cur_page + 1) . '">-></a>'; } else { $page_links .= ' ->'; } return $page_links; } // Calculate pagination information $cur_page = isset($_GET['pg']) ? $_GET['pg'] : 1; $results_per_page = 5; // Number of results per page $skip = (($cur_page - 1) * $results_per_page); // Query that gathers the total number of rows returned $numrows = "SELECT * FROM sometable"; $result = mysqli_query($dbc, $numrows); $total = mysqli_num_rows($result); $num_pages = ceil($total / $results_per_page); // Query to limit the results $limitquery = "$pagestuff . " LIMIT $skip, $results_per_page"; $data = mysqli_query($dbc, $query); // Output the data while ($row = mysqli_fetch_array($data)) { // echo img location here } // Generate page links if ($num_pages > 1) { echo '<div id="pg">'; echo '<p>Page: ' . generate_pg_links($cur_page, $num_pages) . '</p>'; echo '</div>'; } ?> I didn't fully test this but if you add your database connection information to the $dbc variable, put the query you need in, and echo out the row for the images like $row['image'] then it should work. But, this is what you seem to need so hope it helps!
  21. Awesome! Yeah Firebug is awesome!!
  22. <?php include("my_site/navigation.php"); ?> that should work for Linux Did you give the folder correct permissions (chmod 777) I think is what is needed, if apache2 then make sure the user/group is www-data
  23. $Get_Verse_sql = "SELECT ID, Event, Sub_Type, Verse FROM Verses WHERE ID = '".$Verse_id."'"; I don't see where you are setting the value to $Verse_id, try the below: ... don't forget to sanitize the input $Verse_id = $_GET['fontface']; $Get_Verse_sql = "SELECT ID, Event, Sub_Type, Verse FROM Verses WHERE ID = '".$Verse_id."'";
  24. If you want to you can do it that way, have the question in a link format that submits to an answer script that receives the information and then retrieves the answers matching the ID from the database.. that's if I understand you? I was thinking you had questions with answers listed under them, it would be better to use a join rather then having 2 full query structures. A join: $query = "SELECT question, answer FROM questions JOIN answers ON answers.answer_ID AND questions.question_ID" if the tables had the title questions and answers and both contained a field question and answer, with answer_ID and question_ID being unique and the same in both tables you can join them together and output questions with answers that match... I haven't done this in a while but it's what I recall doing... hope it helps clarify and not confuse you!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.