Skip to content

Commit

Permalink
Hook up with index
Browse files Browse the repository at this point in the history
  • Loading branch information
heyqule authored and heyqule committed Nov 20, 2012
1 parent 69ebe63 commit a9c9274
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 34 deletions.
6 changes: 3 additions & 3 deletions splash2/config.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/* Email Allen to get the config if you want to access offcial DB*/
define('DB_PATH', 'sample');
Expand Down
35 changes: 7 additions & 28 deletions splash2/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@
include('config.php');
try
{
$email = $_POST['customer-email'];
$email = trim($_POST['email']);

if(!preg_match('\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b',$email))
if(!preg_match('/[A-Za-z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/',$email))
{
throw new Exception('Invalid Email');
}

if(isset($_POST['store']))
$store = $_POST['store'];
if(empty($store))
{
$store = $_POST['store'];
$store = '';
}
else
{
$store = '';
}

$sqlite_db = new PDO('sqlite:'.DB_PATH,DB_USER,DB_PASS);

Expand All @@ -37,7 +34,7 @@
)
);

echo "DONE";
echo "done";



Expand All @@ -46,22 +43,4 @@
catch(Exception $e)
{
echo 'Error: '.$e->getMessage();
}
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<title>Milk Table</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<form action="" method="post">
EMail:<input type="text" name="customer-email" />
Name:<input type="text" name="store" />
<input type="submit" value="submit" />
</form>
</body>
</html>



}
4 changes: 3 additions & 1 deletion splash2/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
PDO::ERRMODE_EXCEPTION);

echo 'Creating Tables... <br />';
$sqlite_db->exec("Drop table emails");
$sqlite_db->exec("CREATE TABLE IF NOT EXISTS emails (
id INTEGER PRIMARY KEY,
customer_email TEXT,
store_name TEXT,
time INTEGER)");
time INTEGER,
UNIQUE(customer_email) ON CONFLICT REPLACE)");

echo 'Done... <br />';
24 changes: 22 additions & 2 deletions splash2/js/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,31 @@ $(document).ready(function(){
});
});

// Thank you
// Submit and Thank you
$("button").click(function() {
var jThis = $(this);
var attrName = jThis.attr('value').split('-')[0];

var email = $('input[name='+attrName+'-email]').val();
var store = $('input[name=store]').val();

$("#thank-you").fadeIn(200);
if(store == null) store = '';

$.post('email.php',{"email":email,"store":store},
function(data) {
if(data == 'done')
{
alert($("#thank-you").html());
}
else
{
alert("We have encounter an error. Give us a minute");
}
});

});



}); /* End doc.ready */

Expand Down

0 comments on commit a9c9274

Please sign in to comment.