vishwamano

source of vishwamano.com
git clone git://git.ricketyspace.net/vishwamano.git
Log | Files | Refs

commit b158545b608cb137b3da8062fbad6b2fd4695542
parent 7c64d26e12d2717d21182e906bd0e97e61f1530e
Author: rsiddharth <rsiddharth@ninthfloor.org>
Date:   Wed, 31 Dec 2014 01:02:09 -0500

utils.php: added send_mail() and register functions.

Diffstat:
utils.php | 59+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+), 0 deletions(-)

diff --git a/utils.php b/utils.php @@ -35,3 +35,61 @@ function get_images($directory) { return $images; } +function send_email($to, $subject, $body) { + #headers + $headers = "From: no-reply@vishwamano.com\n"; + $headers .= "Reply-To: $to"; + mail($to, $subject, $body, $headers); +} + +function register($email) { + $to = $email; + $name = $_POST['name']; + $email_address = $_POST['email']; + $phone = $_POST['phone']; + $blurb = $_POST['blurb']; + $humantest = $_POST['humantest']; + $submit = $_POST['submit']; + + $humantest_answer= "101"; + + if((strcmp($humantest, $humantest_answer) == 0) and + (!empty($name) and !empty($email_address))) { + + if(strcmp($submit, "1") == 0) { + $course = "Level 1 - Basic"; + }else { + $course = "Level 2 - Advanced"; + } + $course .= " Photography Course."; + + $email_subject = "[VishaMano.com] A&S ". $course. " Registration from $name"; + + $email_body = "$name <$email_address> has registered for the A&S ". $course. "\n\n". + "About $name:\n\n $blurb"; + + if(!empty($phone)) { + $email_body .= "\n\n $name can be buzzed at $phone"; + } + + $headers = "From: no-reply@vishwamano.com\n"; + $headers .= "Reply-To: $email_address"; + + mail($to,$email_subject,$email_body,$headers); + + $alert_msg = 'You have registered for <strong>' + . $course . '</strong> Vishwa Manoharan get back to you seen.'; + $alert = array( 'type' => 'success', + 'content' => $alert_msg); + + } + else { + + $alert_msg = '<strong> Registration error</strong>. Please try again.' + . ' If problem persists email Vishwa Manoharan' + . ' &lt;vishwa91photography@gmail.com&gt;.'; + $alert = array( 'type' => 'danger', + 'content' => $alert_msg); + } + return $alert; +}+ \ No newline at end of file