Permalink
Browse files

Moved configurations into a single file

  • Loading branch information...
1 parent 1aa313e commit 982cb79632e91d54319f8baffad304c2c38f9d9a @itswadesh committed Mar 29, 2016
Showing with 55 additions and 19 deletions.
  1. +0 −1 .gitignore
  2. +21 −1 README.md
  3. BIN books.pdf
  4. +22 −0 config.php
  5. +1 −1 database.php
  6. +4 −3 index.php
  7. +7 −13 sendgrid.php
View
@@ -1 +0,0 @@
-config.php
View
@@ -7,7 +7,27 @@ This will create necessary tables and insert sample data into it.
##Change the settings
The following settings need to be changed at **config.php**
<pre>
-
+ define('DATABASE_HOST', "localhost");
+ define('DATABASE_NAME', "demo");
+ define('DATABASE_USERNAME', "root");
+ define('DATABASE_PASSWORD', "root");
+
+ define('ATTACHED_FILENAME', "books.pdf");
+
+ define('SENDGRID_USERNAME', "YOUR_SENDGRID_USERNAME");
+ define('SENDGRID_PASSWORD', "YOUR_SENDGRID_PASSWORD");
+
+ define('FROM', "<AngularCode> demo@angularcode.com");
+ define('TO', "support@codenx.com");
+ define('SUBJECT', "ShopNx - The Single Page eCommerce Website");
+ define('CONTENT', "
+ <h1>Experience faster shopping with ShopNx</h1>
+ <ul>
+ <li>Responsive Design</li>
+ <li>Higher Scalability</li>
+ <li>Ergonomically Designed</li>
+ </ul>");
+
</pre>
##Run the program
View
Binary file not shown.
View
@@ -0,0 +1,22 @@
+<?php
+ define('DATABASE_HOST', "localhost");
+ define('DATABASE_NAME', "demo");
+ define('DATABASE_USERNAME', "root");
+ define('DATABASE_PASSWORD', "root");
+
+ define('ATTACHED_FILENAME', "books.pdf");
+
+ define('SENDGRID_USERNAME', "YOUR_SENDGRID_USERNAME");
+ define('SENDGRID_PASSWORD', "YOUR_SENDGRID_PASSWORD");
+
+ define('FROM', "<AngularCode> demo@angularcode.com");
+ define('TO', "support@codenx.com");
+ define('SUBJECT', "ShopNx - The Single Page eCommerce Website");
+ define('CONTENT', "
+ <h1>Experience faster shopping with ShopNx</h1>
+ <ul>
+ <li>Responsive Design</li>
+ <li>Higher Scalability</li>
+ <li>Ergonomically Designed</li>
+ </ul>");
+?>
View
@@ -2,7 +2,7 @@
include('config.php');
class Database {
function runQuery($sql) {
- $conn = new mysqli($DATABASE_HOST,$DATABASE_USERNAME,$DATABASE_PASSWORD,$DATABASE_NAME);
+ $conn = new mysqli(DATABASE_HOST,DATABASE_USERNAME,DATABASE_PASSWORD,DATABASE_NAME);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
View
@@ -1,12 +1,11 @@
<?php
include('config.php');
include('database.php');
-include('sendgrid.php');
$database = new Database();
$result = $database->runQuery("SELECT name,author FROM books");
$header = $database->runQuery("SELECT UCASE(`COLUMN_NAME`)
FROM `INFORMATION_SCHEMA`.`COLUMNS`
-WHERE `TABLE_SCHEMA`='crud'
+WHERE `TABLE_SCHEMA`='demo'
AND `TABLE_NAME`='books'
and `COLUMN_NAME` in ('name','author')");
@@ -24,5 +23,7 @@
foreach($row as $column)
$pdf->Cell(95,12,$column,1);
}
-$pdf->Output($ATTACHED_FILENAME,'F');
+$pdf->Output(ATTACHED_FILENAME,'F');
+require('sendgrid.php');
+sendmail();
?>
View
@@ -5,19 +5,13 @@ function sendmail(){
$filePath = dirname(__FILE__);
$params = array(
- 'api_user' => $SENDGRID_USERNAME,
- 'api_key' => $SENDGRID_PASSWORD,
- 'to' => 'support@codenx.com',
- 'subject' => 'ShopNx - The Single Page eCommerce Website',
- 'html' => '
- <ul>
- <li>Responsive Design</li>
- <li>Higher Scalability</li>
- <li>Ergonomically Designed</li>
- </ul>',
- 'text' => 'Experience faster shopping',
- 'from' => 'demo@codenx.com',
- 'files['.$FILE_NAME.']' => '@'.$filePath.'/'.$FILE_NAME
+ 'api_user' => SENDGRID_USERNAME,
+ 'api_key' => SENDGRID_PASSWORD,
+ 'from' => FROM,
+ 'to' => TO,
+ 'subject' => SUBJECT,
+ 'html' => CONTENT,
+ 'files['.ATTACHED_FILENAME.']' => '@'.$filePath.'/'.ATTACHED_FILENAME
);
print_r($params.message);

0 comments on commit 982cb79

Please sign in to comment.