Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.24 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL); ini_set('display_errors', 1);
  4. global $link;
  5. $connection= mysqli_connect("localhost", "root", "", "mydb");
  6. /* check connection */
  7. if (mysqli_connect_errno()) {
  8. printf("Connect failed: %sn", mysqli_connect_error());
  9. exit();
  10. }
  11. ?>
  12.  
  13. index.php
  14.  
  15. <?php include("connect.php");?>
  16.  
  17. <!DOCTYPE html>
  18. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  19. <?php
  20. require 'PHPMailer/PHPMailerAutoload.php';
  21. require 'PHPMailer/class.phpmailer.php';
  22. ?>
  23. <html>
  24. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  25. <head>
  26. <title>PHP insertion</title>
  27. <link rel="stylesheet" href="css/insert.css" />
  28. <link rel="stylesheet" href="css/navcss.css" />
  29. <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
  30. <link rel="stylesheet" href="/resources/demos/style.css">
  31. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
  32.  
  33. </head>
  34. <body>
  35.  
  36.  
  37.  
  38. <div class="maindiv">
  39. <?php include("includes/head.php");?>
  40. <?php include("menu.php");?>
  41. <!--HTML form -->
  42. <div class="form_div">
  43. <div class="title">
  44. <h2 style="color:blue;">تقرير الطلبات </h2>
  45. <h2 style="color:blue;">Customer Request Form </h2></div>
  46.  
  47. <form action="index.php" method="post"> <!-- method can be set POST for hiding values in URL-->
  48. <!--<h2>Custody Form</h2>-->
  49. <label>Full Name:</label><b><label>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;الاسم الكامل</b></label>
  50. <br />
  51. <input class="input" type="text" name="name" value="" />
  52. <br />
  53. <label>Employee Number:</label><b><label>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;رقم الموظف</b></label>
  54. <br />
  55. <input class="input" type="text" name="emp_number" value="" />
  56. <br />
  57. <label>Department:</label><b><label>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;القسم</b></label>
  58. <br />
  59. <input class="input" type="text" name="department" value="" />
  60. <br />
  61. <label>Email:</label></label><b><label>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;البريد الإلكتروني</b></label>
  62. <input class="input" type="text" name="email" value="" />
  63. <br />
  64. <label><b>What You Need?</b></label><b><label>&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;ماذا تحتاج</b></label><br />
  65.  
  66. <div id="option-div">
  67. <input type="checkbox" name="prints[]" value="Printer"><label>Printer</label><br/>
  68. <input type="checkbox" name="prints[]" value="Scanner"><label>Scanner</label><br/>
  69. <input type="checkbox" name="prints[]" value="Pc"><label>Pc</label><br/>
  70. <input type="checkbox" name="prints[]" value="Telephone"><label>Telephone</label><br/>
  71.  
  72. <?php
  73.  
  74. $query_eqp = mysqli_query($connection,"SELECT * FROM radiorequest");
  75. if(mysqli_num_rows($query_eqp) > 0){
  76.  
  77. while($row = mysqli_fetch_assoc($query_eqp)){
  78. //echo '<td><a href="deleteradio.php?id=' .$row['id'].'">Delete</a></td>';
  79.  
  80.  
  81. ?>
  82. <label><input type="checkbox" id="<?php echo strtolower($row['name']); ?>Check" name="prints[]" value="<?php echo $row['name']; ?>"><?php echo $row['name']; ?> </label>
  83. <?php echo '<td><a href="deleterequest.php?id=' .$row['id'].'">Delete</a></td>'; ?>
  84. <?php
  85.  
  86.  
  87. }
  88. }
  89.  
  90.  
  91. mysqli_close($connection);
  92. ?>
  93. </div> <!-- THIS IS WHERE THE NEW RADIO BUTTONS WILL BE PUT
  94.  
  95. <input type="text" id="new-option" placeholder="Insert New Option"><br />
  96. <br />
  97. <input type="button" id="create" value="Enter Any Other Equipment to Request">-->
  98. <input type="text" id="new-option" placeholder="Insert New Option">
  99. <input type="button" id="create" value="Create Your Own Choice">
  100. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  101. <br />
  102. <br /><label>Description</label><br />
  103. <textarea name="description" cols="100" rows="10"></textarea>
  104. <br />
  105. <input class="submit" type="submit" name="submit" value="Submit Request" />
  106. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  107. <?php
  108.  
  109.  
  110. if(isset($_POST['submit'])){
  111.  
  112. //Fetching variables of the form which travels in URL if Equipment listed is clicked
  113.  
  114.  
  115.  
  116. $name = $_POST['name'];
  117. $emp_number = $_POST['emp_number'];
  118. $department = $_POST['department'];
  119. $email = $_POST['email'];
  120.  
  121. $description = $_POST['description'];
  122. $checkBox = implode(',', $_POST['prints']);
  123. //$checkBox = $_POST['prints'];
  124. if(isset($_POST['prints'])) {
  125. // do something else
  126. $query = mysqli_query($connection,"INSERT INTO request (name, emp_number, department, email,need,description) values ('$name','$emp_number','$department', '$email','" . $checkBox . "','$description')");
  127. </script>";
  128. }
  129.  
  130. $mail = new PHPMailer;
  131.  
  132. $mail->isSMTP(); // Set mailer to use SMTP
  133. $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
  134. $mail->SMTPAuth = true; // Enable SMTP authentication
  135. $mail->Username = 'rana0300@gmail.com'; // SMTP username
  136. $mail->Password = 'mazhar2012'; // SMTP password
  137. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  138. $mail->Port = 587; // TCP port to connect to
  139.  
  140. $mail->setFrom('rana0300@gmail.com', 'Dibba Municipality Fujairah');
  141. $mail->addAddress('imazhar74@hotmail.com'); // Add a recipient
  142. $mail->addReplyTo('rana0300@gmail.com', 'Dibba Municipality Fujairah');
  143. $mail->addCC('cc@example.com');
  144. $mail->addBCC('bcc@example.com');
  145.  
  146. $mail->CharSet = 'UTF-8';
  147.  
  148. $mail->isHTML(true); // Set email format to HTML
  149.  
  150. if(!empty($_POST['prints'])){
  151. $str = "";
  152.  
  153. foreach($_POST['prints'] as $selected){
  154.  
  155. $str = $str . ' ' . $selected;
  156.  
  157. //$prints=$_REQUEST['prints'];
  158. //echo $mail->Body = $str."</br>";
  159. $mail->Body ='<h1>Items are Requested by Dibba Municipality Employee<br />Details of requester are under: <br /></br /> <br />
  160.  
  161. <b>Full Name (الاسم الكامل):</b>&nbsp;&nbsp;&nbsp;'.$name. '</br />
  162. <b>Employee Number (رقم الموظف):</b>&nbsp;&nbsp;&nbsp;'.$emp_number. '</br />
  163. <b>Department (القسم): </b>&nbsp;&nbsp;&nbsp;'.$department. '</br />
  164. <b>Email (البريد الإلكتروني):</b>&nbsp;&nbsp;&nbsp;'.$email. '</br />
  165.  
  166.  
  167. <b>Description (المواصفات):</b>&nbsp;&nbsp;&nbsp;'.$description. '</br />
  168. <b>Equipments Needed (المعدات اللازمة):</b>&nbsp;&nbsp;&nbsp;'.$str. '</br />';
  169. }
  170. }
  171.  
  172.  
  173.  
  174. if(!$mail->send()) {
  175. echo 'Message could not be sent.';
  176. echo 'Mailer Error: ' . $mail->ErrorInfo;
  177. } else {
  178. // echo "<script type='text/javascript'>alert('Thanks! Your Request is under process!');</script>";
  179.  
  180. echo "<script type='text/javascript'>alert('شكرا لتقديمك الطلب وسيتم المراجعة !Thanks! Your Request is under process ');</script>";
  181. }
  182. }
  183.  
  184.  
  185. //Closing Connection with Server
  186. //mysqli_close($connection);
  187. ?>
  188.  
  189. </div>
  190. </form>
  191. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement