function Decider($dname, $dmail) { $name = $dname; $mail = strtolower($dmail); //connect to the database $con = mysqli_connect("eu-cdbr-azure-west-a.cloudapp.net", "b8592f1b44ff9a", "fecb2128", "TeamProject"); $name = mysqli_real_escape_string($con, $name); if (mysqli_connect_errno()) { return "f"; } $query = "SELECT Email FROM Subscriber WHERE Email='" . $mail . "'"; $result = mysqli_query($con, $query); if (mysqli_num_rows($result) > 0) { $result = Unsub($mail); } else { if (empty($mail)) { $result = Unsub($name); } else { $result = Subscribe($name, $mail); } } // Free result set mysqli_free_result($result); mysqli_close($con); return $result; }
foreach ($_POST as $key => $value) { $_SESSION[$key] = $value; } $page = 4; } } } ?> <?php /**************************************************/ /* Part II - Write Subscription Info to mySql */ /**************************************************/ if ($page == 4) { Subscribe(); session_destroy(); } /**************************************************/ /* Part III - Display the Appropriate Section */ /**************************************************/ ?> <?php if ($page == 1) { ?> <SCRIPT TYPE="text/javascript"> <!-- function process() {
function Subscribe($id, $email) { $params = array('YMP0' => $email); $url = 'http://ymlp.com/subscribe.php?id=' . $id; $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); echo curl_exec($ch); curl_close($ch); } $request_method = isset($_SERVER['REQUEST_METHOD']) ? strtolower($_SERVER['REQUEST_METHOD']) : ''; if ('post' === $request_method) { if (isset($_REQUEST['lang']) && isset($_REQUEST['email'])) { switch ($_REQUEST['lang']) { case 'en': $id = Subscribe('ghswmqmgmgw', $_REQUEST['email']); break; case 'ru': $id = Subscribe('ghswmqmgmgq', $_REQUEST['email']); break; default: header('HTTP/1.1 400 Bad Request'); } } else { header('HTTP/1.1 400 Bad Request'); } } else { header('HTTP/1.1 405 Method Not Allowed'); }