Jump to content

Eyewash01

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Everything posted by Eyewash01

  1. I'm no expert, but i've generally found that if you use UTF-8 for EVERYTHING, then all is good - so make sure any webpage charsets, the database charsets etc are all set to utf-8 - and i have yet to find any language characters (including stuff like russian, arabic etc) that display incorrectly. Also bear in my that if you use any string function like strlen or watever then be careful as the character are stored in more the one byte so you will need to use the multibyte string functions instead.
  2. Well you could set a session variable with the time that they came onto the site, then do an AJAX call every so often to check against the time and when 30 mins has passed then redirect them to the new page.
  3. <?php foreach ($example as $key => $value){ } ?> The variable $key will be equal to the field name
  4. http://php.net/manual/en/function.preg-match.php
  5. Brackets around the second occurence of include missing?
  6. On your login processing page, if someone logs in successfully (i.e. puts in the correct username and password), then you should add a line like: <?php $_SESSION['logged_in'] = true; ?> Then on each page you want to protect, at the top of the page should be: if (!isset($_SESSION['logged_in'])){ header("Location: login.php"); } Then when they log out, you need to: unset($_SESSION['logged_in']); Remember to include session_start(); at the top of any page where you want to reference or set session variables.
  7. <?php $sql = "SELECT * FROM stuff;"; $rs = mysql_query($sql); while ($row = mysql_fetch_array($rs)){ extract ($row); echo '<td>'.$example_field_name1.'</td>'; echo '<td>'.$example_field_name2.'</td>'; } ?>
  8. Well some code would be useful - however a login check is fairly simple: <!-- THE HTML (login.php) --> <form action="login_proc.php" method="post"> <input type="text" name="username" /> <input type="text" name="password" /> <input type="submit" value="Login" /> </form> <?php // THE PROCESSING PAGE (login_proc.php) extract ($_POST); if ($username == "Admin" && $password = "biscuit"){ header("Location: admin.php"); } else{ header("Location: login.php"); } ?> This is obviously very simplified, but it is a starting point. You would then need to set a flag somewhere (either a session variable or an entry in a database) to tell the system the user is logged in, and then check this when they access any of the pages on the site.
  9. Firstly, you have referenced $_FILES['file1']['uploads'] when that should be the file name, i.e $_FILES['file1']['name'], or whatever you want to call the file. Secondly you can't refer to them as simply $file1 and $file2, you need to use the $_FILES[] array (although I may be wrong if register globals is on, however if it is then you are going to have a million problems there anyway). Work through the W3 tutorial and maybe some others - they do work!
  10. Yes but as you say, if their details are incorrect, then they are directed back to the login page - therefore if the processing is on the same page, hitting F5 will post the data again. Not necessarily a bad thing in this instance as it will simply try to log them in using the same details again, however in other situations where the processing code is doing something more "destructive" (e.g. writing to a database), then it is best to keep processing away from the mercies of the user refresh!
  11. I think you need to go back and look at a tutorial for using GET and POST variables - as both me and lastkarrde have pointed out, you are not actually including the variable $userid in your original code on the address in the form action.
  12. The mail function can only work if you have told PHP which mail server to use to send the mail out. If you are in control of your server, you need to set the smtp server in your php.ini file. If you are on shared hosting, then they should be able to set this up for you.
  13. Yeah even if it's not producing an error, it is most certainly best practise to enclose values in quotes lol
  14. I haven't read through your code, but you could just have something like this: <input type="checkbox" name="fmCheck1" id="fmCheck1" onclick="showhide_div(1);" /> <input type="checkbox" name="fmCheck2" id="fmCheck2" onclick="showhide_div(2);" /> <div id="div1"> Hello </div> <div id="div2"> Goodbye </div> <script type="text/javascript"> function showhide_div(theID){ if (document.getElementById("fmCheck"+theID).checked == true){ document.getElementById("div"+theID).style.display = "block"; } else{ document.getElementById("div"+theID).style.display = "none"; } } </script> Not really a PHP question....lol
  15. Where are you struggling with the W3 tutorial, cause there's not much to it really. You just need to add a input of type="file" to your user form, and then when they submit the form, the details for it will be in the $_FILES array. In it's simplest form, you could simply add this to your processing page: <?php copy($_FILES['fmFile']['tmp_name'],"_assets/".$_FILES['fmFile']['name']); // fmFile being the name of your form field, and the second function parameter being the directory you want to store the file. ?>
  16. http://php.net/manual/en/reserved.variables.server.php
  17. Once again I'm surprised those if statements are working, as surely it needs to read if ($moveup == "yes") (i.e. with quotes) - can't believe it would work otherwise. Anyhow, if you say the code is working when you put it on another page, then you can still do that and make it appear to the user that they are on the same page, just set the form action to a seperate processing page, include your moving code here, then at the bottom of the page, put header("Location: form.html"); // OR WHATEVER YOUR OTHER PAGE IS CALLED This way, to the user it appears they have never left the page. It also stops the annoying thing or users refreshing the page and the script running again.
  18. Use the strlen($string) function to check length of the password http://php.net/manual/en/function.strlen.php
  19. Well you will just need some way of storing in the database which option they previously selected. If you have users that are logged in (and therefore probably stored in a users table) then you will just need another table in the database, which records the id of the option they selected and their user id, and then when you come to output the list again, you can check against the other table to see which they selected previously, and alter how that one appears or whatever you want to do with it.
  20. Without seeing the rest of your code it's hard to tell, but for one I didn't think you could reference array items with string keys sans quotes - i.e. you have $info[weight] which should surely be $info["weight"] or $info['weight']
  21. Checkboxes are only posted across if they are actually checked. The best way to find them is to iterate through the post variables and find any occurences of the checkboxes. THE USER PAGE: <?php $sql = "SELECT p_id FROM products;": $rs = mysql_query($sql); while ($row = mysql_fetch_array($rs)){ extract ($row); echo '<input type="checkbox" name="fmCheck_'.$p_id.'" id="fmCheck_'.$p_id.'" value="'.$p_id.'" />'; } ?> PHP PROCESSING PAGE: <?php foreach($_POST as $key => $value){ if (stripos($key,"fmCheck_") !== false){ $sql = "INSERT INTO products_required VALUES (".$value.");"; $rs = mysql_query($sql); } } ?>
  22. Um, well you haven't set the get variables to anything. Try something more like this: echo '<form action="admin.php?edit=1&id='.$userid.'" method="get">'; When you have just one GET variable, for example, login.php?logout, you can definitely just have the variable without a value assignment, and although I've never tried it with more than one, that is probably you're problem.
  23. I would also suggest using seperate processing pages for page actions. For example, if you had a login page, you would want a mainly HTML based page displaying the login form, which has an action pointing at a seperate PHP based processing page, which then redirects back to either the login page if unsuccessful, or elsewhere if successful. <!-- Login page (login.html) --> <html> <body> <form action="/procs/login_proc.php" method="post"> <!-- login form stuff here --> </form> </body> </html> <?php // PROCESSING PAGE - login_proc.php // if details are incorrect: header("Location: ../login.html"); // if details are correct: header("Location: ../admin.php") ?> This stops the annoying thing of people pressing F5 on pages and it asking if you want to repost data etc
  24. You haven't started the session anywhere - to utilise session variables you must have the following on the page (preferably at the top, or in an external includes file) <?php session_start(); ?>
×
×
  • 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.