Jump to content

Ricky55

Members
  • Posts

    100
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Ricky55

  1. Cheers to everyone. I love an active forum. Some really useful info here I think the if in array is what I was looking for I just wasn't sure how to write it. Btw to get your code to look like code you use code tags code here same on most forums. Once again thanks. Really starting to love php, more of a front guy but it's just too powerful to not know more.
  2. I've been using PHP includes for a while now but I've just started to try to get more advanced. (not much more) I'm using this code to both generate my page titles and give my li tags a class of active so I can style them with css as being in a down state. All is working but I just need a more efficient way of doing this I think. I currently have <?php $title = basename($_SERVER['SCRIPT_NAME'], '.php'); if ($title == 'index') { $title = 'home'; } $title = ucfirst($title); $title = str_replace('-', ' ', $title); $title = ucwords($title); ?> Then in my unordered list I have <?php if ($title == 'Product Selector'||$title == 'Kingston Range') {echo 'class="active"';} ?> I could continue to say if title = a or b or c or d etc but could I use an array to store all of these titles and check to see if the title is in the array? or is there a better way to do this? Thanks in advance
  3. Just have it emailed to the recipient along with the form data. So the user completes a simple form and then they click a browse button to locate an image on their local machine. Click submit and this gets sent to me, the form data and the file as an attachment.
  4. Hi I'm very new to PHP. I've been searching high and low for a script that will process a simple form and also allow a file attachment. I've tried loads of different ones and none of them work as I want. I do actually have one working but this doesn't have any validation of the file. Can anyone please point me in the direction of a script that will allow me to do this. Thanks
  5. Hi I am very new to PHP but I have just been following a tutorial that required PEAR to be installed on my server. I installed PEAR fine using the go-pear.php script and I now have the web front end working and I've got the packages installed that I needed. I am however getting a message across the interface saying "Warning: This package management website is not protected with a password, this is a MAJOR security risk." It provides a read me file with some instructions on how to secure using an htaccess file but I've tried this and I can then no longer access the front end once its on the server. I have installed PEAR to a folder called pearInstall, I have attached the code for the htaccess, I have tried uploading this file to both the site root and the pearInstall folder. What am I doing wrong? Thanks $ echo " AuthUserFile $(pwd)/.htpasswd AuthType Basic AuthName \"Web-based PEAR Frontend\" Require valid-user" > .htaccess && htpasswd -c .htpasswd admin
  6. Hi Just started to use PHP and I've just uploaded a site that uses some simple includes. I want to remove the PHP extension from my URL / Links as I think they just look better without them. Just looked up how to do it with a .htaccess file and the code I've seen works except on one file. It works for all my files that are all in the root folder of the site, one file though products.php when you click the link the browser adds a / on to the end of the URL. When I've look at the permissions they are different for products.php then they are for all my other files. I've not changed these myself, the only difference between products.php and the others is that products links to other php files where the other files link to other files but through an include. All the files that work have the following permissions Owner 6645 Group 48 Octal 644 Products.php has octal 644 but the owner and group are blank. I've tried to change the permissions using Transmit FTP and I just get the following error: Unknown SITE command. The code in the htaccess file is RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php What am I doing wrong? / how do I get around this? Thanks in advance Ricky
  7. whoops, sorry man, I didn't know I could just add PHP tags in that manner, Sorry, but thanks so much. I should have known that really.
  8. Sorry to push this up again, I still can't get this working, I've tried $_SERVER[HTTP_HOST] instead of hard coding my domain name in my links but this still remains in the address bar of the browser so its not getting parsed as PHP. Besides changing the links inside my include file what else do I need to do? <a href="http://$_SERVER[HTTP_HOST]/index.php">Home</a> Also my include file is saved with the extension of .PHP but inside there are no PHP tags its just regular HTML is this correct or should I be using the <?PHP tags? Thanks
  9. Sorry to be a pain Thorpe. My link looks like this <a href="http://www.choicecreative.co.uk/welcome/index.php">Home</a> How would it look if I replaced the domain with that code, I tried a few options and it didn't seem to work. Also, do I still need the initial part of $host = $_SERVER['HTTP_HOST']; And if so where does that need to be located as the include file although saved with the PHP extension is just HTML code.
  10. Cheers Thorpe!!
  11. Sorry I'm getting a bit confused, if I use that relative link though they won't work when I use the include file in files that two folders down from the root. So i do need to turn my links into absolute paths but this will break on my test server as its not the final host so how would I use your example in this? <a href="htttp://www.mysite/includes/contact.php">contact.php</a> Sorry if I being a bit thick!
  12. Sorry my links don't look like that at all they look like this <a href="contactUs.php">contact Us</a>
  13. Thanks very much. I understand that code but would that be used on every link in my include file? For example currently my links look like links... <a href="">contactUs.php</a> Could I declare $host = $_SERVER['HTTP_HOST']; that once for instance and then use the echo on my links?
  14. PFMaBiSmAd, just read your post back again, that sounds ideal so I can use absolute urls but not have to change them. How would I use this then? in my link? Sorry my knowledge of PHP is very small at the moment.
  15. Pleased you said that I was getting a bit confused there myself. Yes just to recap its not linking to the includes, I can do that no bother at all as each page can just link to the include however it needs to. Its the links inside the include file that I'm referring to. They are all currently looking for root based files for example contact.php So when I use this include in a file at the root level all is well but when I use the file several folders in the links obviously no longer work. For them to work they'd need to have ../../ in front of them but I can do this as this will break the links for the files that us the include at the root level. So my use of absolute paths or URLS would be on the links inside the include. I know some of these answers where looking at this problem. Thanks for everyone who has responded its good to be on such a lively forum. So on balance then what is the preferred method of getting around this problem? Thanks
  16. Thanks for all your replies. I think I probably would just use absolute paths but they make local testing a bit of a pain and I'm also uploading the site to a different server while I build the site for the client to approve all the links would be broken until its on the correct server. I'll check them out and let you know how I get on. Thanks
  17. Hi Just starting out with PHP. Working on a site that uses some basic includes, these are working fine for all my files in the root of my site as the links from the header include is just linking straight to pages for example contactUs.php I am now however having to create some new folders to hold some product ranges, these are two folders down from the root of the site. I can link to the includes fine but the links don't work, to work they would need ../../ etc Now I could create a new header include file especially for use by the files in the deeper folders or I could make the links absolute but I just wondered if there was another way? I wondered if you could use PHP to perhaps detect the folder level and then add the necessary path??? I don't know am I way off the mark? Any help / tips much appreciated.
  18. Hi That worked when I also removed this section of code if (!ereg("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,6})$",strtolower($_POST['email']))) { exit("<p>That e-mail address is not valid, please use another.</p>"); } With that present even when the email is left blank it through up the error about the email address not being valid is there an way we can modify this still checks that the email address is valid when one is used but also allows no email to be used. Thanks very much Ricky55
  19. thanks mate I appreciate the help I will try the code and let you know how I get on
  20. Hi I have a form setup which works fine but it requires that all fields are complete before you submit. I want all fields to be required apart from the email address, could anyone have a look at the script and tell me how it needs to be modified to take out the email field from being required. Thanks By the way I am a complete newbie with PHP. the script <?php $after = "thanks.html"; $oops = "oops.html"; if (!isset($_POST['submit']) || $_SERVER['REQUEST_METHOD'] != "POST") { exit("<p>You did not press the submit button; this page should not be accessed directly.</p>"); } else { $exploits = "/(content-type|bcc:|cc:|document.cookie|onclick|onload|javascript|alert)/i"; $profanity = "/(beastial|bestial|blowjob|clit|cock|cum|cunilingus|cunillingus|cunnilingus|cunt|ejaculate|fag|felatio|fellatio|****|fuk|fuks|gangbang|gangbanged|gangbangs|hotsex|jism|jiz|kock|kondum|kum|kunilingus|orgasim|orgasims|orgasm|orgasms|phonesex|phuk|phuq|porn|pussies|pussy|spunk|xxx)/i"; $spamwords = "/(viagra|phentermine|tramadol|adipex|advai|alprazolam|ambien|ambian|amoxicillin|antivert|blackjack|backgammon|texas|holdem|poker|carisoprodol|ciara|ciprofloxacin|debt|dating|porn)/i"; $bots = "/(Indy|Blaiz|Java|libwww-perl|Python|OutfoxBot|User-Agent|PycURL|AlphaServer)/i"; if (preg_match($bots, $_SERVER['HTTP_USER_AGENT'])) { exit("<p>Known spam bots are not allowed.</p>"); } foreach ($_POST as $key => $value) { $value = trim($value); if (empty($value)) { exit("<p>Empty fields are not allowed. Please go back and fill in the form properly.</p>"); } elseif (preg_match($exploits, $value)) { exit("<p>Exploits/malicious scripting attributes aren't allowed.</p>"); } elseif (preg_match($profanity, $value) || preg_match($spamwords, $value)) { exit("<p>That kind of language is not allowed through our form.</p>"); } $_POST[$key] = stripslashes(strip_tags($value)); } if (!ereg("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,6})$",strtolower($_POST['email']))) { exit("<p>That e-mail address is not valid, please use another.</p>"); } $recipient = "[email protected], [email protected]"; $subject = "Web Site Enquiry"; $message .= "Name: {$_POST['name']} \n"; $message .= "Email: {$_POST['email']} \n"; $message .= "Contact: {$_POST['contact']} \n"; $message .= "Address: {$_POST['address']} \n"; $message .= "Postcode: {$_POST['postcode']} \n"; $message .= "Vehicle: {$_POST['vehicle']} \n"; $message .= "Damage: {$_POST['damage']} \n"; $headers .= "Reply-To: <{$_POST['email']}>"; if (mail($recipient,$subject,$message,$headers)) { echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=$after\">"; } else { echo "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=$oops\">"; } } ?>
×
×
  • 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.