我的代码没有从表单中 jQuery 创建的字段获取任何发布数据。我注释掉了很多代码以查看到底发生了什么,但我的 $_POST 只接收在 html 中手动设置的字段。
页面上显示 jQuery 创建的字段并允许我输入数据。所以我不明白为什么在我的 php 代码中提交后没有收到任何发布数据。有没有办法捕获这些字段中的数据并在提交之前保存它们?
<?php
session_start();
require_once "pdo.php";
// Demand a GET parameter
if ( ! isset($_SESSION['user_id']) || strlen($_SESSION['user_id']) < 1 ) {
die('ACCESS DENIED');
} else {
$username = $_SESSION['who'];
$user_id = $_SESSION['user_id'];
}
if ( isset($_POST['cancel'] ) ) {
// Redirect the browser to game.php
unset($_SESSION['first_name']);
unset($_SESSION['last_name']);
unset($_SESSION['email']);
unset($_SESSION['headline']);
unset($_SESSION['summary']);
header("Location: index.php?name=".urlencode($_SESSION['who']));
return;
}
if ( isset($_POST['clear']) ) {
$first_name = '';
$last_name = '';
$email = '';
$headline = '';
$summary = '';
unset($_POST);
}
if ( isset($_POST['headline']) && isset($_POST['summary']) && isset($_POST['email'])
&& isset($_POST['first_name']) && isset($_POST['last_name'])) {
//$first_name = $_POST['first_name'];
$email = $_POST['email'];
//$headline = $_POST['headline'];
$findme = "@";
$pos = strpos($email, $findme);
if ( strlen($_POST['headline']) < 1 || strlen($_POST['last_name']) < 1
|| strlen($_POST['first_name']) < 1 || strlen($_POST['email']) < 1
|| strlen($_POST['summary']) < 1){
$_SESSION['error'] = "All Fields Are Required";
header("Location: add.php?name=".urlencode($_SESSION['who']));
return;
}
aluckdog
相关分类