Error with the loop

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • atyndall
    New Member
    • Sep 2007
    • 13

    Error with the loop

    have a look for yourself, <REMOVED> (feel free to send emails)
    dont enter in the visual code (or enter it incorrectly) (or correctly) and see how all hell breaks loose (the loops of death!) where it should just pop-up with (one) an error message.

    Code (mail.php)
    [PHP]<?php

    $subject = $_POST['subject'];
    $message = $_POST['message'];

    include 'config.inc.php ';

    function alert_redirect( $alert) {
    echo "
    <html>
    <head>
    <script language='Javas cript'>
    <!--
    alert ('$alert')
    window.location = '$homepage'
    //-->
    </script>
    <title>$alert </title>
    </head>
    <body>
    <div align='center'>
    <h1>$alert</h1>
    <form id='' name='' method='post' action='$homepa ge'>
    <input type='submit' name='' id='' value='OK' />
    </form>
    </div>
    </body>
    </html>
    ";
    }


    require_once('r ecaptchalib.php ');
    $resp = null;
    $error = null;
    $publickey = "__REMOVED_ _";
    $privatekey = "__REMOVED_ _";
    if ($_POST['recaptcha_resp onse_field']) {
    $resp = recaptcha_check _answer ($privatekey,
    $_SERVER['REMOTE_ADDR'],
    $_POST['recaptcha_chal lenge_field'],
    $_POST['recaptcha_resp onse_field']);
    if ($resp->is_valid) {

    } else {
    alert_redirect( 'Please re-enter your reCAPTCHA visual identification code.');
    exit();
    }
    }

    session_start() ;
    if(isset($_SESS ION['LastSent']))
    {
    if( $_SESSION['LastSent'] > (time() - $delay) )
    {
    alert_redirect( "You have sent a message in the last $delay seconds. Please wait $delay seconds until trying again.");
    exit();
    }
    }

    if( empty($subject) )
    {
    alert_redirect( 'Your message contained no subject.');
    exit();
    }
    elseif( empty($message) )
    {
    alert_redirect( 'Your message contained no body.');
    exit();
    }
    elseif (mail($to, $subject, $message, $headers))
    {
    $_SESSION['LastSent'] = time();
    alert_redirect( 'Message sent.');
    die();
    } else {
    alert_redirect( 'Error sending message.');
    exit();
    }[/PHP]

    Code (config.inc.php )
    [PHP]<?php

    // Edit the below variables but do NOT remove the ' , " , : or ;
    // $to - Who the script sends the emails to.
    // $homepage - The place in which the script redirects the sender after the error/success message.
    // $headers -- From: - Who the email says it is from.
    // Reply-To: - Who the email says you should reply to.
    // $delay - Amount of time (in seconds) until the sender can send another email. Prevents spamming.
    // $publickey - Your reCAPTCHA public key, required to use the visual code confirmation function
    // $privatekey - Your reCAPTCHA private key, required to use the visual code confirmation function
    // **Get a public and private reCAPTCHA key free from http://recaptcha.net/api/getkey**

    $to = '__REMOVED__';

    $homepage = '__REMOVED__';

    $headers =
    "From: noreply@atyndal l.co.nr"

    . "\r\n" .

    "Reply-To: noreply@atyndal l.co.nr";

    $delay = 180;



    ?>[/PHP]

    What is wrong with this script, what code needs to be fixed/changed/deleted?
    Last edited by ak1dnar; Sep 4 '07, 01:27 PM. Reason: Personal web site links, Not Allowed in the technical forums
  • ak1dnar
    Recognized Expert Top Contributor
    • Jan 2007
    • 1584

    #2
    If there is a specific question, that related with your script you can ask BUT we don't need the links to your web site, because this is considered as web site Advertising.

    Comment

    • atyndall
      New Member
      • Sep 2007
      • 13

      #3
      how will they see the millions of problems with the script then?

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        Hi.

        There are rarely millions of problems, especially in less than 100 lines of code ;)
        It is far more likely that you have one problem over and over again, or that one problem is creating a snowball effect and causing the others.

        Describe the problems and post any error messages. If there are millions of them then start with the first couple and we will go on from there.

        Comment

        Working...