私は以下のコードを持つphpのフォームを持っています:
<form action="" method="post" class="wpcf7-form">
<p><label> Your Name<br /> <span><input type="text" name="your-name" value="" size="40" required /></span> </label></p>
<p><label> Your Email<br /> <span><input type="email" name="your-email" value="" size="40" required /></span> </label></p>
<p><label> Your Message<br /> <span><textarea name="your-message" cols="40" rows="10" required></textarea></span> </label></p>
<p><input type="submit" value="Submit" name="submit" /></p>
</form>
<?php
if(isset($_POST['submit'])){
$to = "[email protected]"; // this is your Email address
$from = $_POST['your_email']; // this is the sender's Email address
$first_name = $_POST['your_name'];
$last_name = $_POST['your_message'];
$subject = "Contact";
$subject2 = "";
$message = $first_name . " has sent you the following message. Message:" . "\n\n" . $last_name. "\n\n" ."Email: ".$from. "\n\n" ;
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
// mail($last_name,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo '<div style="color:#5cad2f; "><b>Thank you ' . $first_name . ', we will contact you shortly.</b></div>';
// You can also use header('Location: thank_you.php'); to redirect to another page.
}
?>
詳細を入力して[送信]ボタンをクリックしても何も起こりません。誰かがこれを手伝ってくれませんか?
あなたの値が設定されているかどうかを知ってみてください:
<?php
if(isset($_POST['submit']))
{
echo "hello world";
}
?>
それが表示される場合は、送信ボタンをクリックすると、hello world
その手段のsubmit
その後の仕事をあなたとあなたの入力フィールドに表示された名前を置き換えます$_POST['your_name']
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加