Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

bethlou

Members
  • Joined

  • Last visited

  1. 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).
  2. 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! }
  3. 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
  4. bethlou replied to bethlou's topic in Frontend
    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
  5. bethlou replied to bethlou's topic in Frontend
    Very true Unfortunately it hasn't made any difference, I still can't see the play options. Beth
  6. bethlou replied to bethlou's topic in Frontend
    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>
  7. bethlou posted a topic in Frontend
    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
  8. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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
  14. bethlou posted a topic in Server Side
    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.
  15. 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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.