ペット用のウェブサイトを作成しています。ペットの飼い主がペットを登録して追加できるページを作りたいです。フォームを作成し、javascriptを配置してペットを追加しました。これにより、[ペットを追加]リンクをクリックすると新しいフィールドが作成されます。しかし、この情報をphp変数に収集することはできません。リンクはここにあります:http://animalswecare.in/mypet.php
私はphpとmysqliの実用的な知識を持っています。
私のPHPコードif(isset($ _POST ['mypet'])){
$name = mysqli_real_escape_string ( $dbc, strip_tags ( trim ( $_POST['name'] ) ) );
$email = mysqli_real_escape_string ( $dbc, strip_tags ( trim ( $_POST['email'] ) ) );
$password = mysqli_real_escape_string ( $dbc, strip_tags ( trim ( $_POST['password'] ) ) );
$gender = mysqli_real_escape_string ( $dbc, strip_tags ( trim ( $_POST['sex'] ) ) );
$contact = mysqli_real_escape_string ( $dbc, strip_tags ( trim ( $_POST['contact'] ) ) );
$country = mysqli_real_escape_string ( $dbc, strip_tags ( trim ( $_POST['country'] ) ) );
$state = mysqli_real_escape_string ( $dbc, strip_tags ( trim ( $_POST['state'] ) ) );
$city = mysqli_real_escape_string ( $dbc, strip_tags ( trim ( $_POST['city'] ) ) );
//$photo = mysqli_real_escape_string ( $dbc, strip_tags ( trim ( $_POST['picture'] ) ) );
$fname = mysqli_real_escape_string ( $dbc, $_FILES['picture']['name'] );
$ext=$_FILES['picture']['name'];
$targetpath = "images/user/big/";
if($ext !="")
{
$ext = explode(".",$ext);
if($ext[1]=="jpg" || $ext[1]=="gif" || $ext[1]=="jpeg" || $ext[1]=="png" || $ext[1]=="bmp" || $ext[1]=="wbmp" || $ext[1]=="JPEG" || $ext[1]=="JPG" || $ext[1]=="GIF" || $ext[1]=="PNG" || $ext[1]=="BMP")
{
if($_FILES['picture']['size'] <= 2000000)
{
$filename=$targetpath.$id."-" .$fname;
$photo = $id."-" .$fname;
if (file_exists($filename))
{
chmod($filename, 0777);
unlink($filename);
}
if(move_uploaded_file($_FILES['picture']['tmp_name'],$filename))
{
$thpath = "images/user/thumb/";
$file = createThumb1($filename, $thpath, $fl_db,350,280);
}
}
}
}
$query = "INSERT INTO `user` SET `name`= '$name',`email` = '$email' ,`password` = '$password',`gender` = '$gender', `contact` = '$contact', `country` = '$country', `state` = '$state', `city` = '$city', `photo` = '$photo',`date` = now(),`status` = '1' ";
$insComm = mysqli_query($dbc, $query);
$uid = mysqli_insert_id( $dbc );
if($_POST['petname'])
{
$array = $_POST['petname'];
foreach($array as $petname)
{
if(strlen($petname)>0)
{
//$petname = mysqli_real_escape_string ( $dbc, strip_tags ( trim ( $_POST['petname'] ) ) );
$type = mysqli_real_escape_string ( $dbc, strip_tags ( trim ( $_POST['type'] ) ) );
$breed = mysqli_real_escape_string ( $dbc, strip_tags ( trim ( $_POST['breed'] ) ) );
$gender = mysqli_real_escape_string ( $dbc, strip_tags ( trim ( $_POST['gender'] ) ) );
//$photo = mysqli_real_escape_string ( $dbc, strip_tags ( trim ( $_POST['photo'] ) ) );
$fname = mysqli_real_escape_string ( $dbc, $_FILES['petimage']['name'] );
$ext=$_FILES['petimage']['name'];
$targetpath = "images/pet/big/";
if($ext !="")
{
$ext = explode(".",$ext);
if($ext[1]=="jpg" || $ext[1]=="gif" || $ext[1]=="jpeg" || $ext[1]=="png" || $ext[1]=="bmp" || $ext[1]=="wbmp" || $ext[1]=="JPEG" || $ext[1]=="JPG" || $ext[1]=="GIF" || $ext[1]=="PNG" || $ext[1]=="BMP")
{
if($_FILES['petimage']['size'] <= 2000000)
{
$filename=$targetpath.$id."-" .$fname;
$petphoto = $id."-" .$fname;
if (file_exists($filename))
{
chmod($filename, 0777);
unlink($filename);
}
if(move_uploaded_file($_FILES['petimage']['tmp_name'],$filename))
{
$thpath = "images/pet/thumb/";
$file = createThumb1($filename, $thpath, $fl_db,350,280);
}
}
}
}
$query = "INSERT INTO `mypet` SET `uid`= '$uid',`petname`= '$petname',`type` = '$type',`breed` = '$breed',`gender` = '$gender', `photo` = '$petphoto',`date` = now(),`status` = '1' ";
$insComm = mysqli_query($dbc, $query);
$msg = "Your information is successfully Added!!";