.htaccess Code
Options +FollowSymLinks -MultiViews
RewriteEngine On
#for normal domains like example.com or example.in to redirect to https://www.example.com
#RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
#RewriteCond %{HTTP} off
#RewriteCond %{HTTP_HOST} ^([^\.]+)\.(com|in|org)$ [NC]
#RewriteRule ^ http://www.%1.%2%{REQUEST_URI} [R=301,L,NE]
ErrorDocument 404 /errorPages/404.php
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+details\.php\?event=([^\s&]+) [NC]
RewriteRule ^ details/%1? [R=301,L]
RewriteRule ^details/([^/]+)/?$ details.php?events=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
# We are setting here the default file to load while the URL is called followed by fallback files
DirectoryIndex index.php
# Redirect all requests except only POST
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} \s/+(.*?/)?(?:index)?(.*?)\.(?:php?)[\s?/] [NC]
RewriteRule ^ /%1%2 [R=302,L,NE]
这是我的JQuery-Ajax代码:
var form = new FormData($('#regForm')[0]);
$.ajax({
url: "/register",
type: "POST",
data: form,
cache: false,
contentType: false,
processData: false,
success:function(data)
{
if(data == "ack")
{
$("form#regForm")[0].reset();
$("#message1").slideDown("slow");
setTimeout(function() {
$("#message1").slideUp("slow");
}, 5000);
}
else if(data == "nak")
{
$('#regForm').find('input, button, select').removeAttr('disabled');
$("#register").text("Register Now!");
$("#message2").slideDown("slow");
setTimeout(function() {
$("#message2").slideUp("slow");
}, 5000);
}
else
{
console.log(data);
}
},
error:function(data){}
});
这是PHP代码:
<?php
print_r($_POST);
exit();
?>
这是HTML代码:
<form id="regForm" enctype="multipart/form-data">
<div class="form-group">
<label for="event">Event / Workshop?</label>
<select id="vid_event" name="vid_event" class="form-control">
<option disabled selected value="">Select Event..</option>
<option value="Crack-A-Thon">(Workshop)</option>
</select>
</div>
<div class="form-group" id="addSubevent">
</div>
<div class="form-group">
<label for="name">Your Full Name</label>
<input onkeypress="return IsChar(event);" type="name" class="form-control" name="vid_name" id="vid_name">
</div>
<div class="form-group">
<label for="mobile">Your Mobile Number</label>
<input minlength="10" maxlength="10" onkeypress="return IsNumeric(event);" type="text" class="form-control" name="vid_mobile" id="vid_mobile">
</div>
<div class="form-group">
<label for="college">Your College Name</label>
<input onkeypress="return IsChar(event);" type="text" class="form-control" name="vid_college" id="vid_college">
</div>
<div class="form-group">
<label for="course">Course Field?</label>
<select id="vid_course" name="vid_course" class="form-control">
<option disabled selected value="">Select Course..</option>
<option value="11th">11th</option>
<option value="12th">12th</option>
<option value="Diploma">Diploma / Poly</option>
<option value="Engineering">Engineering</option>
<option value="Post Graduation">Post Graduation</option>
</select>
</div>
<div class="form-group">
<label for="vid_year">Which Year?</span></label>
<select id="vid_year" name="vid_year" class="form-control">
<option disabled selected value="">Select Year..</option>
<option value="First">First Year</option>
</select>
</div>
<button type="submit" id="register" class="btn btn-success btn-block">Register Now!</button>
</form>
当我在PHP服务器上打印数据时,它显示一个空白数组,并且没有数据被发布!为什么这样?代码逻辑出了什么问题?
每次,我将数据发布到服务器它显示一个空白数组总是我认为存在代码错误但它不喜欢它,因为它没有给出任何错误。