Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL); ini_set('display_errors', 1);
- global $link;
- $connection= mysqli_connect("localhost", "root", "", "mydb");
- /* check connection */
- if (mysqli_connect_errno()) {
- printf("Connect failed: %sn", mysqli_connect_error());
- exit();
- }
- ?>
- index.php
- <?php include("connect.php");?>
- <!DOCTYPE html>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <?php
- require 'PHPMailer/PHPMailerAutoload.php';
- require 'PHPMailer/class.phpmailer.php';
- ?>
- <html>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <head>
- <title>PHP insertion</title>
- <link rel="stylesheet" href="css/insert.css" />
- <link rel="stylesheet" href="css/navcss.css" />
- <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
- <link rel="stylesheet" href="/resources/demos/style.css">
- <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
- </head>
- <body>
- <div class="maindiv">
- <?php include("includes/head.php");?>
- <?php include("menu.php");?>
- <!--HTML form -->
- <div class="form_div">
- <div class="title">
- <h2 style="color:blue;">تقرير الطلبات </h2>
- <h2 style="color:blue;">Customer Request Form </h2></div>
- <form action="index.php" method="post"> <!-- method can be set POST for hiding values in URL-->
- <!--<h2>Custody Form</h2>-->
- <label>Full Name:</label><b><label>                   الاسم الكامل</b></label>
- <br />
- <input class="input" type="text" name="name" value="" />
- <br />
- <label>Employee Number:</label><b><label>               رقم الموظف</b></label>
- <br />
- <input class="input" type="text" name="emp_number" value="" />
- <br />
- <label>Department:</label><b><label>                    القسم</b></label>
- <br />
- <input class="input" type="text" name="department" value="" />
- <br />
- <label>Email:</label></label><b><label>                    البريد الإلكتروني</b></label>
- <input class="input" type="text" name="email" value="" />
- <br />
- <label><b>What You Need?</b></label><b><label>                 ماذا تحتاج</b></label><br />
- <div id="option-div">
- <input type="checkbox" name="prints[]" value="Printer"><label>Printer</label><br/>
- <input type="checkbox" name="prints[]" value="Scanner"><label>Scanner</label><br/>
- <input type="checkbox" name="prints[]" value="Pc"><label>Pc</label><br/>
- <input type="checkbox" name="prints[]" value="Telephone"><label>Telephone</label><br/>
- <?php
- $query_eqp = mysqli_query($connection,"SELECT * FROM radiorequest");
- if(mysqli_num_rows($query_eqp) > 0){
- while($row = mysqli_fetch_assoc($query_eqp)){
- //echo '<td><a href="deleteradio.php?id=' .$row['id'].'">Delete</a></td>';
- ?>
- <label><input type="checkbox" id="<?php echo strtolower($row['name']); ?>Check" name="prints[]" value="<?php echo $row['name']; ?>"><?php echo $row['name']; ?> </label>
- <?php echo '<td><a href="deleterequest.php?id=' .$row['id'].'">Delete</a></td>'; ?>
- <?php
- }
- }
- mysqli_close($connection);
- ?>
- </div> <!-- THIS IS WHERE THE NEW RADIO BUTTONS WILL BE PUT
- <input type="text" id="new-option" placeholder="Insert New Option"><br />
- <br />
- <input type="button" id="create" value="Enter Any Other Equipment to Request">-->
- <input type="text" id="new-option" placeholder="Insert New Option">
- <input type="button" id="create" value="Create Your Own Choice">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <br />
- <br /><label>Description</label><br />
- <textarea name="description" cols="100" rows="10"></textarea>
- <br />
- <input class="submit" type="submit" name="submit" value="Submit Request" />
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <?php
- if(isset($_POST['submit'])){
- //Fetching variables of the form which travels in URL if Equipment listed is clicked
- $name = $_POST['name'];
- $emp_number = $_POST['emp_number'];
- $department = $_POST['department'];
- $email = $_POST['email'];
- $description = $_POST['description'];
- $checkBox = implode(',', $_POST['prints']);
- //$checkBox = $_POST['prints'];
- if(isset($_POST['prints'])) {
- // do something else
- $query = mysqli_query($connection,"INSERT INTO request (name, emp_number, department, email,need,description) values ('$name','$emp_number','$department', '$email','" . $checkBox . "','$description')");
- </script>";
- }
- $mail = new PHPMailer;
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'smtp.gmail.com'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'rana0300@gmail.com'; // SMTP username
- $mail->Password = 'mazhar2012'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 587; // TCP port to connect to
- $mail->setFrom('rana0300@gmail.com', 'Dibba Municipality Fujairah');
- $mail->addAddress('imazhar74@hotmail.com'); // Add a recipient
- $mail->addReplyTo('rana0300@gmail.com', 'Dibba Municipality Fujairah');
- $mail->addCC('cc@example.com');
- $mail->addBCC('bcc@example.com');
- $mail->CharSet = 'UTF-8';
- $mail->isHTML(true); // Set email format to HTML
- if(!empty($_POST['prints'])){
- $str = "";
- foreach($_POST['prints'] as $selected){
- $str = $str . ' ' . $selected;
- //$prints=$_REQUEST['prints'];
- //echo $mail->Body = $str."</br>";
- $mail->Body ='<h1>Items are Requested by Dibba Municipality Employee<br />Details of requester are under: <br /></br /> <br />
- <b>Full Name (الاسم الكامل):</b> '.$name. '</br />
- <b>Employee Number (رقم الموظف):</b> '.$emp_number. '</br />
- <b>Department (القسم): </b> '.$department. '</br />
- <b>Email (البريد الإلكتروني):</b> '.$email. '</br />
- <b>Description (المواصفات):</b> '.$description. '</br />
- <b>Equipments Needed (المعدات اللازمة):</b> '.$str. '</br />';
- }
- }
- if(!$mail->send()) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- } else {
- // echo "<script type='text/javascript'>alert('Thanks! Your Request is under process!');</script>";
- echo "<script type='text/javascript'>alert('شكرا لتقديمك الطلب وسيتم المراجعة !Thanks! Your Request is under process ');</script>";
- }
- }
- //Closing Connection with Server
- //mysqli_close($connection);
- ?>
- </div>
- </form>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement