Jump to content

Rob in hood

Member
  • Posts

    25
  • Joined

  • Last visited

Posts posted by Rob in hood

  1. Form code:

    
    Name *: 
    
    
    Email address *: 
    
    
    Contact no: 
    
    
    
    
    
    Message *: 
    
    
    
    

     

    email.php:

    <?php
    //first make sure from is sanitary
    $from = $_POST["from"];
    $from=filter_var($from, FILTER_SANITIZE_EMAIL); //this first cleans it, so that it contains the right kind of characters
    if(filter_var($from, FILTER_VALIDATE_EMAIL)){ //this checks the resulting clean address for well-formedness
       $to = "fdfdfd@gmail.com";
       $subject = "Feedback";
       //$message = $_POST["msg"] + ;
       reset($_POST);
       while (list($key, $val) = each($_POST))
         {
         $message .= "$key => $val \n";
         }
       $headers = "CC: gdfdfdd@gmail.com";
       //mail($to,$subject,$message,$headers);
       echo "Thank you! We will get back to you shortly.";
    }
    else
    {
       echo 'The from address provided is invalid!';
       echo '
    '.$from.'
    ';
       reset($_POST);
       while (list($key, $val) = each($_POST))
         {
         echo "$key => $val 
    ";
         }
    }
    ?>

     

    I just did another test, running the same, non-working email.php on a different HTML form -- had the same problem (submit 1st time=error, 2nd time=works). When I use a different, older email.php of mine then it works first time as expected.

     

    So it would seem there's something wrong with the PHP code then?

     

    An older, working email.php:

    <?php
    //first make sure from is sanitary
    $from = $_POST["from"];
    $from=filter_var($from, FILTER_SANITIZE_EMAIL); //this first cleans it, so that it contains the right kind of characters
    if(filter_var($from, FILTER_VALIDATE_EMAIL)){ //this checks the resulting clean address for well-formedness
       $to = "dfdfdfs@gmail.com";
       $subject = "Feedback";
       $message = $_POST["msg"];
       if ($_POST["name"]=="")
           $headers = "From: $from";
       else
           $headers = "From: "+$_POST["name"];
       mail($to,$subject,$message,$headers);
       echo "Mail Sent.";
    }
    else
    {
       echo 'The from address provided is invalid!';
       echo '
    $from';
    }
    ?> 

  2. So that's your problem you are trying to run the email stuff even though no one has filled out and submited the form .

     

    Unfortunately, that is not the problem: I am filling in the form and then pressing submit. The html is sending the data method="post". The problem is that the first time I press submit, it's as if the .php file gets no POST data. I press back and press submit again - without changing anything - and then it miraculously works.

  3. Most important first step, sounds like a stupid mistake, but people tend to miss this somehow.

    Are you running the code without checking if the form was sent, which basically means that first time you enter that page the whole validation code starts, but the problem is that nothing has been sent thus $_POST is not filled with what you are looking for.

    And based on the error code generated I got a feeling it might have something to do with this.

     

    It does seem like the $_POST is not filled on the first submit. What do I do to fix this?

     

    This code

        while (list($key, $val) = each($_POST))
         {
         echo "$key => $val 
    ";
         }

    prints out all the key-value pairs inside the $_POST. On the first run it doesn't print out anything, implying $_POST is empty.

     

    I can't see the reason why the $_POST is empty on the first go, but after I press back and Submit again it works as expected.

  4. I have some php code to send me an email with all of an HTML form's data layed out.

     

    I load up the page, type in some random stuff and press submit. I then get this response:

     

    The from address provided is invalid!
    
    

     

    I press back - change nothing - and click submit again, and then I get this: (the correct response)

     

    The from address provided is invalid!
    
    ff55@gg
    
    name => Test 
    
    from => ff55@gg 
    
    contactno => 050505 
    
    msg => MESSAGE 
    

     

    The same thing happens when I put in a correctly formed email address. I first get the error, press back, submit again and it goes through without a problem and I receive the email.

     

    Once it's worked once, it will continue to work when I press back and re-submit. Until I change anything in the form - then it gives the erroneous response once. Click back, submit again and it's back to working properly.

     

    This is happening in the pages dished out by the server, not on something I'm running locally.

     

    I am really at a loss here - don't know how I'm supposed to debug code which works every second time it's run O_o. Any suggestions would be appreciated.

     

    Here's the strange php code.

    <?php
    //first make sure from is sanitary
    $from = $_POST["from"];
    $from=filter_var($from, FILTER_SANITIZE_EMAIL); //this first cleans it, so that it contains the right kind of characters
    if(filter_var($from, FILTER_VALIDATE_EMAIL)){ //this checks the resulting clean address for well-formedness
       $to = "myaddress@gmail.com";
       $subject = "Feedback";
       //$message = $_POST["msg"] + ;
       reset($_POST);
       while (list($key, $val) = each($_POST))
         {
         $message .= "$key => $val \n";
         }
       $headers = "CC: anotheraddress@gmail.com";
       //mail($to,$subject,$message,$headers);
       echo "Thank you! We will get back to you shortly.";
    }
    else
    {
       echo 'The from address provided is invalid!';
       echo '
    '.$from.'
    ';
       reset($_POST);
       while (list($key, $val) = each($_POST))
         {
         echo "$key => $val 
    ";
         }
    }
    ?>

  5. I looked into Website tonight briefly once a while back' date=' and I don't remember there even being any option to edit any HTML - it's just a WYSIWYG tool.[/quote']

     

    I really think I need something else, I just hate to start all over. I wonder though if I couldn't get new hosting, and just copy and paste that html into the new one to start where I left off?

     

    Is http://www.mindionmusic.com/ your website?

     

    I am not seeing the navigation you speak of. Can you post a link to the page with the problem?

  6. I am having a very weird problem with my background image. Its edges are all #080808 (verified in MS Paint and Photoshop). I have set this color in the CSS (see below). When Firefox renders it in Windows it renders the edges of the background image at #0c0c0c. When FF renders it in Mac, it does #0a0a0a. Opera in Mac renders it correctly at #080808. Safari fails. Internet Explorer 8 renders correctly at #080808.

     

    What on earth is going on? O_o :/

     

    body {
       font-family: Helvetica, Verdana, sans-serif;
       letter-spacing: 1px;
       font-size: 19px;
       background: #080808 url(images/background.jpg) center top no-repeat;
       margin: 0;
       padding: 0;
       height: 853px;
    }

  7. I realised I should maybe post the CSS code.

     

    @charset "UTF-8";
    /* CSS Document */
    body {
     background: #1b1b1b url(images/bodytile.png) center repeat-y;
     margin: 0px;
     padding: 0px;
    }
    #container {
     width: 1010px;
     margin: 0 auto;
    }
    #header {
     background: #1b1b1b url(images/headertile.png) top repeat-x;
     height: 167px;
    }
    #leftcol {
     background: #1b1b1b url(images/bgleft.png) top right no-repeat;
     float: left;
     width: 5px;
     height: 500px;
    }
    #rightcol {
     background: #1b1b1b url(images/bgright.png) top left no-repeat;
     float: right;
     width: 5px;
     height: 500px;
    }
    #content {
     background: #e9e9e9;
     float: left;
     width: 1000px;
     height: 1200px;
    }
    #footer {
     background: #1b1b1b url(images/footer.png) bottom center no-repeat;
     clear: both;
     height: 97px;
    }

  8. I actually want the image to overflow the div. I want the overflow to get cut off by the browser window, instead of making scrollbars to show the rest of the image.

     

    The reason for this approach is so that the browser cuts off equally from both sides of the border for smaller screen resolutions. If I used fixed width border divs, then for small screen resolutions the border divs will make the browser have horizontal scrollbars.

     

    The alternate I know to this way is to make a big background image with both border pictures, and a big blank area in the middle, and set that image as the background image. But this makes the image unnecessarily large, just for the big blank area in the middle, seperating the border images.

     

    Position:fixed did stop it from making scrollbars, but I want the image to scroll, not be fixed :)

  9. Thanks for the reference information. I'll read through them and just absorb the essential ideas, to have a reference later for finding bugs.

     

    I've just downloaded Firebug, and will have a look at it and the tutorial tomorrow - 1AM is approaching and starting to make my eyes feel sandy :(

  10. If you add:

     

    $nav ul { margin:0; }

     

    Yay!! :D That sorted things out - thank you. So does that mean setting the border has a side effect of setting the margin to 0?

     

    Thanks for the other comments, I'm glad you think it's mostly good. I've removed the width: inherit lines. I wasn't sure what stuff does and doesn't get inhertted, is there some kind of reference where I can find out about inheritance rules and default values? If the quotes aren't doing any harm then I'll leave them because my inner-programmer likes strings to look like that :)












  11. Important Booking Information:



    Tha payj


    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec orci tellus, sagittis ut condimentum a, interdum id turpis. Maecenas rutrum lorem quis libero fringilla volutpat. In tristique orci vel nisi aliquam dapibus consectetur tellus scelerisque. Aliquam vulputate volutpat metus, ac imperdiet nibh aliquet vitae. Donec cursus rutrum ultrices. Donec sit amet tortor magna. Phasellus ultricies nisl id urna cursus suscipit. Phasellus cursus lorem sit amet nisi consequat ac sagittis enim tempor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Fusce egestas imperdiet rhoncus. Mauris dapibus sem quis libero malesuada scelerisque. Cras faucibus ante ut neque eleifend adipiscing. Nam augue libero, porta et mattis vitae, sagittis sed mi.


    Re hahahaha lity!!


    Suspendisse et ante a augue venenatis suscipit. Morbi hendrerit massa id lorem facilisis ut viverra justo cursus. Maecenas ac lectus non libero pellentesque imperdiet. Nulla facilisi. Cras non enim id magna semper sagittis. Morbi quam est, molestie ac rutrum non, aliquam et mi. Vestibulum dapibus auctor nisl nec molestie. Nam porttitor gravida dui, id venenatis velit suscipit aliquet. Nulla in lacus a dolor dignissim malesuada eu eu lorem. Vestibulum sed euismod diam. Nunc pellentesque accumsan ligula sed semper. Donec malesuada mi in mauris semper tristique. In vel diam id nisl lacinia ornare. In blandit ornare accumsan. Integer justo libero, dapibus ac lobortis nec, laoreet vel quam.


    Nulla in consectetur neque. Nulla ac augue nunc. Aliquam tempor sem et mi blandit ultricies eleifend sem hendrerit. Nunc velit leo, interdum sit amet cursus ut, bibendum vitae elit. Nunc tortor mi, semper vel tincidunt et, tristique a turpis. Etiam tempor commodo sollicitudin. In auctor urna ac elit euismod blandit. Vivamus mattis libero vitae turpis dapibus non vulputate magna vehicula. Phasellus sit amet nisl nulla, ut luctus nibh. Quisque varius turpis augue. In eleifend varius feugiat. Aliquam non felis arcu, quis imperdiet massa. Phasellus non sem nisi. In vitae risus sapien. Proin facilisis aliquam tortor eget hendrerit.


    Pellentesque ac neque leo. Vestibulum in felis libero. Pellentesque mollis, justo nec cursus accumsan, magna nibh malesuada diam, vitae eleifend mi dolor vitae massa. Cras et sem nibh. Suspendisse potenti. Sed vitae justo dolor, eget ultricies lectus. Cras non enim id magna semper sagittis. Morbi quam est, molestie ac rutrum non, aliquam et mi. Vestibulum dapibus auctor nisl nec molestie. Nam porttitor gravida dui, id venenatis velit suscipit aliquet. Nulla in lacus a dolor dignissim malesuada eu eu lorem. Quisque adipiscing semper diam sit amet malesuada. Phasellus tincidunt ultrices commodo. Phasellus iaculis egestas dui nec condimentum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vivamus at enim felis, semper aliquam massa.


    Sed eget pretium sapien. Pellentesque non tellus et nisl facilisis accumsan. Nam tempor mi vitae ante condimentum vel varius nibh ornare. Praesent orci enim, porta et porta sed, condimentum eget ipsum. Ut mollis dolor id dolor lacinia accumsan. Nunc luctus gravida nibh mollis vulputate. Morbi tempus, felis sit amet pharetra dictum, velit erat consequat leo, eu scelerisque leo mi sit amet felis. Duis id quam quis diam pharetra tristique. Fusce sem enim, dignissim et posuere eu, porta varius ante. Duis luctus, urna id dictum venenatis, dolor urna dapibus lacus, et consectetur nunc ligula sit amet turpis. Curabitur ultricies velit sed dui tristique ut iaculis urna dictum. Fusce metus nisl, elementum non pulvinar nec, vulputate tristique sapien. Maecenas nec eros mi, quis suscipit metus. In ac est eget risus malesuada ultrices a ut nulla. Morbi semper congue adipiscing. Nulla iaculis commodo lorem, sit amet ultricies libero aliquam eget.
    Donec risus orci, vehicula at consectetur ac, aliquet eget tortor. Aenean et lorem accumsan justo placerat condimentum. Praesent ac dictum nisl.



    © 2009 All rights reserved









  12. Note that Eric didn't include display: block; that's because when you style float: left it automatically converts the element to block; but of course you need to delete the display: inline or there will be a conflict (which he did).

     

    I usually include display: block where I've deliberately changed an inline element, even though float does it for me, just so that I have a reminder there that I changed it.

     

    Ah, good to know! I'm slowly learning those little intracacies like that :)





  13. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed at ante. Mauris eleifend, quam a vulputate dictum, massa quam dapibus leo, eget vulputate orci purus ut lorem. In fringilla mi in ligula. Pellentesque aliquam quam vel dolor. Nunc adipiscing. Sed quam odio, tempus ac, aliquam molestie, varius ac, tellus. Vestibulum ut nulla aliquam risus rutrum interdum. Pellentesque lorem. Curabitur sit amet erat quis risus feugiat viverra. Pellentesque augue justo, sagittis et, lacinia at, venenatis non, arcu. Nunc nec libero. In cursus dictum risus. Etiam tristique nisl a nulla. Ut a orci. Curabitur dolor nunc, egestas at, accumsan at, malesuada nec, magna.





×
×
  • Create New...