$phone = $_POST['phone']; $s3rawurl = $url; $filename = basename($_FILES['userfile']['name']); $s3finishedurl = $finishedurl; $status = 0; $date = '2015-11-10 12:00:00'; $stmt->bind_param("sssssii", $email, $phone, $filename, $s3rawurl, $s3finishedurl, $state, $date); if (!$stmt->execute()) { echo "Execute failed: (" . $stmt->errno . ") " . $stmt->error; } printf("%d Row inserted.\n", $stmt->affected_rows); /* explicit close recommended */ $stmt->close(); $link->real_query("SELECT * FROM arshadsTable"); $res = $link->use_result(); echo "Result set order...\n"; while ($row = $res->fetch_assoc()) { echo $row['ID'] . " " . $row['email'] . " " . $row['phone']; } $sns = new Aws\Sns\SnsClient(['version' => 'latest', 'region' => 'us-east-1']); $result = $sns->createTopic(['Name' => 'My-New-SNS-topic']); $topicArn = $result['TopicArn']; echo "Topic ARN is ::: {$topicArn}"; $result = $sns->setTopicAttributes(['AttributeName' => 'DisplayName', 'AttributeValue' => 'MP2-SNS-TOPIC', 'TopicArn' => $topicArn]); $result = $sns->subscribe(['Endpoint' => $email, 'Protocol' => 'email', 'TopicArn' => $topicArn]); sleep(30); //=======================sleep for 30 seconds so that the user can subscribe================== $result = $sns->publish(['TopicArn' => $topicArn, 'Subject' => 'Image uploaded', 'Message' => 'Congratulations! Your image has been successfully uploaded']); $link->close(); header('Location: gallery.php'); exit;
<?php session_start(); require 'vendor/autoload.php'; use Aws\Sns\SnsClient; //Create topic and subscribe to it $email = $_POST['email']; $sns = new Aws\Sns\SnsClient(array('version' => 'latest', 'region' => 'us-east-1')); $ArnArray = $sns->createTopic(['Name' => 'mp2-jgl-pict']); $Arn = $ArnArray['TopicArn']; $settopicAttributes = $sns->setTopicAttributes(array('TopicArn' => "{$Arn}", 'AttributeName' => 'DisplayName', 'AttributeValue' => 'mp2-jgl-pict')); $topicAttributes = $sns->getTopicAttributes(array('TopicArn' => "{$Arn}", 'AttributeName' => 'DisplayName', 'AttributeValue' => 'mp2-jgl-pict')); $listSubscriptions = $sns->listSubscriptionsByTopic(array('TopicArn' => $Arn)); $subscribe = $sns->subscribe(array('TopicArn' => $Arn, 'Protocol' => 'email', 'Endpoint' => $email)); ?> <html> <body style="background-color:LemonChiffon"> <center> <h1 style=> Subscription confirmed</h1> <h2> <?php echo $email; ?> </h2> <h3> <?php echo "\r\n"; echo "You will receive an email you must confirm"; ?> </h3><a href="/index.php">Index page</a></center>