www.webdeveloper.com
Results 1 to 7 of 7

Thread: feedback script

  1. #1
    Join Date
    Dec 2012
    Posts
    7

    feedback script

    Hi,

    I'm trying to use this script for sending emails via form on my website and it works perfectly when it's in the root folder, but when I'm trying to put it on my site the submit button doesn't work. Site I want to put it in is in /public_HTML/folder1/index.html and all feedback files in /public_HTML/folder1/folder2/...
    I was trying to change the names of files and put there relative links and nothing happened.

    All scripts/files are here http://www.quackit.com/html/codes/ht...m_to_email.cfm

  2. #2
    Join Date
    Aug 2012
    Posts
    155
    It is no good linking to a script you have used, if you want help we need to see the specific code that you are having problems with (i.e. where you are trying to send your emails or redirect after email is sent).

  3. #3
    Join Date
    Dec 2012
    Posts
    7
    The full code is on that website at the bottom. I don't know where the problem is exactly in the code, so that's why I've put the whole one. I will also paste the part I think I'm having problem with.
    The only thing I'm changing is email address to send feedback. It's help@polineng.tk but I'm having a problem with finding a file(site) with thank you or error message after hitting 'submit' button.
    Structure looks like this:

    /public_html/
    /eng/
    /eng/feedback/
    /eng/feedback/feedback_form.html
    /eng/feedback/thank_you.html
    /eng/feedback/error_message.html
    /eng/feedback/send_mail.php
    /eng/uk.html
    index.html

    When all files from 'feedback' folder are directly in the root folder it works fine, but when it's in sub-folders (like above) script is not finding any files and not sending the email to my inbox.

    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Feedback Form</title>	
    </head>
    <body>
    <h1>Send Us Your Feedback!</h1>
    <form action="send_mail.php" method="post">
    (...) // structure of the form is not important, so I cut it out
    
    <input type="submit" value="Submit" /> 
    </form>
    
    </body>
    </html>
    Like I said, this script is not finding I think the problem is with this part:
    PHP Code:
    /*
    This bit sets the URLs of the supporting pages.
    If you change the names of any of the pages, you will need to change the values here.
    */
    $feedback_page "feedback_form.html";
    $error_page "error_message.html";
    $thankyou_page "thank_you.html";
    /*
    This next bit loads the form field data into variables.
    If you add a form field, you will need to add it here.
    */
    $email_address $_REQUEST['email_address'] ;
    $comments $_REQUEST['comments'] ;

    (...)

    // If the user tries to access this script directly, redirect them to the feedback form,
    if (!isset($_REQUEST['email_address'])) {
    header"Location: $feedback_page); 

    Here is the whole script. It's a bit different than the one on the website I gave in the first post.
    PHP Code:
    <?php
    /*
    This first bit sets the email address that you want the form to be submitted to.
    You will need to change this value to a valid email address that you can access.
    */
    $webmaster_email "help@polineng.tk";

    /*
    This bit sets the URLs of the supporting pages.
    If you change the names of any of the pages, you will need to change the values here.
    */
    $feedback_page "feedback_form.html";
    $error_page "error_message.html";
    $thankyou_page "thank_you.html";

    /*
    This next bit loads the form field data into variables.
    If you add a form field, you will need to add it here.
    */
    $email_address $_REQUEST['email_address'] ;
    $comments $_REQUEST['comments'] ;

    /*
    The following function checks for email injection.
    Specifically, it checks for carriage returns - typically used by spammers to inject a CC list.
    */
    function isInjected($str) {
        
    $injections = array('(\n+)',
        
    '(\r+)',
        
    '(\t+)',
        
    '(%0A+)',
        
    '(%0D+)',
        
    '(%08+)',
        
    '(%09+)'
        
    );
        
    $inject join('|'$injections);
        
    $inject "/$inject/i";
        if(
    preg_match($inject,$str)) {
            return 
    true;
        }
        else {
            return 
    false;
        }
    }

    // If the user tries to access this script directly, redirect them to the feedback form,
    if (!isset($_REQUEST['email_address'])) {
    header"Location: $feedback_page);
    }

    // If the form fields are empty, redirect to the error page.
    elseif (empty($email_address) || empty($comments)) {
    header"Location: $error_page);
    }

    // If email injection is detected, redirect to the error page.
    elseif ( isInjected($email_address) ) {
    header"Location: $error_page);
    }

    // If we passed all previous tests, send the email then redirect to the thank you page.
    else {
    mail"$webmaster_email""Feedback Form Results",
      
    $comments"From: $email_address);
    header"Location: $thankyou_page);
    }
    ?>

    Now I also don't know why the feedback is not send too. Is the script not doing anything else after not finding the file or the 'submit' button on my website is not even finding the script (file send_mail.php)
    Last edited by Polineng; 12-11-2012 at 10:01 AM.

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,361
    Is it "/public_html/eng/feedback/", or is "/eng" at the same level as "/public" (i.e., not a subdirectory of it)?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Aug 2012
    Posts
    155
    Well if all your files for your feedback form are in the same folder (the public_html/eng/feedback/ folder) then there should be no problem with your header redirects as you have them. Therefore I would suggest putting your location variables in {} in the header locations, like so.
    PHP Code:
    header"Location: {$feedback_page}); 
    And see if that helps.

    If all the files are not within this sub folder (including the form page) then your links won't work as you have them.

  6. #6
    Join Date
    Dec 2012
    Posts
    7
    Quote Originally Posted by simplypixie View Post
    Well if all your files for your feedback form are in the same folder (the public_html/eng/feedback/ folder) then there should be no problem with your header redirects as you have them. Therefore I would suggest putting your location variables in {} in the header locations, like so.
    PHP Code:
    header"Location: {$feedback_page}); 
    And see if that helps.

    If all the files are not within this sub folder (including the form page) then your links won't work as you have them.
    They are in the same folder, that's why I don't know what is wrong. I will try it with {}

    Quote Originally Posted by NogDog View Post
    Is it "/public_html/eng/feedback/", or is "/eng" at the same level as "/public" (i.e., not a subdirectory of it)?
    /eng is a subfolder of /public
    I had to do it like that because of my poll script. I've got two main pages in two different languages.

  7. #7
    Join Date
    Dec 2012
    Posts
    7

    Thumbs up

    Problem solved!

    It was working fine but because I was removing .html from address bar it wasn't finding the files.

    .htaccess was blocking it. I was changing the name from file.html to file/ but I guess it not working in this script.

    Code:
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}\.html -f
    RewriteRule ^([^/]+)/$ $1.html 
    
    # Forces a trailing slash to be added
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
    RewriteRule (.*)$ /$1/ [R=301,L]
    Thanks for your time guys.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles