Jump to content

Yesideez

Members
  • Posts

    2,342
  • Joined

  • Last visited

Everything posted by Yesideez

  1. Wouldn't something like this be a lot better? <input type="button" value="Create a new post" title="Create a new page entry." onclick="javascript:window.location=<?php echo $_SERVER['PHP_SELF']; ?>?action=create"/> I'm not that great with Javascript so I might (probably) be using the syntax a little incorrectly.
  2. Gotcha! Thanks for explaining that, I'll certainly be looking into relocating those file outside the public_html folder
  3. Now I'm not sure I understand what you mean - if they're inside their own folder then they're outside of the document root :/
  4. The files are inside their own folder already but it's how to authorise - that's the bit I'm stuck on.
  5. My website has various files available for download but I only want to have those files accessible by scripts contained on the web server. I've got an empty index.php inside each folder so people can't browse the files but what I'd like to do is have them get "Access denied" by Apache rather than empty space. I borrowed a one liner from a friend's set-up which he uses to do exactly what I'm wanting to do: deny from all but this denies everything even if I try and download a file using the website so I then had a read up and came up with this: Order Deny,Allow Deny from all Allow from www.pictureinthesky.net Again, that denies everything access still. This is a direct link to one of the files: http://www.pictureinthesky.net/files/games/cfodder2.zip I've managed to set up a rewrite rule to prevent hotlinking but can it also be made to prevent users typing the URL directly into the browser? Any help gratefully appreciated!
  6. $address=''; switch ($interest) { case 'Membership': $address='membership@myemail.co.uk'; break; case 'Events': $address='sales@myemail.co.uk'; break; case 'Business': $address='sales@myemail.co.uk'; break; case 'Weddings': $address='weddings@myemail.co.uk'; break; } if (!empty($address)) { mail($address,$subject,$message,$headers); } mail('info@myemail.co.uk',$subject,$message,$headers); That way the email will only get sent to those in the switch statement if one of the cases match and an extra email will always be sent to info. EDIT: thorpe's got a much better idea
  7. When you get the id from the warrantydb table you can use this to then pull data from the database.
  8. http://us2.php.net/manual/en/function.fgetcsv.php
  9. You need to some way add an identifier into the options. If you have an "id" field in the warrantydb table you can modify your query for this: SELECT id,lname, fname, phone FROM warrantydb ORDER BY lname ASC Now assign this into a variable: $id=$row['id']; Now, when you add the options, use this line: echo "<option value=\"$id\">$Data $Data2 $Data3</option>"; Now read the id field... POST: $warrantyid=$_POST['DropData']; GET: $warrantyid=$_GET['DropData'];
  10. Let's say in your garage table you have an extra field, let's call it "canrace" and make it boolean (0 or 1) You can then have a query like this: SELECT * FROM garage WHERE owner='$username' AND damage='0' AND canrace=1 Those cars that can race set to 1 and those that can't, set to 0.
  11. As suggested by flyhoney - print_r will show you the structure of the array so you have an idea of what foreach is running through. Let's take a single dimensional array as an example, one containing a list of 5 names (adam, peter, paul, robert, jake) $arrNames=array('adam','peter','paul','robert','jake'); Now we'll use foreach to run through the array sending some text to the browser: foreach ($arrNames as $name) { echo 'Hello '.$name.'<br>'; } As you can see foreach runs through the array passing the elements in turn as $name and is the same as: for ($i=0;$i<count($arrNames);++$i) { echo 'Hello '.$arrNames[$i].'<br>'; } Let's say we have an indexed array - the indexes are the names and the values are their age: $arrAges=array('adam' => 18,'peter' => 21,'paul' => 35,'robert' => 65,'jake' => 14); Now we can use foreach to run through each element accessing the index and value: foreach ($arrAges as $key => $value) { echo $key.' is '.$value.' years old<br>'; } Home that helps.
  12. That's similar to what I use but I don't think there's a right and wrong way to do it - down to individual taste. What I do is make my template as a plain HTML file. This page has everything on it I want to display. Once completed I split it up into smaller include files and then make an index file and include them all back in.
  13. Can you give me an example? I can't seem to understand full what it is you're asking...
  14. Create a .htaccess file inside the folder in question and have it contain this one line: deny from all
  15. Try this: for ($FileNumber=1;$FileNumber<=100;++$FileNumber) { if (file_exists("orders/$FolderDate/Order #$FileNumber.txt")) { $data=file("orders/$FolderDate/Order #$FileNumber.txt"); foreach ($data as $d) { $parts=explode('=',$d); echo $parts[0].$parts[1].'<br>'; } } else { echo 'File orders/'.$FolderDate.'/Order #'.$FileNumber.'.txt not found<br>'; } }
  16. Try adding this at the very start of the script to turn on all error reporting and see how it goes. error_reporting(E_ALL); ini_set('display_errors', 1); (Thanks to Mark Baker's signature for a quick look-up there!)
  17. If you leave the for() loop set to 100 if the files don't exist you shouldn't receive an error but it depends on how error reporting is set up.
  18. $FileNumber=1; while (file_exists("orders/$FolderDate/Order #$FileNumber.txt") { $data=file("orders/$FolderDate/Order #$FileNumber.txt"); foreach ($data as $d) { $parts=explode('=',$d); echo $parts[0].$parts[1].'<br>'; } $FileNumber++; } You can try that, not sure if it would work as I've not tested it but it gives the basic idea of what you're looking for.
  19. See my above code - I just realised I missed that out and added it.
  20. The only thing I've missed off (accidentally!) is a loop to count from 1 to 100 so the final code would look like this: for ($FileNumber=1;$FileNumber<=100;++$FileNumber) { if (file_exists("orders/$FolderDate/Order #$FileNumber.txt")) { $data=file("orders/$FolderDate/Order #$FileNumber.txt"); foreach ($data as $d) { $parts=explode('=',$d); echo $parts[0].$parts[1].'<br>'; } } }
  21. OK let's go through what I've done line by line... if (file_exists("orders/$FolderDate/Order #$FileNumber.txt")) { This checks if the file in question exists - if it does, it executes the code inside the braces. $data=file("orders/$FolderDate/Order #$FileNumber.txt"); Because our previous if() turned out the file DID exist this reads the entire file into $data (as an array) and each line is a separate element. foreach ($data as $d) { This foreach() loops reads through the $data array and assigns each element in turn as $d $parts=explode('=',$d); This explodes the current element (aka. line) and splits on the "=" echo $parts[0].$parts[1].'<br>'; This echo's out elements 0 and 1 followed by a line break. } This ends the foreach() loop. } This ends the if()
  22. Seems you've got your logic in a bit of a twist. The file_exists() function tells you whether a file exists or not and returns either true or false so you're better off using that in an if() outside of your for() loop... if (file_exists("orders/$FolderDate/Order #$FileNumber.txt")) { $data=file("orders/$FolderDate/Order #$FileNumber.txt"); foreach ($data as $d) { $parts=explode('=',$d); echo $parts[0].$parts[1].'<br>'; } }
  23. First, if you surround your code with [code] and [/code] tags it makes things stand out and preserves formatting. Next, try removing the first / from the include and try again. Make sure the "menu" folder is relative to where the script is being run and menu.html is actually inside it.
  24. You'll want to use an iframe - Google is your friend! Just note that if Google (or any other site you try this on) uses Javascript to break out of frames there's nothing you can do to stop it.
  25. As a side note for the OP... Many different types of files have identifying strings embedded in the files at certain locations. For example, GIF files start "GIF" followed by a revision number (most common being GIF87) and an animated GIF would look something like this: GIF87a You can do an extra check for files which must be of specific type (don't rely on this method alone either!) with something like this: if ($file[0]=='G' && $file[1]=='I' && $file[2]=='F') { //looks like the file is a GIF }
×
×
  • 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.