How can I make a PHP script send me results?

I made a PHP script quiz on a website. Simple true or false quiz. After the user submits the quiz, it shows their results. How do I make it so that it emails or sends the results directly to me?


Comments

3 Responses to “How can I make a PHP script send me results?”

  1. dhaneshmane on June 27th, 2010 2:16 pm

    hey dude,

    you can easily write a php email function which will email you the result.

    <?php
    $to = "someone@example.com";
    $subject = "Test mail";
    $message = "Hello! This is a simple email message.";
    $from = "someonelse@example.com";
    $headers = "From: $from";
    mail($to,$subject,$message,$headers);
    echo "Mail Sent.";
    ?>

  2. Aaron on June 27th, 2010 2:16 pm

    I would be glad to help but I need to see what your code is doing now to show the user their results.
    Share what you’ve got and we can go from there by using the PHP mail command.

    http://www.w3schools.com/PHP/php_mail.asp

    HTH,
    aaron

  3. DzSoundNirvana on June 27th, 2010 2:16 pm

    <?

    /***********************
    CLASS :: MYMail
    ************************/
    class MyMail{
    var $To;
    var $ToSender;//If you want the email to go to the sender
    var $Subject;
    var $Msg;
    var $Headers;
    var $From;
    var $ReplyTo;
    /*
    $headers = ‘From: webmaster@example.com‘ . "\r\n" .
    ‘Reply-To: webmaster@example.com‘ . "\r\n" .
    ‘X-Mailer: PHP/’ . phpversion();
    mail($to, $subject, $message, $headers);
    ***&&&&&*******
    For HTML Mail
    ‘MIME-Version: 1.0′ . "\r\n";
    $headers .= ‘Content-type: text/html; charset=iso-8859-1′ . "\r\n";
    */
    function MyMail($To, $Subject, $Msg, $From, $ReplyTo){
    $this->To=(empty($To)) ? "0" : $To;
    $this->Subject=(empty($Subject)) ? "0" : $Subject;
    $this->Msg=(empty($Msg)) ? "0" : $Msg;
    $this->From=(empty($From)) ? "0" : $From;
    $this->ReplyTo=(empty($ReplyTo)) ? "0" : $ReplyTo;
    $this->Headers="MIME-Version: 1.0" . "\r\n" . "Content-type: text/html; charset=iso-8859-1" . "\r\n" . "From:" . $this->From . "\r\n" . "Reply-To:" . $this->ReplyTo . "\r\n" . "X-Mailer: PHP/" . phpversion();

    //Use this array if you want to send to only one person
    $SetMail=array(
    ‘To’=> $this->To,
    ‘Subject’=> $this->Subject,
    ‘Msg’=> $this->Msg,
    ‘Headers’=> $this->Headers,
    ‘From’=> $this->From,
    ‘ReplyTo’=> $this->ReplyTo
    );
    //Use this array if you want it to go to multiple people (the sender/CC:/Bcc:)
    /*
    $SetMail=array(
    ‘To’=> $this->To . "," . $ToSender,
    ‘Subject’=> $this->Subject,
    ‘Msg’=> $this->Msg,
    ‘Headers’=> $this->Headers,
    ‘From’=> $this->From,
    ‘ReplyTo’=> $this->ReplyTo
    );
    */
    if(in_array("0",$SetMail)){
    echo "<div align=\"left\"><font color=\"#640000\">Something wrong with the mail! Please make sure all fields are filled in!</font></div>";
    return;
    }
    else{
    if(!mail($SetMail['To'], $SetMail['Subject'], $SetMail['Msg'], $SetMail['Headers'])){
    echo "<script type=\"text/javascript\">window.location=\"error.php?app=Error&action=Echo&ErrorType=$this->Errors&Remarks=There is a problem with the Mail!\"</script>";
    }
    }
    }
    }
    ?>

    and call the class like this

    Code:
    $MyMail=new MyMail($To="Email address", $Subject="Subject", $Msg=Message or body, $From="From email address", $ReplyTo="reply to email address.or use from email address");

    and set the $Msg to what ever the array (results) are

Powered by Yahoo! Answers