Jump to content

Eyewash01

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Eyewash01's Achievements

Newbie

Newbie (1/5)

0

Reputation

  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. ?>
×
×
  • 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.