Everything posted by bethlou
-
PHP Pear/Contact Form
Hi I am very new to PHP. I'm wanting a feedback form on my website where the form is sent via SMTP rather than sendmail. I have checked that php is working by doing this code: <?php error_reporting(E_ALL); ini_set('display_errors', True); $path = '/home/****/php'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); echo("<p>Sending PEAR Mail.php...</p>"); require('Mail.php'); $from = "Info <info@****.co.uk>"; $to = "Info <info@****.co.uk>"; $subject = "Hi - Test message!"; $body = "Hi,\n\nHow are you?"; $host = "mail.****.co.uk"; $username = "info@****.co.uk"; $password = "*******"; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } ?> This works fine. I have created a form in my contact page: <form name="feedbackform" action="form-mailer2.php" method="post"> <input type="hidden" name="Required" value="Name,Comments"> <p>Name: <input name="Name" size="30"> <span class="formsmall">required</span></p> <p>E-mail: <input name="Email" size="30"> <span class="formsmall">optional</span></p> <p>Feedback/Comments:</p> <p><textarea name="Comments" rows="5" cols="40"></textarea></p> <p><input type="submit" value="Submit" name="submitform"><input type="reset" value="Reset" name="reset"></p> </form> I then used the code based on the php above and the one found to get the form details from the contact page and send to the email address via smtp. I have left the validations in - although if these are no good please feel free to tell me! I will want to put a captcha in but need to look into that yet. Anyway, the code I have created is now this (which is saved in the file form-mailer2.php: <?php error_reporting(E_ALL); ini_set('display_errors', True); $path = '/home/******/php'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); echo("<p>Sending PEAR Mail.php...</p>"); require('Mail.php'); $mailfrom = "info@***.co.uk"; $mailTo = "info@***.co.uk"; $mailSubject = "Web Feedback"; $mailHost = "mail.***.co.uk"; $mailPort = "25"; $mailAuth = "true"; $mailPassword = "****"; // Get the form fields. $name = $_POST['Name']; $email = $_POST['Email']; $comments = $_POST['Comments']; $reqFields = $_POST['Required']; // I find including the time/date useful for record-keeping. // Note that it is the web server's time/date, not yours // or the sender's. $date = date("l jS F Y, g:i A"); // A simple yet reasonably effective email address validator. if ((!ereg(".+\@.+\..+", $email)) || (!ereg("^[a-zA-Z0-9_@.-]+$", $email))) { $errorMessages .= "<li>Invalid email address: $email</li>"; } // Make sure required fields are filled in. $checkFields = explode(",",$reqFields); while(list($theField) = each($checkFields)) { if(!$$checkFields[$theField]) { $errorMessages .= "<li>Missing $checkFields[$theField]</li>"; } } // If there are errors, display them and a back button. I would prefer this to flash up on the contact form rather than on a different page though. if($errorMessages) { ?> <p>Errors were found on the form.</p> <ul> <?php echo $errorMessages; ?> </ul> <p><input type="button" value="Back" onClick="history.back()"></p> <?php } // No errors, send the message and print out success message. else { // Build the email. $body = " Name: $Name Email: $Email Phone: $Phone ----- Comments ----- $Comments -------------------- $headers["From"] = $mailTo; $headers["To"] = $mailTo; $headers["Subject"] = $mailSubject; $params["host"] = $mailHost; $params["port"] = $mailPort; $params["auth"] = $mailAuth; $params["username"] = $mailTo; $params["password"] = $mailPassword; $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($mailTo, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } // I would rather redirect to a different thank you page but both of next options don't work when taking out: //echo("<p>Message successfully sent!</p>"); //RedirectToURL("thank-you.php"); or header(Location: "thank-you.php" ); ?> Depending on what I change about I either get: The website cannot display the page or a list of undefinable variables. If anyone is able to understand the php and notice where the problem lies I would be so grateful. Thank you. (Acknowledgement given to http://www.web1marketing.com/resources/tools/php-form-mailer.htm where I have adapted the form from).
-
smtp authentication for contact form
There is also this version I have found, PHPMailer instead of PEAR - but I have the same issues - where to put it and what am I supposed to delete! require_once('../class.phpmailer.php');//include("class.smtp.php"); // optional, gets called from within class.phpmailer.php if not already loaded$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch$mail->IsSMTP(); // telling the class to use SMTP try { $mail->Host = "mail.yourdomain.com"; // SMTP server $mail->SMTPDebug = 2; // enables SMTP debug information (for testing) $mail->SMTPAuth = true; // enable SMTP authentication $mail->Host = "mail.yourdomain.com"; // sets the SMTP server $mail->Port = 26; // set the SMTP port for the GMAIL server $mail->Username = "yourname@yourdomain"; // SMTP account username $mail->Password = "yourpassword"; // SMTP account password $mail->AddReplyTo('name@yourdomain.com', 'First Last'); $mail->AddAddress('whoto@otherdomain.com', 'John Doe'); $mail->SetFrom('name@yourdomain.com', 'First Last'); $mail->AddReplyTo('name@yourdomain.com', 'First Last'); $mail->Subject = 'PHPMailer Test Subject via mail(), advanced'; $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically $mail->MsgHTML(file_get_contents('contents.html')); $mail->AddAttachment('images/phpmailer.gif'); // attachment $mail->AddAttachment('images/phpmailer_mini.gif'); // attachment $mail->Send(); echo "Message Sent OK<p></p>\n"; } catch (phpmailerException $e) { echo $e->errorMessage(); //Pretty error messages from PHPMailer } catch (Exception $e) { echo $e->getMessage(); //Boring error messages from anything else! }
-
smtp authentication for contact form
Hi I have stumbled across your forum post as I am desperately trying to work the exact same thing out for myself. After lots of reading I am starting to work out the direction I'm going but the problem I have is how to incorporate the SMTP bits into the current form I have. I looked at the code (as linked above) but in the contact form I have - using the unsecure option - I don't know what bits I should or can delete as there seems to be a lot about the validations of the form. I am very much a novice and so have used the Contact form with CAPTCHA - Contact form where you can view the files I think the one I need to change is the fgcontactform.php but the php code before the DOCTYPE on the contactform.php page asks for the email address (I'm hoping this copies properly!): <?PHP /* Contact Form from HTML Form Guide This program is free software published under the terms of the GNU Lesser General Public License. See this page for more info: http://www.html-form-guide.com/contact-form/creating-a-contact-form.html */ require_once("./_scripts/contactform/fgcontactform.php"); /*require_once("./_scripts/contactform/captcha-creator.php"); $formproc = new FGContactForm(); $captcha = new FGCaptchaCreator('scaptcha'); $formproc->EnableCaptcha($captcha); */ //1. Add your email address here. //You can add more than one receipients. $formproc->AddRecipient('info@website.co.uk'); //<<---Put your email address here //2. For better security. Get a random tring from this link: http://tinyurl.com/randstr // and put it here $formproc->SetFormRandomKey('CnRrspl1FyEylUj'); if(isset($_POST['submitted'])) { if($formproc->ProcessForm()) { $formproc->RedirectToURL("thank-you.php"); } } ?> <?php session_start(); if( isset($_POST['submit'])) { if( $_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) { // Insert you code for processing the form here, e.g emailing the submission, entering it into a database. echo 'Thank you. Your message said "'.$_POST['message'].'"'; unset($_SESSION['security_code']); } else { // Insert your code for showing an error message here echo 'Sorry, you have provided an invalid security code'; } } else { ?> Thank you if anyone is able to help. Beth
-
Embedded Object
Thank you, those links are really interesting and helpful. I have got it working, yay! Just need to fiddle a bit more with it now Beth
-
Embedded Object
Very true Unfortunately it hasn't made any difference, I still can't see the play options. Beth
-
Embedded Object
Thanks, I tried that. In PSPad that I use on the preview that works lovely, but when I upload the file to the server firefox still doesn't show anything at all. In Internet explorer previewing the document from my computer gives me a Q for the player with no pop-ups to suggest I need to download or allow anything and once it's uploaded to the server shows a broken film strip. I've attached screen shots of both. There must be something I'm not doing right, but it's got me stumped! Thanks The code was: <h4>Click on the following to hear samples from the CD:</h4> <ul><li>Des oges mais <embed src="../_music/cds/medieval_feast/des_oges.mp3" width="140" height="40" autostart="false" loop="FALSE"> </embed> </li>
-
Embedded Object
Hi Is anyone able to see why this embedded object will show up in IE but not in Firefox. I've checked my link to the music file and that's not the problem, but that in IE the play/pause symbol shows up and in firefox it doesn't show at all. <h4>Click on the following to hear samples from the CD:</h4> <ul><li>Des oges mais <object height="27px" width="70px" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"> <param name="AutoStart" value="0" > <!-- not wanting it to play on page loading --> <param name="FileName" value="../_music/des_oges.mp3"> <param name="loop" value="0" > </object> </li> Perhaps there is a better way of being able to do this? I'm creating a list of cd's and on just a couple of tracks I want a 30sec example/intro that people can choose to click to hear, or a link that will allow them to download. Thanks Beth
-
Special html characters e.g ampersand
Thank you. Is there a reason why the worded ones are better than the numbers version? And, is it ok to mix and match, e.g. left parenthesis ( ( right parenthesis ) ) don't have the worded version. Do they still work ok with: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> Beth
-
Special html characters e.g ampersand
Hi I have been researching the information needed for the <HEAD> section of a webpage and what I need to put in to allow the use of special characters. I have been using the characters from http://www.webmastersprofitpak.net/html-codes.html but have also found those from http://www.tedmontgomery.com/tutorial/htmlchrc.html the more wordy ones, so for an ampersand I usually use & rather than & What is best practice? When I have validated the code most of the x; ones have worked fine apart from one for quote marks. I am wondering if there is a rule for what is put in the head section and what style of special characters are used. I can't seem to find the answer that definitively says "use this in your head section when using the following special characters". I can find a lot of references to the different meta options and I use UTF-8 but there also seems to be charset=ISO-8859-1 and others. Am I confusing what this means, I feel I must be?! Thanks Beth
-
Cross browser issues
Thank you sooooo much. I have just seen your message and uploaded it and it works, yay! )) I can't believe it was so simple, I'm embarrassed I hadn't worked it out, or been able to find the quirks of this doctype, but thanks again I thought I was going to have to start all over again. Best wishes for 2011 Beth
-
Cross browser issues
Thank you for your suggestion, I've given it a go but.... I have changed one line to <meta http-equiv="content-type" content="text/html;charset=utf-8" /> which hasn't made any difference (to css formatting or to the character issues. I have tried the different doctypes - strict/transitional etc listed in the webpage. If I change it to any of them it undoes the formatting of the css (even in IE) and puts in bullets when there shouldn't be, I revalidated each time and I get a thumbs up. Doesn't that mean I've written my css right according to whichever doctype I use, so why won't the browsers cooperate? It doesn't seem to like it when I just add one of the additional lines to the existing doctype, it goes wrong again: "http://www.w3.org/TR/html4/strict.dtd"> "http://www.w3.org/TR/html4/loose.dtd"> and only works perfectly like this: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" <html> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> If I need to change the doctype to one of the others, what would I have to do in the css to make it work as I really did think I had written everything quite simply, especially as I have fixed the layout to px. Thanks again in advance
-
Cross browser issues
I am totally confused. I have written this webpage (file attached) index2.html(css and html all in one page at the moment, it won't be eventually) it has passed W3C validation (apart from 4 warnings for the characters I've used to replace punctuation - not sure why that's wrong either though). It looks ok in IE7 (with different screen resolutions), all in line with the header expanding the correct width, the ul/li's not displaying bullets unless I've changed them specifically to something else. The blockquote in my third column styled with a div is at the top of the page, not shunted to the bottom. But when I view it in opera/Firefox etc it looks awful. I have made it purely through a notepad style program (rather than dreamweaver etc) and can't for the life of me understand what I have done wrong. Is anyone able to help me please? Many thanks in advance
-
Which shopping cart you prefer?
This is really helpful for me as I am a complete new starter to shopping carts. I have a client who is a musician wanting to sell his cd's online. He currently uses the Paypal Buy Now button and it takes him from his website to Paypal's own page. What he wants now is a shopping cart version. I have been looking into the Paypal Add to Cart option and also Prestashop, ZenCart and OsCommerce thanks to posts on this forum. What I am struggling to understand is (not how to download these exactly or how to enter products as I'm guessing that will be self-explanatory when I go through the process) but how it actually works. If I have my webpage with html and css coding and then one of these shopping carts how do they integrate with the existing site - do I have to add extra links to my existing page for the shopping carts/checkouts (how do I know what these links would be) etc or do I have to redesign/recreate the website in one of these programs? I was hoping not to end up with the same issue he has at the moment where once the buyer clicks buy now or add to cart that they are navigated away from his actual website as they may wish to browse some more. And if they are navigated away how do I get them back to the site? Many thanks Beth
-
MyPHP Forum
Hi I would like to make a simple discussion forum ( with a little bit of styling so it doesn't look really bad!). I have heard that MyPHP Forum is a really good program to use but I wondered what other people thought? I also wondered how I go about starting this as I don't know where to download it from or find userguides on how to set it up. Perhaps there are other free forum software packages available that would be better? The only other one I've heard of is vBulletin but I don't think that is free. Many thanks Beth.
-
background image on <h2> tags
Thanks, that works quite well. Enhancing this further, if I reduce the margin on the left so it would start more over on the left (overlapping the navigation <div>) it actually disapears underneath it. Any ideas how I can achieve that. My thoughts are z-index ( have tried it but can't work out why it won't work, but surely it must?!) or absolute position, (haven't tried this but a. will it still disappear under div and b. will it move in relation to the <h2> tag if more content is added or if the screen resolution is altered?) Thanks Beth
-
background image on <h2> tags
Thanks Adding padding works to make the picture show but it also creates lots of extra space around that header, more than I want. Is there anyway of getting the image to be under the h2 tag but also overlap the other paragraphs? (I've tried to make what I want it to look like in photoshop.) Beth
-
background image on <h2> tags
Hi I would like to be able to place an image I have created so it appears underneath ny <h2>/<h3> tags at the beginning. The image I can resize but I want it to be a bit bigger than the pre-defined size of the headers. What seems to happen when i use the following code is show the image but only one part of it rather than having the swirling bits being much larger - I'm hoping that makes sense when you see the image. h2 { background-image:url(..\floral95.png); background-repeat: no-repeat; padding: 0; margin:0; } the html is: <h2>Private Functions and Corporate Event Options</h2> <p>random blurb</p> <h3>Weddings</h3> I have attached the image:floral97 If anyone can help that would be great. Thanks Beth
-
W3C CSS Validator
Thanks, that is reassuring although there must be a way of avoiding it. What do other people do? Beth
-
W3C CSS Validator
Hi I have checked my css file using the CSS Validator for W3C and it has come up with five warnings. 64 Same colors for color and background-color in two contexts h1 and h2 64 Same colors for color and background-color in two contexts a:hover and h2 64 Same colors for color and background-color in two contexts a:active and h2 64 Same colors for color and background-color in two contexts #footer and h2 86 Same colors for color and background-color in two contexts #container and #footer a I am not sure how to correct these. Basically I have the h1 as background red with white writing . The footer is the same but with smaller font and hover over changes for the links. The h2 used in the main content of the site is red on a white background. Can anyone help with how to tidy up the code so it will validate. I tried taking the colour from the h2 but it then goes the same as the rest of the content and I don't want that. Many thanks Beth
-
Transferring Domain, bought by someone else to my host
Hello The scenario is: A friend has asked a web hosting company to buy a domain name for her. She is registered as the owner and her home address comes up on the Whois directory. She doesn't however have any of the details regarding the account/purchase details. She has the telephone number of the chap and wants me to contact him so I can then sort out her hosting, she no longer wants to use his services. What I am unsure about is what I actually need to find out from this chap so I can let the hosting company know I want to host this domain name with them. I'm guessing it's just some password details but I don't know what a host would need. When I have carried out the transfer/set up the hosting for this domain, do I need to change any account details so this chap can't upset all the arrangements? Many thanks Beth
-
CMS for Photographer
Hi Does SilverStripe mean you have to build your website in this package for the cms to work, or can you apply it to your already designed website made with standard html and css for styling? Thanks Beth
-
mysql & php_how to upload photo's
Hi I have been building a very simple website for a local sports club based purely on html and css. I have been asked to add a gallery page where the members can upload pictures of certain events from their own cameras. I have just recently been learning about php and mysql and feel I could probably sort out the database and the php code for members to enter their details and upload the table. (I haven't tried but I'm optimistic ). What I am really struggling to comprehend is how: a) I get them to upload an image - I am only thinking of emails for example where you get to browse you computer for uploading an attachment, I don't know if there is another way. b ) how do I get it to display properly in a webpage so it looks good, rather than just a list - would I need to design a table and then somehow get the php to populate each box, and how do they add new sub headings if the pictures relate to specific events? c ) how do they upload images to the database/get them on the webpage at a compressed size? I would normally get the picture, alter size etc in Irfanview and then upload to webserver via ftp, but is there a way to have this done another way or would the member have to be able to do this themselves prior to uploading? Is this type of thing usually done or is there some big package that should be designing it. I prefer to understand the code rather than using packages like Dreamweaver as I wouldn't know where to start with that. Thanks in advance for any advice or tips. Beth
-
Hosting Packages Explained
Thank you. At the moment I think it will be quite plain. I've only just started teaching myself Dreamweaver CS3 as all my other websites are very flat with just html/css.
-
Hosting Packages Explained
Thank you for those suggestions. Could you tell me the difference between Windows v Linux web hosting, is one more reliable than the other?
-
Hosting Packages Explained
Thank you that is really helpful, and please go on for as long as you want it all helps Are there often problems with hosting and issues that need sorting out. I haven't ever had any problems with my personal site with the hosting side of things, I always seem to be able to access the control panel (I enter the ftp address, enter my password and then choose 'open ftp site in windows explorer') and I can always view the website. Thanks