Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $id = $_POST["id"];
- $connection = curl_init();
- curl_setopt($connection, CURLOPT_URL, "http://southamptonstudentrooms.com/Wad/downloadwebservice3.php");
- $dataToPost = array ("id" => $id);
- curl_setopt($connection,CURLOPT_RETURNTRANSFER,1);
- curl_setopt($connection,CURLOPT_POSTFIELDS,$dataToPost);
- $response = curl_exec($connection);
- // display any errors
- if(curl_errno($connection)){
- echo 'Curl error: ' . curl_error($ch);
- }
- curl_close($connection);
- if ($response == "OK") {
- echo "updated";
- }
- else if ($response == ' ERROR') {
- echo "updated failed";
- }
- else {
- echo "error";
- }
- echo "<br><br>test responce =" . $response;
- ?>
- <?php
- $servername = "localhost";
- $username = ".........";
- $password = ".........";
- $dbname = "..........";
- $ID = $_POST["id"];
- // 11: Chris Palmer, username ChrisPalmer, Password tree987, Balance 2.00
- // Create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- // Check connection
- if (!$conn) {
- die("Connection failed: " . mysqli_connect_error());
- }
- $sql = "SELECT * FROM ht_users WHERE username='ChrisPalmer'";
- $result = mysqli_query($conn, $sql);
- if (mysqli_num_rows($result) > 0) {
- // output data of each row
- while($row = mysqli_fetch_assoc($result)) {
- if($row["balance"] >= 0.79)
- {
- echo "OK";
- mysqli_close($conn);
- try {
- //WAI
- $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
- // set the PDO error mode to exception
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- $sql = "UPDATE wadsongs SET downloads=downloads + 1 WHERE songid='$ID'";
- // Prepare statement
- $stmt = $conn->prepare($sql);
- // execute the query
- $stmt->execute();
- // echo a message to say the UPDATE succeeded
- // echo $stmt->rowCount() . " records UPDATED successfully";
- }
- catch(PDOException $e)
- {
- echo $sql . "<br>" . $e->getMessage();
- }
- $conn = null;
- }
- else{
- ECHO "ERROR";
- }
- }
- }
- else {
- echo "0 results";
- mysqli_close($conn);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement