Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'dbconfig.php';
- if(isset($_GET['newcontact']) && isset($_GET['newphone']) && isset($_GET['userid'])) {
- $query = $conn->prepare("INSERT INTO contacts (contact, phone, createdbyuserid) VALUES (:newcontact, :newphone, :userid)");
- $query->bindValue(':newcontact', $_GET['newcontact']);
- $query->bindValue(':newphone', $_GET['newphone']);
- $query->bindValue(':userid', $_GET['userid']);
- $query->execute();
- $query->closeCursor();
- if(isset($_GET['neworganization'])) {
- $query = $conn->prepare("UPDATE contacts SET organization = :organization WHERE phone = :phone");
- $query->bindValue(':organization', $_GET['neworganization']);
- $query->bindValue(':phone', $_GET['newphone']);
- $query->execute();
- $query->closeCursor();
- }
- if(isset($_GET['newrelationship'])) {
- $query = $conn->prepare("UPDATE contacts SET relationship = :relationship WHERE phone = :phone");
- $query->bindValue(':relationship', $_GET['newrelationship']);
- $query->bindValue(':phone', $_GET['newphone']);
- $query->execute();
- $query->closeCursor();
- }
- if(isset($_GET['newaddress'])) {
- $query = $conn->prepare("UPDATE contacts SET address = :address WHERE phone = :phone");
- $query->bindValue(':address', $_GET['newaddress']);
- $query->bindValue(':phone', $_GET['newphone']);
- $query->execute();
- $query->closeCursor();
- }
- if(isset($_GET['newgroup'])) {
- $query = $conn->prepare("INSERT INTO groups (createdbyuserid, groupname) VALUES (:userid, :groupname)");
- $query->bindValue(':userid', $_GET['userid']);
- $query->bindValue(':groupname', $_GET['groupname'])
- $query->execute();
- $query->closeCursor();
- $query = $conn->prepare("UPDATE contacts SET contacts.groupid = (SELECT groupid FROM groups WHERE groupname = :groupname) and phone = :phone");
- $query->bindValue(':groupname', $_GET['groupname']);
- $query->bindValue(':phone', $_GET['newphone']);
- $query->execute();
- $results = $query->fetchAll(PDO::FETCH_ASSOC);
- $query->closeCursor();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement