11
Answers

How to add encoding to a php file

Photo of ma ouml

ma ouml

7y
977
1
Hi friends
How i can add the encoding in the subject part of the email in php
And thank you in advance

Answers (11)

0
Photo of Kesavan Krishnan
NA 521 3.7k 7y
Hello,
 
Did you used  "utf-8" chaset in the mysql connection.
 
$this->conn->set_charset("utf8");
 
i mean after connect mysql 
  1. $this->conn = $this->connectDB();   
  2. $this->conn->set_charset("utf8");  
 
 
Accepted
0
Photo of ma ouml
NA 436 92.8k 7y
 

Kesavan Krishnan

do you have example please  
0
Photo of Kesavan Krishnan
NA 521 3.7k 7y
Hello,
 After your signup send link with some encripted key and need the following steps.
 
Step 1. Need to generate secret key with some datetime (Date time which means 2 days)
 
step 2. Have to add 2 field . one for confirmation another one for forgot password "user". 
 
step 3. After click on the url , have to decrypt it and check the date validation and confirmation field in DB. If that field already confirmed or date expired throw the error.
 
While signup and forgot password have to store that secret key into db and validate while confirm and forgot password.
 
Once confirmed remove the key and update the needed fieds like "confirmed" as 0 => 1 , forgot pass "forgot pass" 1 => 0.
 
All the best.. 
0
Photo of ma ouml
NA 436 92.8k 7y
 

Kesavan Krishnan

thank you very much
 
Sorry i will bother you i want to do that when the user signs up I send him a confirmation email as well as when he forgets the password
How do I please I tested several tuto but it does not work and thank you in advance
 
 
0
Photo of ma ouml
NA 436 92.8k 7y
 this is my query to create but i find the same problem
 
CREATE TABLE `contact` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(256) NOT NULL,
`email` varchar(256) NOT NULL,
`subject` varchar(256) NOT NULL,
`message` text NOT NULL,
`time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
0
Photo of ma ouml
NA 436 92.8k 7y
Kesavan Krishnan
i find the same problem 
0
Photo of Kesavan Krishnan
NA 521 3.7k 7y
As i mentioned for your previous question http://www.c-sharpcorner.com/forums/how-to-add-translation-options-for-my-website-in-php
 
you have to add the table Collation as "utf8_general_ci";
 
  1. ALTER TABLE <table_name> CHARACTER SET = utf8_general_ci;  
 
0
Photo of ma ouml
NA 436 92.8k 7y
 

Kesavan Krishnan

I solved the problem but I found another problem that the accents in the database they are not accéspés how to do please
 
 
0
Photo of Kesavan Krishnan
NA 521 3.7k 7y
Hello,
 
simply add the needed charset after created the mailer object
 
  1. $mail = new PHPMailer();  
  2. $mail->CharSet = 'UTF-8';  
 
 
0
Photo of ma ouml
NA 436 92.8k 7y
 

Kesavan Krishnan

 how to do in this script please
<?php
// Include and initialize phpmailer class
require 'PHPMailer/PHPMailerAutoload.php';
$mail = new PHPMailer;
// SMTP configuration
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'email';
$mail->Password = 'password';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->setFrom($_POST['email'], $_POST['name']);
$mail->addReplyTo($_POST['email'], $_POST['name']);
// Add a recipient
$mail->addAddress('email');
// Email subject
$mail->Subject = $_POST['objet']." - ". $_POST['name'];
// Set email format to HTML
$mail->isHTML(true);
// Email body content
$mailContent = "<p style = 'font-size:17px;'>".$_POST['message']."</p>";
$mail->Body = $mailContent;
// Send email
if(!$mail->send()){
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}else{
echo 'Message has been sent';
}
?>
 
0
Photo of Kesavan Krishnan
NA 521 3.7k 7y
Hello,
 
Please use  mb_send_mail 
 
http://php.net/manual/en/function.mb-send-mail.php
 
http://bitprison.net/content/how-to-send-correct-utf-8-mail-in-php/