मेरे पास एक मूल रूप है जिसे मैं कुछ मूल PHP का उपयोग कर सबमिट कर रहा हूं। मेरे पास फॉर्म सबमिशन बहुत अच्छा काम कर रहा है, सिवाय इसके कि मेरे पास एक रेडियो बटन है (संपर्क की पसंदीदा विधि के लिए) और मुझे यकीन नहीं है कि PHP में इसे कैसे जोड़ना है ताकि ईमेल में भेज सके। दोनों रेडियो बटन विकल्पों का एक ही नाम है, इसलिए यह मान के रूप में काम नहीं कर रहा है। मेरा कोड नीचे है।PHP फॉर्म हैंडलिंग के साथ रेडियो बटन
पीएचपी इस प्रकार है:
<?php
$name = stripslashes($_POST['name']);
$email = stripslashes($_POST['email']);
$phone = stripslashes($_POST['phone']);
$contact = stripslashes($_POST['contact']);
$message = stripslashes($_POST['message']);
$form_message = "Name: $name \nEmail: $email \nPhone: $phone \nPreferred Method of Contact: $contact \nMessage: $message";
// Exit process if field "human" is filled (because this means it is spam)
if ($_POST['human']) {
echo 'Tastes Like Spam!'; exit; }
// if it is not filled, submit form
else {
header("Location: http://www.newurl.com");
mail("[email protected]", "Email Subject", $form_message, "From: $email");
}
?>
प्रपत्र के लिए HTML नीचे है:
<form method="post" id="form" action="handle_form.php">
<div class="field">
<input type="text" name="human" id="human" class="txt" />
</div>
<div class="field form-inline">
<label class="contact-info" for="txtName">Name*</label>
<input type="text" name="name" id="name" class="txt" value=""/>
</div>
<div class="field form-inline">
<label class="contact-info" for="txtEmail">Email*</label>
<input type="text" name="email" id="email" class="txt" value=""/>
</div>
<div class="field form-inline">
<label class="contact-info" for="txtPhone">Phone</label>
<input type="text" name="phone" id="phone" class="txt" value=""/>
</div>
<div class="field form-inline radio">
<label class="radio" for="txtContact">Preferred Method of Contact</label>
<input class="radio" type="radio" name="contact" checked /> <span>Email</span>
<input class="radio" type="radio" name="contact" /> <span>Phone</span>
</div>
<div class="field form-inline">
<textarea rows="10" cols="20" name="message" id="message" class="txt" value=""></textarea>
</div>
<div class="submit">
<input class="submit" type="submit" name="submit" value="Submit Form">
</div>
</form>
धन्यवाद मदद के लिए बहुत बहुत!
<input class="radio" type="radio" value="email" name="contact" checked /> <span>Email</span>
<input class="radio" type="radio" value="phone" name="contact" /> <span>Phone</span>
आप भी लेबल –
की विशेषता रेडियो और चेक बॉक्स के साथ लेबल से जोड़ने के लिए एक आसान तरीका दोनों पाठ और एक '