フォームを取得し、jquery で変数チェックを行い、それを ajax の php ファイルに渡しますが、この通知が表示されます
Notice: Undefined index: your_name in C:\xampp\htdocs\process.php 行 3 ここで何かが間違っています Notice: Undefined index: your_email in C:\xampp\htdocs\process.php 行 7
ここに私のjqueryコードがあります
$(".button").click(function(){
$('.error').hide();
var your_email=$("input#your_email").val();
if(your_email ==""){
$("label#youremail_error").show();
$("input#your_email").focus();
return false;
}
var your_name=$("input#your_name").val();
if(your_name==""){
$("label#yourname_error").show();
$("input#your_name").focus();
return false;
}
var friends_email=$("input#friends_email").val();
if(friends_email==""){
$("label#friendsemail_error").show();
$("input#friends_email").focus();
return false;
}
var friends_name=$("input#friends_name").val();
if(friends_email==""){
$("label#friendsname_error").show();
$("input#friends_name").focus();
return false;
}
var dataString = 'your_email=' + your_email + '&friends_email=' + friends_email + '&your_name=' + your_name + '&friends_name=' + friends_name;
//alert(dataString);
$.ajax({
type: "POST",
url:"process.php",
data: dataString,
success: function(ret) {
alert(ret);
//alert("thank you for signing up");
},
ここに私のPHPがあります
<?php
include 'inc/class.phpmailer.php';
if(isset($_POST['your_name'])){
$your_name=$_POST['your_name'];
}
else{
echo "something is wrong with your name having:";
var_dump($_POST['your_name']);
echo "<br/>";
}
if(isset($_POST['your_email'])){
$your_email=$_POST['your_email'];
}
else{
echo "something is wrong with your email having:";
var_dump($_POST['your_email']);
echo "<br/>";
}
if(isset($_POST['friends_name'])){
$friends_name=$_POST['friends_name'];
}
else{
echo "something is wrong with friends name having:";
var_dump($_POST['friends_name']);
echo "<br/>";
}
この通知が表示される理由がわかりません $_POST の値が設定されていないようです。
私はこれで頭がいっぱいです。$_POST が設定されていない理由/時期を知っていますか?