ไม่แน่ใจว่ามีใครตอบคำถามนี้ได้บ้าง
ฉันเพิ่งสร้างฟอร์ม PHP Ajax บนเว็บไซต์ของฉันซึ่งตรวจสอบความถูกต้องด้วย jQuery ฟิลด์ทั้งหมดได้รับการตรวจสอบความถูกต้องเพื่อให้ต้องมีเนื้อหาในการส่งแบบฟอร์ม
ด้วยเหตุผลบางประการ ฉันยังคงได้รับอีเมลที่ส่งจากแบบฟอร์ม แต่ไม่มีข้อมูลในแบบฟอร์ม มีใครบ้างที่มีความคิดว่าทำไมสิ่งนี้ถึงเป็นเช่นนั้น? ดูโค้ดและภาพหน้าจอด้านล่าง (ฉันได้ลบโค้ดตรวจสอบความถูกต้องของ jQuery เพื่อประหยัดพื้นที่ แต่ได้ทดสอบแล้วและใช้งานได้) -
---HTML---
<div class="col-md-6">
<div class="thankyou-message">
<p class="hero">THANK YOU!!!</p>
<p>For submitting your registration.</p>
<p>We have received your information and will contact you in due course.</p>
</div>
<div class="registration-form my-5 my-md-0">
<div class="row">
<div class="col-sm-4">
<label for="ageteam">Age group and team</label>
</div>
<div class="col-sm-8">
<input class="w-100" type="text" id="age-team" name="testage" required />
<span class="error age-team">Please tell us your age group</span>
</div>
</div>
<div class="row margin-top--20 margin-bottom--16 border-bottom--orange">
<div class="col-12">
PLAYER
</div>
</div>
<div class="row margin-bottom--8">
<div class="col-sm-4">
<label for="name">Name</label>
</div>
<div class="col-sm-8">
<input class="w-100" class="w-100" type="text" id="name" name="name" required />
<span class="error name">Please tell us your name</span>
</div>
</div>
<div class="row margin-bottom--8">
<div class="col-sm-4">
<label for="address">Address</label>
</div>
<div class="col-sm-8">
<textarea class="w-100" id="address" name="address" rows="4" required></textarea>
<span class="error address">Please tell us your address</span>
</div>
</div>
<div class="row margin-bottom--8">
<div class="col-sm-4">
<label for="postcode">Postcode</label>
</div>
<div class="col-sm-8">
<input class="w-100" type="text" id="postcode" name="postcode" required />
<span class="error postcode">Please tell us your postcode</span>
</div>
</div>
<div class="row margin-bottom--8">
<div class="col-sm-4">
<label for="dob">Date of birth</label>
</div>
<div class="col-sm-8">
<input class="w-100" type="text" id="dob" name="dob" required />
<span class="error dob">Please tell us your date of birth</span>
</div>
</div>
<div class="row margin-bottom--8">
<div class="col-sm-4">
<label for="school">School</label>
</div>
<div class="col-sm-8">
<input class="w-100" type="text" id="school" name="school" required />
<span class="error school">Please tell us the name of your school</span>
</div>
</div>
<div class="row margin-top--20 margin-bottom--16 border-bottom--orange">
<div class="col-12">
PARENT OR GUARDIAN
</div>
</div>
<div class="row margin-bottom--8">
<div class="col-sm-4">
<label for="parent-name">Name</label>
</div>
<div class="col-sm-8">
<input class="w-100" type="text" id="parent-name" name="parent-name" required />
<span class="error parent-name">Please tell us the name of your parent or guardian</span>
</div>
</div>
<div class="row margin-bottom--8">
<div class="col-sm-4">
<label for="parent-address">Address</label>
</div>
<div class="col-sm-8">
<textarea class="w-100" id="parent-address" name="parent-address" rows="4" required></textarea>
<span class="error parent-address">Please tell us your parent or guardians address</span>
</div>
</div>
<div class="row margin-bottom--8">
<div class="col-sm-4">
<label for="parent-postcode">Postcode</label>
</div>
<div class="col-sm-8">
<input class="w-100" type="text" id="parent-postcode" name="parent-postcode" required />
<span class="error parent-postcode">Please tell us the postcode of your parent or guardian</span>
</div>
</div>
<div class="row margin-bottom--8">
<div class="col-sm-4">
<label for="phone">Phone</label>
</div>
<div class="col-sm-8">
<input class="w-100" type="text" id="phone" name="phone" required />
<span class="error number">Please tell us your phone number</span>
<span class="error number2">Please enter a valid phone number</span>
</div>
</div>
<div class="row margin-bottom--8">
<div class="col-sm-4">
<label for="email">Email</label>
</div>
<div class="col-sm-8">
<input class="w-100" type="text" id="email" name="testemail" required />
<span class="error email">Please tell us your email address</span>
<span class="error email2">Please enter a valid email address</span>
</div>
</div>
<div class="submit-btn">
Submit registration
</div>
</div>
</div>
---jQuery Submission Code---
{-code- 2}
--- รหัสการประมวลผลแบบฟอร์ม PHP ---
<?php
$ageTeam = $_POST[\'ageTeam\'];
$name = $_POST[\'name\'];
$address = $_POST[\'address\'];
$postcode = $_POST[\'postcode\'];
$dob = $_POST[\'dob\'];
$school = $_POST[\'school\'];
$parentName = $_POST[\'parentName\'];
$parentAddress = $_POST[\'parentAddress\'];
$parentPostcode = $_POST[\'parentPostcode\'];
$number = $_POST[\'number\'];
$email = $_POST[\'email\'];
$email_thankyou = "
Hi".$name."
Thank you for registering.
We look forward to welcoming you to our team and will contact you in due course.
Thanks again
";
$email_alert = "
".$name."has completed a registration form.
Their details are listed below:
Age and team:".$ageTeam."
Players full name:".$name."
Players address:".$address."
Players postcode:".$postcode."
Players date of birth:".$dob."
Players school:".$school."
Parent/guardians name:".$parentName."
Parent/guardians address:".$parentAddress."
Parent/guardians postcode:".$parentPostcode."
Contact number:".$number."
Email Address:".$email."
";
$headers = "From: Test PHP Ajax Form";
// Notification email to client
mail($email, \'Thank you for registering\', $email_thankyou, $headers);
// Notification email to Matthiola
mail(\'[email protected]\', \'Player Registration\', $email_alert, $headers);
?>
--- อีเมลที่ได้รับ ---
อีเมลที่ได้รับแสดงแบบคงที่ เนื้อหา แต่ไม่มีข้อมูลที่ผู้ใช้ควรให้
สาเหตุส่วนใหญ่อาจเป็นเพราะบอทและโปรแกรมรวบรวมข้อมูลเว็บที่ทำงานผ่านไซต์ของคุณ คุณควรตรวจสอบอินพุตจากฝั่งเซิร์ฟเวอร์ (โดยใช้ PHP) ก่อนส่งอีเมล
if ($name != \'\' && $address != \'\'){
// Notification email to client
mail($email, \'Thank you for registering\', $email_thankyou, $headers);
// Notification email to Matthiola
mail(\'[email protected]\', \'Player Registration\', $email_alert, $headers);
}
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
JQuery is arguably the most popular JavaScript library with so many features for modern development. JQuery is a fast and concise JavaScript library created by John Resig in 2006. It is a cross-platform JavaScript library designed to simplify client-side HTML scripting. Over 19 million websites are currently using jQuery! Companies like WordPress, Facebook, Google, IBM and many more rely on jQuery to provide a kind of web browsing experience.
https://jquery.com/
HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet.
Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
https://www.w3.org/html/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.