I have searched the question in stackoverflow and found few answers but non of them is helped me . So I am posting it again . My php form with post method in localhost is working fine but the same code is not working in server (linux server) I dont know what the actual problem is .Please help
- form that i want to submit
<form class="forma" id="forma" method="POST" action="contact-form.php" name="myForm" autocomplete="off">
<div class="formWrapper">
<div class="group">
<input type="text" name="name" id="name">
<span class="highlight"></span>
<span class="bar"></span>
<label>Name</label>
<p class="error-red"></p>
</div>
<div class="group">
<input type="text" name="eMail" id="eMail">
<span class="highlight"></span>
<span class="bar"></span>
<label>Email</label>
<p class="error-red"></p>
</div>
<div class="group">
<input type="text" name="mobileNo" id="mobileNo">
<span class="highlight"></span>
<span class="bar"></span>
<label>Mobile no.</label>
<p class="error-red"></p>
</div>
<div class="group">
<input type="text" name="message" id="message">
<span class="highlight"></span>
<span class="bar"></span>
<label>Message</label>
</div>
<div class="captchaWrapper">
<img src="captcha.php?rand=<?php echo rand(); ?>" id="captchaimgCont" style="margin-right: 14px;" alt="captcha">
<a href="javascript: refreshCaptcha();" class="clickTorefreshAnchor">
<i class="fa fa-refresh clickTorefresh" id="caprefresh">
</i>
</a>
<div class="captchaInputWrapper group">
<input type="text" id="6_letters_code" name="captcha">
<span class="highlight"></span>
<span class="bar"></span>
<label>Enter the code here:</label>
<p class="error-red"></p>
</div>
</div>
<div class="submit submitBtn" id="consubmit">
<button type="submit" name="sendmail" id="sendmail" class="sendMailBtn">Submit
</button>
</div>
</div>
<div class="clear"></div>
</form>
- my jquery ajax code
jQuery(document).ready(function() {
jQuery("#forma").submit(function(e) {
e.preventDefault();
e.stopImmediatePropagation();
jQuery('#sendmail').html('Please wait...');
jQuery.ajax({
type: "post",
url: './contact-form.php',
data: jQuery("#forma").serialize(),
dataType: "json",
success: function(data) {
jQuery('p.error-red').html('');
if ('success' == data.result) {
//jQuery("#forma")[0].reset();
//jQuery('#response').append('<p class="successMessage">' + data.msg + '</p>');
// jQuery('#sendmail').html('Submit');
window.location.href = "https://www.mrpmediaworks.com/thanks.php";
}
if ('error' == data.result) {
var arr = data.msg;
var element_arr = data.fieldname;
count = '0';
jQuery.each(arr, function(index, value) {
if (value.length != 0) {
jQuery('input[name=' + element_arr[count] + ']').parent('.group').find('p.error-red').html(value);
}
count++;
});
jQuery('#sendmail').html('Submit');
}
}
});
return false;
});
});
- my php code
<?php
session_start();
require_once('config.php');
$email = '';
$fieldname = array();
$msg = array();
$result = '';
$count = '';
$name = $_Post["name"];
$contact = $_Post["mobileNo"];
$email = $_Post["eMail"];
$msg_query = $_Post["message"];
$captcha = $_Post["captcha"];
echo $name;
die();
?>
just testing code
same code works with get
I have tried removing action from form and may possible combination but noting worked. after edit
4. .htaccess file
# browser requests PHP
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]
# check to see if the request is for a PHP file:
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^/?(.*)$ /$1.php [L]
this is the only content in my htaccess file