Jump to content

JonnoTheDev

Staff Alumni
  • Posts

    3,584
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by JonnoTheDev

  1. <?php $result = mysql_query("SELECT * FROM user WHERE id='123'"); $row = mysql_fetch_assoc($result); ?> <form> name: <input type="text" name="name" value="<?php print (strlen($_POST['name']) ? $_POST['name'] : $row['name']); ?>" /><br /> email: <input type="text" name="email" value="<?php print (strlen($_POST['email']) ? $_POST['email'] : $row['email']); ?>" /><br /> </form> Get the idea? If the form is submitted with new data and there are errors (you will have to validate the input) the fields will retain the new data entered, otherwise they will display the default values from the database. However I would not recommend putting POST data back into an input field until it has been sanitized i.e. remove sql injection, html, javascript, etc
  2. Bollo**** You wouldn't. A loop would be used! Face it you have no one agreeing with your method. It is spaghetti code. End of
  3. So for every time I use a checkbox I need a hidden field. What if you had 100 checkboxes? Absolute garbage. I have never see a form work this way in my life. As far as additional php code it is minimal
  4. OK if you want the next and prev record from a given row just us > < opeartors // next row SELECT id FROM table WHERE id > 123 ORDER BY id ASC LIMIT 1 // prev row SELECT id FROM table WHERE id < 123 ORDER BY id DESC LIMIT 1
  5. Don't use a pointer i.e popen() Fork the script with exec() exec("php /path/to/script.php > /dev/null &"); ironhamster88, these comments have nothing to do with a performance issue!
  6. SELECT id FROM table ORDER BY id DESC LIMIT 2 This will give you the last 2 records
  7. if ($formpass == $pass && $formlogin == $login) { session_register("loggedin"); $loggedin = "1"; //logged in so run a javascript redirect to admin page. ?> <script language="javascript"> <!-- location.replace("admin"); --> </script> This is awful code (using javascript to redirect). session_register() is depreciated. Get yourself a new CMS (an upto date one at least)
  8. Why would you do that? You only need 1 field with that name. Check its value when sent to the server: // can only be a 1 or 0 $checkVal = ($_POST['checkboxName']) ? 1 : 0; Get rid of that hidden field with the same name
  9. SELECT MAX(fieldname) AS lastPK, MAX(fieldname)+1 AS newPK FROM table
  10. Welcome to the Internet. Use a php file for CSS definition and encrypt it using ioncube. Personally though I wouldn't be bothered.
  11. echo "<META HTTP-EQUIV = 'Refresh' Content = '0; URL =login.php'>"; bad code. why would you echo prior to any html output? use headers to redirect to indicate a valid HTTP status. never echo prior to headers being sent. chokies12 if your session data remains after unset then you must be resetting its value somewhere. try this sample script on a test page <?php session_start(); $_SESSION['name'] = "Joe"; print "session set - value: ".$_SESSION['name']."<br />"; unset($_SESSION['name']); print "session unset - value: ".$_SESSION['name']; ?> The second printed line should contain no value for $_SESSION['name']
  12. Why use it? It doesn't remove any of the associated session data or clear a user cookie if used. Never needed this function! If your session still has a value after unset() you are resetting it somewhere.
  13. pointless - will add overhead and why would anyone want it? you will never hide it from an experienced web user.
  14. All you need on logout is <?php session_start(); unset($_SESSION['userName']); header('location: index.php'); exit(); ?> And your index <?php session_start(); if(!strlen($_SESSION['userName']))) { header('location: login.php'); exit(); } ?>
  15. example sql (im guessing your tables) SELECT name, dob FROM employees WHERE MONTH(dob) = MONTH(CURDATE()) ORDER BY DAYOFMONTH(dob) ASC
  16. Just a small thought but if you put the preview text box to the right of the controls it would make it much better as you have to scroll to see the results. If you make the page without any scroll it would be perfect. Also there is a grey rectangle with a red border at the top of the page in IE 8.
  17. why not? ammend your CSS
  18. Surely you have a database and only 2 files to edit. The product detail page where you can edit the add to basket button. Displaying a list of products is done with a loop. Simply edit the contents of the loop to include a form for each product. Please tell me you have not hand coded each product add to basket button. Also if you are trying to redirect the user back to the referring page you should not be passing the script name through the url as a parameter. You should implement a tracker that stores the url in a session on each page load. You can then use this to redirect a user. This method could then be used to track users throughout your site. I would want to know what direction a user took on my site to buy a product, i.e which pages are performing best also if a users tracking stops at the product info screen then I may think about updaing it a little, maybe the photos are no good or the product information is poor. This is essential information with online shops.
  19. This is easy if all sites are on the same server. Store the terms content in a text file somewhere on your server i.e. /usr/local/php/includes/terms.txt In the text file use a tag where you will want to replace text on each site i.e. // terms.txt <p>Your use of [sITENAME] etc......</p> Then on each site get the contents of the file and use the str_replace function to replace the markers. If you have multiple markers use an array as parameters in the function i.e. <?php $terms = file_get_contents('/usr/local/php/includes/terms.txt'); $terms = str_replace("[sITENAME]", "mysite.com", $terms); print $terms; ?>
  20. You don't! You just add it in your terms of use not to remove the text.
  21. Also why would you do this? $sqlquery = $sqlSelect; Why assign the value of a variable to another variable meaning you have 2 variables in memory space containing the same string. Pointless and inefficient.
  22. What I a saying is use a form to add a product to the basket rather than using an href. Add the parameters you need to hidden fields <form method="post" action="basket.php"> <input type="hidden" name="src" value=".$_SERVER['REQUEST_URI']." /> <input type="hidden" name="productID" value=".$row["Prod_ID"]." /> <input type="submit" name="submit" value="add to basket" /> </form> You do not need to encode or decode anything
  23. Why not set the form action to POST instead of using GET. To remove the encoding though you would use urldecode() on the value.
  24. Check your CSS. This is what your page looks like in IE [attachment deleted by admin]
×
×
  • 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.