Jump to content

Need help getting my mail function to work


mikeoffy69

Recommended Posts

I am having an issue with a support ticket program. I have added a feature to this program that allows my staff members to add multiple users to a ticket. The problem I am having because I am new to PHP is how do I email the users when they have been added to the ticket. Below is the code I am using for add user. If someone could look at it and help me figure out how to get this to email the user when they are added to the support ticket that would be great.  I have been struggling with this for alot of nights and just cant figure it out.

 

<?php

require "../conf/conn.php";
require "../conf/conf.php";
require "session.php";
?>

<html>
<head>
<title><?php echo "$c_title - Add User"; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<STYLE type="text/css">
<?php include('../style.php'); ?>
</STYLE>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function dele(assigned_user,username,ticket_id,id) {
    var assigned = document.getElementById('assigned_user').value;
    if(assigned_user==assigned) {
        alert("You Can't Delete the user '"+username+"'\nUsername assigned for the ticket '"+ticket_id+"'");
    } else {
        if(confirm('Are you sure to delete?'))     
            window.location.href = "adduser.php?action=delete&user_id="+assigned_user+"&ticket_id="+ticket_id+"&ticid="+id;
    }
}
//  End -->
</script>
</head>
<body>
    <?php
        $ticket_id = $_GET['ticket_id'];
        
        if(isset($_GET['action'])) {
            if($_GET['action']=='delete'){
                if(isset($_GET['ticid'])) {
                    $tid = $_GET['ticid'];
                    $query_user ="DELETE FROM support_users WHERE id='$tid'";
                    $result=mysql_query($query_user);
                    echo $_SESSION['successMsg'] = "<b>User Deleted From the ticket '$ticket_id'</b>";
                }
            }
        }

        if(!empty($_POST)) {
            $date = date('Y-m-d H:i:s');
            $puid = $_POST['username'];
            if($puid!='') {    
                mysql_query("INSERT INTO support_users (id,user_id,ticket_id,assign_date) VALUES ('','$puid','$ticket_id','$date')") or die("<B>Error ".mysql_errno()." :</B> ".mysql_error()."");
                $_SESSION['successMsg'] = "User Added !";
            }
        }

        $query_user ="SELECT SU.id,SU.user_id,SU.ticket_id,SU.assign_date,U.user,U.name,U.email FROM support_users AS SU LEFT JOIN users AS U ON SU.user_id=U.id WHERE ticket_id='$ticket_id';";
        $result1=mysql_query($query_user);
        $user_arr = array();
        while($userrow1 = mysql_fetch_array($result1)) {  
            $user_arr[] = $userrow1['user_id'];
        }
        $result=mysql_query($query_user);


        $query_user ="SELECT * FROM support WHERE Ticket='$ticket_id';";
        $support_result=mysql_query($query_user);
        $support = mysql_fetch_array($support_result);
/*
        $query_user ="SELECT * FROM users WHERE Ticket='$ticket_id';";
        $support_result=mysql_query($query_user);
        $support = mysql_fetch_array($support_result);*/

        

        if(isset($_SESSION['successMsg'])) {
            if($_SESSION['successMsg']=="") {
                echo $_SESSION['successMsg'];
                $_SESSION['successMsg'] = "";
            }
        }
        
    ?>
    
<form method="post" action="">
    <table width="400" border="0" align="center" cellspacing="1">
     <tr>
        <td colspan="4" class="submenu"> 
           Ticket ID <?=$ticket_id?>
        </td>
    </tr>
     <tr align="center"> 
        <td colspan="4" class="submenu"> 
           Add Users
        </td>
    </tr>
    
    <tr align="center"> 
        <td class=""> 
           Select User
        </td>
        <td>
                         <select name="username">
                          <option value="">[--Select User--]</option>
                          <?php
                          $query_user1 ="SELECT * FROM users WHERE level = '3' AND active <> '0' AND validated ='1' order by name";
                          $result1=mysql_query($query_user1);
                          while($userrow1 = mysql_fetch_array($result1)) {  
                              if(!in_array($userrow1["id"],$user_arr)) {    
                                $tempuser=$userrow1["user"]; ?>
                            <option value="<?php echo $userrow1["id"];?>"<?php if($row_user[user]==$tempuser){echo " selected ";}?>><?php echo "$userrow1[user] ($userrow1[name] )"; ?></option>
                          <?php } 
                            } ?>
                          </select>
                    <input type='submit' value='Add'>
        </td>
       </tr>
     </table>
</form>

    <table width="400" border="0" cellspacing="0" cellpadding="0" align="center" class="border">
    <tr> 
    <td> 
    <table width="400" border="0" align="center" cellspacing="1">
      <tr align="center"> 
        <td colspan="4" class="submenu"> 
           Assigned Users
           <input type='hidden' id='assigned_user' name='assigned_user' value="<?=$support['user_id']?>">
        </td>
       </tr>
      <tr>
        <td class="descrip">User</td>
        <td class="descrip">Name</td>
        <td class="descrip">Email</td>
        <td class="descrip">Actions</td>
      </tr>
    <?php
    while($row = mysql_fetch_array($result)) {
    ?>
       <tr>
         <td class="dat"><a href="#" onClick="sendValue(<?php echo "'".$row[user]."'"; ?>);"><?php echo $row[user]; ?></a><?php if ($row["active"] == 2) echo "<font size=1 color=#FF0000> (Suspended)</font>"; ?></td>
         <td class="dat"><?php echo $row["name"]; ?></td>
         <td class="dat"><?php echo $row["email"]; ?></td>
         <td class="dat"><img src="../images/delete3.gif" /> <a href="javascript:dele('<?=$row["user_id"]?>','<?=$row["user"]?>','<?=$row["ticket_id"]?>','<?=$row["id"]?>');">Delete </a></td>
       </tr>
    <?php
    }
    ?>
      <tr align="center"> 
        <td colspan="4" class="submenu"> 
           <?php if ($numpage>1) {
                    pagenav();
                } else {
                    echo " ";
                } ?>
        </td>
       </tr>
    </table>
    </td>
    </tr>
    </table>
    <br><table align="center"><tr><td><a href="javascript:window.close();">Close Window</a></td></tr></table>
</body>
</html>

 

 

Thanks in advance for any help...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.