I'm working on contact form for my site, everything work good if i fill the inputs in English language but if i fill the inputs in arabic language i don't receive any emails, how i can fix this ?
this is my code :
HTML code :
<section class="body">
<form action="form.php" method="post" enctype="multipart/form-data">
<h1 class="title">Contact</h1>
<label></label>
<input name="d_name" required="required" placeholder="أسم المندوب">
<label></label>
<input name="d_phone" type="text" required="required" placeholder="رقم هاتف المندوب">
<label></label>
<input name="c_name" type="text" required="required" placeholder="أسم المشترك">
<label></label>
<input name="phonee" required="required" type="text" placeholder="رقم هاتف المشترك" />
<label></label>
<select class="dropdown-select" name="comp" required="">
<option disabled="disabled" selected="selected" value="">أختر الشركة</option>
<option value="جولان">جولان</option>
<option value="بارتنير">بارتنير</option>
<option value="بلفون">بلفون</option>
<option value="تيلزار 019">تيلزار 019</option>
</select>
<label></label>
<select name="type" required="">
<option disabled="disabled" selected="selected" value="">اختر نوع الرقم</option>
<option value="فاتورة">فاتورة</option>
<option value="كرت">كرت</option>
</select>
<label></label>
<input name="sim" required="required" type="text" placeholder="رقم الشريحة" />
<label></label>
<textarea name="message" cols="20" rows="5" required="required" placeholder="Message"></textarea>
<input id="cancel" name="cancel" value="Cancel" />
<input id="submit" name="submit" type="submit" value="Submit">
</form>
</section>
PHP code :
<?php
$name = $_POST['d_name'];
$phone = $_POST['d_phone'];
$cname = $_POST['c_name'];
$cphone = $_POST['phonee'];
$comp = $_POST['comp'];
$sim = $_POST['sim'];
$type = $_POST['type'];
$message = $_POST['message'];
$from = 'From:' . $_POST['d_name'];
$to = 'Noor_Phone#hotmail.com';
$subject = 'Email Inquiry';
$body = "Delegate Name: $name\n Delegate phone: $phone\n\n\n Customer Name: $cname\n Customer Phone: $cphone\n Line Type: $type\n Company: $comp\n Sim Number: $sim\n Message:\n $message";
?>
<?php
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
echo '<p>Thank you for your email!</p>';
} else {
echo '<p>Oops! An error occurred. Try sending your message again. </p>';
}
}
?>
Instead of using php built-in mail function, use phpmailer. This will solve your problem. Using this class you have the option to set charset:
$mail->CharSet = 'UTF-8';
For additional troubleshooting, you can
<meta charset="utf-8">
You also have the option to include charset attribute in the form tag:
<form action="form.php" method="post"
enctype="multipart/form-data" accept-charset="utf-8">
Or have a look at this old SO answer on sending arabic content in email.
Hope this may help.
Setting the Html Lang might help this situation try this
<html lang="ar">
Referenced from http://www.w3schools.com/tags/ref_language_codes.asp
thanks for helping ,this is the answer:
HTML Code:
<h1 class="title">Contact</h1>
<label></label>
<input name="d_name" required="required" placeholder="أسم المندوب">
<label></label>
<input name="d_phone" type="text" required="required" placeholder="رقم هاتف المندوب">
<label></label>
<input name="c_name" type="text" required="required" placeholder="أسم المشترك">
<label></label>
<input name="phonee" required="required" type="text" placeholder="رقم هاتف المشترك" />
<label></label>
<select class="dropdown-select" name="comp" required="">
<option disabled="disabled" selected="selected" value="">أختر الشركة</option>
<option value="جولان">جولان</option>
<option value="بارتنير">بارتنير</option>
<option value="بلفون">بلفون</option>
<option value="تيلزار 019">تيلزار 019</option>
</select>
<label></label>
<select name="type" required="">
<option disabled="disabled" selected="selected" value="">اختر نوع الرقم</option>
<option value="فاتورة">فاتورة</option>
<option value="كرت">كرت</option>
</select>
<label></label>
<input name="sim" required="required" type="text" placeholder="رقم الشريحة" />
<label></label>
<textarea name="message" cols="20" rows="5" required="required" placeholder="Message"></textarea>
<input id="cancel" name="cancel" value="Cancel" />
<input id="submit" name="submit" type="submit" value="Submit">
</form>
</section>
PHP Code:
<?php
$mail->CharSet = 'UTF-8';
$name = $_POST['d_name'];
$phone = $_POST['d_phone'];
$cname = $_POST['c_name'];
$cphone = $_POST['phonee'];
$comp = $_POST['comp'];
$sim = $_POST['sim'];
$type = $_POST['type'];
$message = $_POST['message'];
$formcontent="Delegate Name: $name\n Delegate phone: $phone\n\n\n Customer Name: $cname\n Customer Phone: $cphone\n Line Type: $type\n Company: $comp\n Sim Number: $sim\n Message:\n $message";
$recipient = "Noor_Phone#hotmail.com";
$subject = "Contact Form";
$mailheader = "From: admin#4uphone.co.il";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='contact.html' style='text- decoration:none;color:#ff0099;'> Return Home</a>";
?>
Related
Am I not supposed to be using the POST method to obtain the information for the Employees? I used this form before when it was just name, email, and phone and it worked fine. I'm new to PHP and am a bit lost.
I edited a little bit of the form out so that it didn't go on forever so I apologize for the lengthy code (this is my first post) I'm really just focused on getting the dropdown menu of the form converted into PHP because I believe that is my real issue.
this is my dropdown HTML (edited)
<form action="solutions_form.php" method="post" >
<div class="ai-s7-row2">
<label for="">phone</label>
<input type="text" name="phone" required="required" placeholder="Enter your phone">
</div>
<div class="ai-s7-row2">
<label for="">website</label>
<input type="text" name="website" required="required" placeholder="Enter your website">
</div>
<div class="ai-s7-row3 form-message-area">
<label for="">tell us a little about your business's compliance and/or regulartory needs</label>
<textarea name="message" required="required" placeholder="Enter your message"></textarea>
</div>
<div class="ai-s7-row2">
<label for="employees">number of employees</label>
<div class="ai-s7-row3">
<select id="employees" name="employees">
<option value=""> Pick an option</option>
<option value="< 10"> < 10</option>
<option value="< 100">< 100</option>
<option value="< 1000">< 1000</option><option value="> 1000">more than 1000</option>
</select>
</div>
</div>
<div class="form-btn-bx">
<input type="submit" class="form-submit-btn" value="Submit">
</div>
</form>
This what I have in my PHP
/* Data Variables */
$name = $_POST['name'];
$email = $_POST['email'];
$organization = $_POST['organizatioon'];
$industry = $_POST['$industry'] ;
$phone = $_POST['phone'];
$website = $_POST['website'];
$message = $_POST['message'];
$employees = $_POST['employees'];
$honeypot = $_POST['_honey'];
$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Organization: $organization <br>
Industry: $industry <br>
Phone: $phone <br>
Website: $website <br>
Message: $message <br>
Employees: $employees <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);
Need to add form,method = "post" action = 'PHP file address'
I'm using the following php script on a contact form but it is neither sending emails or redirecting -
<?php
if (isset($_POST['submit'])) {
$jobtype = $_POST['jobtype'];
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$mailto = "myemail";
$email_subject = "Contact form submission: $name";
$email_body = "You have received a new message. ".
" Here are the details:\n $jobtype \n Name: $name \n ".
"Email: $email \n Message \n $message";
mail($mailto, $email_subject, $email_body,);
header("Location: thank-you.html?mailsend");
}
?>
The contact form is as follows -
<form action="/contact.php" method="POST">
<label for="jobtype">What can I do for you?</label>
<select id="jobtype" name="jobtype">
<option value="web-design">Web Design</option>
<option value="logo-design">Logo Design</option>
<option value="graphic-design">Graphic Design</option>
<option value="photo-video">Photography/Video</option>
<option value="general-enquiry">General Enquiry</option>
</select>
<label for="name">Who are you?</label>
<input type="text" id="name" name="name" placeholder="Your name is..">
<label for="email">Your email?</label>
<input type="text" id="email" name="email" placeholder="Your email is..">
<label for="message">A quick description of the job</label>
<textarea id="message" name="message" placeholder="Let me know here.." style="height:200px"></textarea>
<input type="submit" value="Submit">
</form>
I've tried some of the fixes on here but none seem to work, any help is appreciated!
Having problem in sending form input to email, using php code.
<?php
$emailTo="testing_testing#gmail.com";
$subject = $POST_['username'];
$content = $_POST['course'] . $_POST['message'] . $_POST['tel'];
$headers = "From: ".$_POST['email'];
mail($emailTo, $subject, $content, $headers);
?>
HTML Form Code:
<form method="post">
<input id="username" type="text" name="username" placeholder="Name" required> </br>
<input id="tel" type = "tel" name="tel" placeholder="Phone no." required></br>
<input id="email" type="email" name="email" placeholder="Email id" required></br>
<input list="course" name="course">
<datalist id="course">
<option value="IELTS">
<option value="English Speaking">
<option value="Computers">
<option value="Accounting">
<option value="Fashion Designing">
<option value="Hospitality and Tourism">
<option value="General Enquiry">
</datalist>
<textarea id="message" name="message" rows="10" cols="30" placeholder="Any Message !"></textarea>
<INPUT id="submit" type="submit" value="Submit">
</form>
OUTPUT:
This code does not set the subject field as it says - nosubject. Where as in the php code I am assigning the value of username as the subject field.
The problem is your declaration of the $subject variable:
$subject = $POST_['username'];
Should be
$subject = $_POST['username'];
Hope this helps :)
I have a form which user submits and is sent directly to the e-mail. The problem is that I'm not storing these values in database and directly mailing them. It is like a complaint registering system. What I want to do is that when the user submits a complaint and is redirected to success page, a complaint number is generated which should be obviously incremental by 1 for the next submission. Also there is no separate user account as anyone visiting the website can submit complaints. I tried using a field option as unique id but it didn't really work.
The html form is,
<form method="post" action="handler.php">
<div>
<label for="first_name"><span class="labelname"><strong>First Name:</strong></span></label>
<input type="text" maxlength="50" size="50" name="first_name" id="first_name" value="" class="required" />
</div>
<div>
<label for="last_name"><span class="labelname"><strong>Last Name:</strong></span></label>
<input type="text" maxlength="50" size="50" name="last_name" id="last_name" value="" class="required" />
</div>
<div>
<label for="telephone"><span class="labelname"><strong>Telephone Number:</strong></span></label>
<input type="text" maxlength="20" size="50" name="telephone" id="telephone" value="" class="required" />
</div>
<div>
<label for="email"><span class="labelname"><strong>E-mail: (Optional)</strong></span></label>
<input type="email" maxlength="30" size="50" name="email" id="email" value="" class="" />
</div>
<div>
<label for="com_type"><span class="labelname"><strong>Complaint Type:</strong></span></label>
<select name="com_type" id="com_type" class="required">
<option value=""></option>
<option value="Electrician">Electrician</option>
<option value="Plumber">Plumber</option>
<option value="Mason">Mason</option>
<option value="Miscellaneous">Miscellaneous</option>
</select>
</div>
<div>
<label for="flat_no"><span class="labelname"><strong>Flat No.:</strong></span></label>
<input type="text" maxlength="10" size="50" name="flat_no" id="flat_no" value="" class="required" />
</div>
<div>
<label for="block_no"><span class="labelname"><strong>Block Number:</strong></span></label>
<select name="block_no" id="block_no" class="required">
<option value=""> </option>
<option value="A-1">A-1</option>
<option value="A-2">A-2</option>
<option value="A-3">A-3</option>
<option value="A-4">A-4</option>
<option value="A-5">A-5</option>
<option value="A-6">A-6</option>
<option value="A-7">A-7</option>
<option value="B-1">B-1</option>
<option value="B-2">B-2</option>
<option value="B-3">B-3</option>
<option value="B-4">B-4</option>
<option value="C-1">C-1</option>
<option value="C-2">C-2</option>
</select>
</div>
<div>
<label for="message"><span class="labelname"><strong>Describe your problem:</strong></span></label>
<textarea rows="10" cols="50" maxlength="2000" name="message" id="message" class="required"></textarea>
</div>
<button class="submit" type="submit" name="submit" value="Send Email">Submit Complaint</button> <button class="reset" type="reset">Reset</button>
php code,
<?php
if(!isset($_POST['submit']))
{
die("Error. You need to submit the form.");
}
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$telephone = $_POST['telephone'];
$visitor_email = $_POST['email'];
$com_type = $_POST['com_type'];
$flat_no = $_POST['flat_no'];
$block_no = $_POST['block_no'];
$message = $_POST['message'];
$email_from = $visitor_email;
$email_subject = "New Complaint";
$email_body = "message\n\n". "First Name: $first_name\n\n".
"Last Name: $last_name\n\n".
"Telephone: $telephone\n\n". "Complaint Type: $com_type\n\n".
"Flat No.: $flat_no\n\n". "Block No.: $block_no\n\n".
"Complaint: $message";
$to = "my email.com";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
try{
mail($to,$email_subject,$email_body,$headers);
//success, redirect to thank
header('Location: http://mywebsite.com/thank.php');
} catch(Exception $e){
//problem, redirect to fail
header('Location: http://mywebsite.com/fail.php');
}
?>
I just want a complaint number on the successful submission page and the complaint number should also go in the mail also with other details. Can I do it without using the database. Please help.
If you have the numbers stored as a primary key, then you can do something like this:
SELECT COUNT(*) FROM `table`;
Or if you have the auto_increment or PRIMARY KEY set, you can use:
SELECT MAX(`id`) FROM `table`;
And then add + 1 to the result and insert it as new. If you aren't using a database, then use a flat file named count.txt for it and put in the current number and increment:
<?php
$count = file_get_contents("count.txt");
$count++;
file_put_contents("count.txt", $count);
?>
But this option is not so good. So please use a mechanism to lock the file while updating the count.
I have a webpage that has two contact forms and the second one is working fine but I can't seem to get the first one to work. I am fairly new to php. Thanks in advance for the help. Here's the html:
<h3>Message Us</h3>
<form action="?" method="POST" onsubmit="return saveScrollPositions(this);">
<input type="hidden" name="scrollx" id="scrollx" value="0" />
<input type="hidden" name="scrolly" id="scrolly" value="0" />
<div id="msgbox1">
<label for="name2">Name:</label>
<input type="text" id="name2" name="name2" placeholder=" Required" />
<label for="email2">Email:</label>
<input type="text" id="email2" name="email2" placeholder=" Required" />
<label for="phone">Phone:</label>
<input type="text" id="phone" name="phone" placeholder="" />
<label for= "topic">Topic:</label>
<select id="topic" name="topic">
<option value="general">General</option>
<option value="stud">Property Price Enquiry</option>
<option value="sale">Bull Sale Enquiry</option>
</select>
</div><!--- msg box 1 -->
<div id="msgbox2">
<textarea id="message" name="message" rows="7" colums="25" placeholder="Your Message?"></textarea>
<p id="feedback2"><?php echo $feedback2; ?></p>
<input type="submit" value="Send Message" />
</div><!--- msg box 2 -->
</form><!--- end form -->
</div><!--- end message box -->
And here's the php:
<?php
$to2 = '418#hotmail.com'; $subject2 = 'MPG Website Enquiry';
$name2 = $_POST ['name2']; $email2 = $_POST ['email2']; $phone = $_POST ['phone']; $topic = $_POST ['topic']; $message = $_POST ['message'];
$body2 = <<<EMAIL
This is a message from $name2 Topic: $topic
Message: $message
From: $name2 Email: $email2 Phone: $phone
EMAIL;
$header2 = ' From: $email2';
if($_POST['submit']=='Send Message'){
if($name2 == '' || $email2 == '' || $message == ''){
$feedback2 = '*Please fill out all the fields';
}else {
mail($to2, $subject2, $body2, $header2);
$feedback2 = 'Thanks for the message. <br /> We will contact you soon!';
} } ?>
For the saveScrollPositions I use the following php and script:
<?php
$scrollx = 0;
$scrolly = 0;
if(!empty($_REQUEST['scrollx'])) {
$scrollx = $_REQUEST['scrollx'];
}
if(!empty($_REQUEST['scrolly'])) {
$scrolly = $_REQUEST['scrolly'];
}
?>
<script type="text/javascript">
window.scrollTo(<?php echo "$scrollx" ?>, <?php echo "$scrolly" ?>);
</script>
You have a mistake in your HTML part i.e.
<input type="submit" value="Send Message" />
add attribute name also in this input type like this-
<input type="submit" value="Send Message" name="submit" />
one thing more to correct in your php script is write-
$header2 = "From: ".$email2; instead of $header2 = ' From: $email2';
now try it.
What do you return in "saveScrollPositions" function? if you return false the form submit wont fire.