Jump to content

Gcobani

New Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by Gcobani

  1. Hi Team I have tried to create send email using php mail function and attach one file, but the issue i am facing now pdf document is only shown on html content not displaying it as a pdf and need some around my logic below. <?php $filenameee = $_FILES['id']['name']; $message = "Name: ". $fname . $lname . "\r\n Email: " . $email . "\r\n Cell Number: " . $number . "\r\n Monthly Income: " . $income . "\r\n Loan Amount: " . $amount . "\r\n Town:" . $town . "\r\n id :.$filenameee."; $subject ="Application Form"; $fromname ="ACI FINANCE"; $fromemail = $email; //if u dont have an email create one on your cpanel $mailto = 'gcobani.mkontwana@agilelimitless.org.za'; //the email which u want to recv this email // Define the message body $body = '--'.$separator.$eol; $body .= 'Content-Type: text/plain; charset="iso-8859-1"'.$eol; $body .= 'Content-Transfer-Encoding: 8bit'.$eol.$eol; $body .= $message.$eol; // Define the first attachment $filenameee = 'public_html/PHPMailer/path/to/attachment1/id.pdf'; $file_size = filesize($filenameee); $file_name = basename($filenameee); $handle = @fopen($filenameee, 'rb'); $content = @fread($handle, $file_size); @fclose($handle); $attachment = chunk_split(base64_encode($content)); $body .= '--'.$separator.$eol; $body .= 'Content-Type: application/pdf; name="'.$file_name.'"'.$eol; $body .= 'Content-Transfer-Encoding: base64'.$eol; $body .= 'Content-Disposition: attachment; filename="'.$file_name.'"'.$eol.$eol; $body .= $attachment.$eol; $body .= '--'.$separator.'--'.$eol; ?>
  2. @mac_gyver what should i use in shoring i achieve this....? I have been stuck with this problem for almost a week now.
  3. Hi Team I need some help with my logic, i am trying to send email attachment i managed to create one attachment. But the problem is the document i cant able to view it says "failed to load pdf document, expected application/pdf.pf , found plain text". Logic to achieve this using php mail function. <?php $filenameee = $_FILES['id']['name']; //$fileName = $_FILES['id']['temp_name']; $amount =$_REQUEST['amount']; $purpose =$_REQUEST['purpose']; $voucher =$_REQUEST['voucher']; $gender =$_REQUEST['gender']; $fname =$_REQUEST['fname']; $lname =$_REQUEST['lname']; $title =$_REQUEST['title']; $typeID =$_REQUEST['typeID']; $email =$_REQUEST['email']; $number =$_REQUEST['number']; $maritalstatus =$_REQUEST['maritalstatus']; $street1 =$_REQUEST['street1']; $street2 =$_REQUEST['street2']; $town =$_REQUEST['town']; $province =$_REQUEST['province']; $code =$_REQUEST['code']; $propertyownership =$_REQUEST['propertyownership']; $placeofwork =$_REQUEST['placeofwork']; $jobtitle =$_REQUEST['jobtitle']; $jobstreet=$_REQUEST['jobstreet']; $jobstreet2 =$_REQUEST['jobstreet2']; $jobtown =$_REQUEST['jobtown']; $worknumber =$_REQUEST['worknumber']; $jobprovince =$_REQUEST['jobprovince']; $jobcode =$_REQUEST['jobcode']; $income =$_REQUEST['income']; $bankname=$_REQUEST['bankname']; $branchname =$_REQUEST['branchname']; $accountno =$_REQUEST['accountno']; $accounttype =$_REQUEST['accounttype']; $signature =$_REQUEST['signature']; $bankstatement =$_REQUEST['bankstatement']; $payslip=$_REQUEST['payslip']; $message = "Name: ". $fname . $lname . "\r\n Email: " . $email . "\r\n Cell Number: " . $number . "\r\n Monthly Income: " . $income . "\r\n Loan Amount: " . $amount . "\r\n Town:" . $town; $subject ="Application Form"; $fromname ="ACI FINANCE"; $fromemail = $email; //if u dont have an email create one on your cpanel $mailto = 'gcobani.Mkontwana@agilelimitless.org.za'; //the email which u want to recv this email $content = file_get_contents($filenameee); $content = chunk_split(base64_encode($content)); // a random hash will be necessary to send mixed content $separator = md5(time()); // carriage return type (RFC) $eol = "\r\n"; // main header (multipart mandatory) $headers = "From: ".$fromname." <".$fromemail.">" . $eol; $headers .= "MIME-Version: 1.0" . $eol; $headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol; $headers .= "Content-Transfer-Encoding: binary"; $headers .= "This is a MIME encoded message." ; $headers .="Content-Length: . filesize($filenameee)"; $headers .="Accept-Ranges: bytes" ; @readfile($filenameee); $logo = 'img/logo.png'; $link = '#'; $body = "<!DOCTYPE html><html lang='en'><head><meta charset='UTF-8'><title>Express Mail</title></head><body>"; $body .= "<table style='width: 100%;'>"; $body .= "<thead style='text-align: center;'><tr><td style='border:none;' colspan='2'>"; $body .= "<a href='{$link}'><img src='{$logo}' alt=''></a><br><br>"; $body .= "</td></tr></thead><tbody><tr>"; $body .= "<td style='border:none;'><strong>Name:</strong> {$fname} {$lname}</td>"; $body .= "<td style='border:none;'><strong>Email:</strong> {$from}</td>"; $body .= "</tr>"; $body .= "<tr><td style='border:none;'><strong>CellNumber:</strong> {$number}</td></tr>"; $body .= "<tr><td></td></tr>"; $body .= "<tr><td style='border:none;'><strong>Loan Amount:</strong> {$amount}</td></tr>"; $body .= "<tr><td></td></tr>"; $body .= "<tr><td style='border:none;'><strong>Monthly income:</strong> {$income}</td></tr>"; $body .= "<tr><td></td></tr>"; $body .= "<tr><td style='border:none;'><strong>Town:</strong> {$town}</td></tr>"; $body .= "<tr><td></td></tr>"; $body .= "<tr><td style='border:none;'><strong>Upload bankstatement </strong> {$bankstatement}</td></tr>"; $body .= "<tr><td></td></tr>"; $body .= "<tr><td style='border:none;'><strong>Upload payslip:</strong> {$payslip}</td></tr>"; $body .= "<tr><td></td></tr>"; $body .= "<tr><td colspan='2' style='border:none;'><strong></strong> </td></tr>"; // message //$body = "--" . $separator . $eol; $body .= "Content-Type: text/plain; charset=\"iso-8859-1\"" . $eol; $body .= "Content-Transfer-Encoding: binary" . $eol; $body .= $message . $eol; // attachment $body .= "--" . $separator . $eol; $body .= "Content-Type: application/pdf; name=\"" . $filenameee . "\"" . $eol; $body .= "Content-Transfer-Encoding: binary" . $eol; $body .= 'Content-Disposition: inline; $filenameee="' . $filenameee . '"'; $body .= $content . $eol; $body .= "</tbody></table>"; $body .= "</body></html>
  4. Hi Team I need some help with the following back end logic, i have code that register new users to the database. Currently its not registering new users instead it goes to my if else statement when password is not matching. // back end code <?php $showAlert = false; $showError = false; $exists=false; if($_SERVER["REQUEST_METHOD"] == "POST") { // Include file which makes the // Database Connection. include 'db_config.php'; $username = $_POST["username"]; $password = $_POST["password"]; $cpassword = $_POST["cpassword"]; $sql = "Select * from signup where username='$username'"; $result = mysqli_query($conn, $sql); $num = mysqli_num_rows($result); // This sql query is use to check if // the username is already present // or not in our Database if($num == 0) { if(($password == $cpassword) && $exists==false) { $hash = password_hash($password, PASSWORD_DEFAULT); // Password Hashing is used here. $sql = "INSERT INTO `signup` ( `username`, `password`, `date`) VALUES ('$username', '$hash', current_timestamp())"; $result = mysqli_query($conn, $sql); if ($result) { $showAlert = true; } } else { $showError = "Passwords do not match"; } }// end if if($num>0) { $exists="Username not available"; } }//end if ?> <?php if($showAlert) { echo ' <div class="alert alert-success alert-dismissible fade show" role="alert"> <strong>Success!</strong> Your account is now created and you can login. <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> '; } if($showError) { echo ' <div class="alert alert-danger alert-dismissible fade show" role="alert"> <strong>Error!</strong> '. $showError.' <button type="button" class="close" data-dismiss="alert aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> '; } if($exists) { echo ' <div class="alert alert-danger alert-dismissible fade show" role="alert"> <strong>Error!</strong> '. $exists.' <button type="button" class="close" data-dismiss="alert" aria-label="Close"> <span aria-hidden="true">×</span> </button> </div> '; } ?> // front end <form action="signup.php" method="post" class="relative z-5 wow fadeInUp"> <div class="form-group relative mb-25 mb-sm-20"> <input type="text" class="form-control input-lg input-white shadow-5" id="username" placeholder="Username" name="username" required> <i class="far fa-user transform-v-center"></i> </div> <div class="form-group relative mb-25 mb-sm-20"> <input type="email" class="form-control input-lg input-white shadow-5" id="email" placeholder="Email" name="email" required> <i class="far fa-envelope transform-v-center"></i> </div> <div class="form-group relative mb-20 mb-sm-20"> <input type="password" class="form-control input-lg input-white shadow-5" id="password" placeholder="Password" name="password" required> <i class="fas fa-lock transform-v-center"></i> </div> <div class="form-group relative mb-20 mb-sm-20"> <input type="password" class="form-control input-lg input-white shadow-5" id="confirmpassword" placeholder="Confirm Password" name="confirmpassword" required> <i class="fas fa-lock transform-v-center"></i> </div> <div class="form-group form-check pl-0"> <div class="d-flex justify-content-between"> <div class="custom-control custom-checkbox"> <input type="checkbox" class="custom-control-input" id="customCheck1" checked=""> <label class="custom-control-label fs-13" for="customCheck1"><span class="label-check">Remember me</span></label> </div> </div> </div> <button type="submit" class="btn btn-square btn-block shadow-4 mt-20">SIGNUP</button> <div class="signup-login text-center">
×
×
  • 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.