For some reason I am not getting a response back from AJAX call. I have used the console in Chrome and Firefox to monitor this but all I can see if what the form is sending. I am using MAMP and haven't tried this on a live server, but I need it to work in MAMP. I have tried lots of things people have suggested from similar issues I have found in stackoverflow but known have worked,please help!
<form id="signup_submit" method="post" action="AJAX/signup.php">
<div class="form-group show-progress">
</div>
<div class="form-group">
<input type="text" name="firstname" id="firstname" class="form-control" autocomplete="firstname" placeholder="Enter First Name...">
<span class="firstname-error error"></span>
</div><!-- form-group -->
<div class="form-group">
<input type="text" name="surname" autocomplete="surname" id="surname" class="form-control" placeholder="Enter Surname...">
<span class="surname-error error"></span>
</div><!-- form-group -->
<div class="form-group">
<input type="email" name="email" id="email" autocomplete="email" class="form-control" placeholder="Enter Email...">
<span class="email-error error"></span>
</div><!-- form-group -->
<div class="form-group">
<input type="password" name="password" autocomplete="password" id="password" class="form-control" placeholder="Choose Password...">
<span class="password-error error"></span>
</div><!-- form-group -->
<div class="form-group">
<input type="password" id="confirm" name="confirm" autocomplete="confirm" class="form-control" placeholder="Confirm Password...">
<span class="confirm-error error"></span>
</div><!-- form-group -->
<div class="form-group">
<button type="submit" id="submit" >Create Account</button>
</div><!-- form-group -->
<div class="form-group">
Already have an account?
</div>
</form><!-- form -->
signup.js
$(document).ready(function(){
$('form').submit(function(e){
e.preventDefault();
var data = $('#signup_submit').serialize();
console.log(data)
$.ajax({
type:'POST',
URL: 'AJAX/signup.php',
data: data,
dataType: 'json',
encode:true,
success: function(d){
d = JSON.parse(d);
console.log(d.testjson);
if(d.success){
$('#signup_submit').append('<div>'+d.message+'</div>');
}else{
if(d.errors.firstname){$('.firstname-error').show();$('.firstname-error').html(d.errors.firstname);}
if(d.errors.surname){$('.surname-error').show();$('.surname-error').html(d.errors.surname);}
if(d.errors.email){$('.email-error').show();$('.email-error').html(d.errors.emailname);}
if(d.errors.password){$('.password-error').show();$('.password-error').html(d.errors.password);}
if(d.errors.confirm){$('.confirm-error').show();$('.confirm-error').html(d.errors.confirm);}
}
}
})
})
})
signup.php
<?php
$errors = array();
$response = array();
if(empty($_POST['firstname'])){$errors['firstname'] = 'First Name Is Required!';}
if(empty($_POST['surname'])){$errors['surname'] = 'Surname Is Required!';}
if(empty($_POST['email'])){$errors['email'] = 'Email Address Is Required!';}
if(empty($_POST['password'])){$errors['password'] = 'Password Is Required!';}
if(empty($_POST['confirm'])){$errors['confirm'] = 'Please Confirm Your Password!';}
$response['errors'] = $errors;
if (!empty($errors)){
$response['success'] = false;
$response['message'] = 'FAIL!';
}else{
$response['success'] = true;
$response['message'] = 'SUCCESS!';
}
?>
You are never returning anything in the signup.php file. You need to json_encode and use echo or exit at the end of your script.
<?php
$errors = array();
$response = array();
if (empty($_POST['firstname'])) $errors['firstname'] = 'First Name Is Required!';
if (empty($_POST['surname'])) $errors['surname'] = 'Surname Is Required!';
if (empty($_POST['email'])) $errors['email'] = 'Email Address Is Required!';
if (empty($_POST['password'])) $errors['password'] = 'Password Is Required!';
if (empty($_POST['confirm'])) $errors['confirm'] = 'Please Confirm Your Password!';
$response['errors'] = $errors;
if (!empty($errors)) {
$response['success'] = false;
$response['message'] = 'FAIL!';
} else {
$response['success'] = true;
$response['message'] = 'SUCCESS!';
}
// Return data here
exit(json_encode($response));
?>
Edit: Keep the PHP exit from above, but instead use jQuery.post() rather than jQuery.ajax() as it is shorter, cleaner and simpler than messing with content types. It should also fix your issue:
$(document).ready(function(){
$('form').submit(function(e) {
e.preventDefault();
var data = $('#signup_submit').serialize();
console.log("data:");
console.log(data);
$.post("AJAX/signup.php", data, result => {
console.log("result:");
console.log(result);
result = JSON.parse(result);
if (result.success) {
$('#signup_submit').append('<div>'+result.message+'</div>');
} else {
if (result.errors.firstname) $('.firstname-error').html(result.errors.firstname).show();
if (result.errors.surname) $('.surname-error').html(result.errors.surname).show();
if (result.errors.email) $('.email-error').html(result.errors.email).show();
if (result.errors.password) $('.password-error').html(result.errors.password).show();
if (result.errors.confirm) $('.confirm-error').html(result.errors.confirm).show();
}
});
});
});
Remove dataType: 'json' and try. Also set the header before echoing back the result like below:
header('Content-type:application/json');
echo json_encode($response);
Related
I'm making a registration form where the script is executed in a seperate file that is used thru AJAX.
I have tried using the script directly by doing <form action="assets/php/action.php?action=register method="post" id="registration-form"> And it works that way however I would like to use AJAX to do this.
The problem with that is that if I use AJAX the POST data is not sent to the action.php file.
I have tried debugging my code but I cannot find what is causing the issue.
My registration form:
<form action="#" method="POST" class="user" id="register-form">
<div id="regAlert"></div>
<div class="form-group row">
<div class="col-sm-12 mb-3 mb-sm-0">
<input type="text" name="name" id="name" class="form-control form-control-user"
placeholder="Name" required>
</div>
</div>
<div class="form-group">
<input type="email" class="form-control form-control-user" id="remail" name="email"
placeholder="Email Address" required>
</div>
<div class="form-group row">
<div class="col-sm-6">
<div id="passError" class="text-danger font-weight-bold"></div>
</div>
</div>
<div class="form-group row">
<div class="col-sm-6 mb-3 mb-sm-0">
<input type="password" class="form-control form-control-user"
id="rpassword" name="password" placeholder="Password" required minlength="8">
</div>
<div class="col-sm-6">
<input type="password" class="form-control form-control-user"
id="cpassword" name="cpassword" placeholder="Repeat Password" required minlength="8">
</div>
</div>
<input type="submit" value="Register Account" id="register-btn" name="register" class="btn btn-primary btn-user btn-block">
<hr>
</form>
My AJAX script: (Sorry about the comments that are not in English)
<script type="text/javascript">
$(document).ready(function() {
//Register Form Ajax Request
$("#register-btn").click(function(e) { //Kui registreerimis nuppu vajutatakse, siis
if($("#register-form")[0].checkValidity()) { //Kontrolli formi õigsust
e.preventDefault();
$("#register-btn").val('Creating Account...'); //Muudab registreerimis nupu teksti
if($("#rpassword").val() != $("#cpassword").val()) { //Kui paroolid ei ole samad siis näitab errori
$("#passError").text('* Passwords did not match!'); //Paroolide mitte sama olemise error
$("#register-btn").val('Register Account'); //Muudab registreerimis nupu teksti
} else { //Kui paroolid kattusid, siis
$("#passError").text(''); //Eemaldab paroolide mitte sama olemis errori kirja
$.ajax({
url: "assets/php/action.php",
method: 'POST',
data: $("register-form").serialize()+'&action=register',
success:function(data) {
$("#register-btn").val('Register Account'); //Muudab registreerimis nupu teksti
if(data === 'register') {
window.location = 'home.php';
} else {
$("#regAlert").html(data);
}
}
});
}
}
});
});
</script>
My action.php file:
<?php
session_start();
require_once 'auth.php';
$user = new Auth();
if(isset($_POST['action'])) {
if($_POST['action'] == 'register') {
$name = $user->test_input($_POST['name']);
$email = $user->test_input($_POST['email']);
$pass = $user->test_input($_POST['password']);
$hpass = password_hash($pass, PASSWORD_DEFAULT);
echo $name;
echo $email;
echo $pass;
if($user->user_exist($email)) { //Kontrollib kas selle meiliaadressiga on konto juba registreeritud, kui on siis
echo $user->showMessage('warning', 'This email is already registered'); //Saadab inimesele kirja, et selle emailiga on konto juba registeeritud, 'warning' tähendab teate tüüpi, teine tekst on kiri, mida saadab
} else { //Kui selle meiliaadressiga pole kasutajat veel registeeritud, siis
if($user->register($name, $email, $hpass)) {
echo 'register';
$_SESSION['user'] = $email;
} else {
echo $user->showMessage('danger', 'Something went wrong! Please try again later or contact support.');
}
}
print_r($_POST); //This only outputs that the action is register, no POST values are outputted
die();
}
}
?>
Thanks,
Nimetu.
Don't use AJAX. Use fetch instead, you don't need external libraries like jQuery and more efficient. This is an example:
fetch('http://example.com/movies.json')
.then(response => response.json())
.then(data => console.log(data));
More information here: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
I am new to the PHP. I am trying to code a project using PHP and Ajax to logging into another page. But in Ajax query some parts are not executing that means it check every thing inside the Ajax query part but shows always "Wrong combination" in alert whenever it success.
Here is the code that I tried:
Logging page HTML would be:
form method="POST" class="form-signin">
<div class="account-logo">
<img src="assets/img/logo-dark.png" alt="">
</div>
<div class="form-group">
<label> Email</label>
<input type="email" name="email" id="email" autofocus="" class="form-control">
</div>
<div class="form-group">
<label>Password</label>
<input type="password" name="password" id="password" class="form-control">
</div>
<div class="form-group text-right">
Forgot your password?
</div>
<div class="form-group text-center">
<input type="button" onClick="sendContact();" class="btn btn-primary account-btn" name="login" value="DO LOGIN" id="login_button">
<!-- <button type="submit" class="btn btn-primary account-btn">Login</button> -->
</div>
<div class="text-center register-link">
Don’t have an account? Register Now
</div>
</form>
The Ajax part would be:
function sendContact() {
var email = $('#email').val();
var password = $('#password').val();
var data = {
"email": email,
"password": password,
};
jQuery.ajax({
data: data,
url: "auth/log.php", // Url to which the request is send
type: "POST", // Type of request to be send, called as method
success: function(data)
{
if(data==='success'){
window.location.replace('index.php');
}
else{
alert('Wrong combination');
}
}
});
// window.location.replace('index.php');
}
The log.php page would be
<?php
include "dbconnection.php";
session_start();
// $email=$_POST['email'];
// $password=$_POST['password'];
$select_data="select * from users where email='". $_POST['email']."' and password='".$_POST['password']."'";
$results= $conn->query($select_data);
if($results->num_rows>0){
$_SESSION["loggedin"] = true;
$_SESSION["user"] = $email;
echo 'success';
}else{
echo 'fail';
}
?>
Can some here help me.
I tried this code to use for login but it does not work. when I click on submit, nothing happens. When I tried to login I am always getting a wrong password error, but my password is correct. what should I do?
my HTML
<form class="form-horizontal" id="loginform" method="post">
<div class="form-group">
<label for="userid" class="col-sm-3 control-label">User ID</label>
<div class="col-sm-9 has-feedback">
<input type="text" class="form-control" id="userid" name="userid" placeholder="Enter Your User ID" required>
<span class="glyphicon glyphicon-user form-control-feedback"></span>
</div>
</div>
<div class="form-group">
<label for="password" class="col-sm-3 control-label">Password</label>
<div class="col-sm-9 has-feedback">
<input type="password" class="form-control" id="password" name="password" placeholder="Enter Your Password" required>
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
</div>
<div class="form-group">
<div class="col-xs-4 col-xs-offset-8">
<button type="submit" id="submit" class="btn btn-danger btn-block btn-flat">Sign In</button>
</div>
</div>
</form>
my Php
<?php
$userid = security($_POST['userid']);
$password = security($_POST['password']);
$query = mysqli_query($link,"SELECT * FROM user WHERE USER_USERNAME = '".$userid."' AND USER_PASSWORD = '".$password."'");
$numrows = mysqli_num_rows($query);
if ($numrows!==0)
{
while($row = mysqli_fetch_assoc($query))
{
#$_SESSION['session_userid'] = $row['USER_USERNAME'];
#$_SESSION['session_accounttype'] = $row['ACCESS_ID'];
}
//Location Depends on the User Type
if($_SESSION['session_accounttype']=="1")
{
echo 'true';
}
}
else
{
echo 'false';
}
?>
My JS
$(document).ready(function(){
$("#add_err").css('display', 'none', 'important');
$("#submit").click(function(){
username=$("#userid").val();
password=$("#password").val();
$.ajax({
type: "POST",
url: "../basefunction/login.php",
data: "userid="+username+"&password="+password,
success: function(html){
if(html=='true') {
//$("#add_err").html("right username or password");
window.location="admin";
}
else {
$("#add_err").css('display', 'inline', 'important');
$("#add_err").html("<img src='images/alert.png' />Wrong username or password");
}
},
beforeSend:function()
{
$("#add_err").css('display', 'inline', 'important');
$("#add_err").html("<img src='images/ajax-loader.gif' /> Loading...")
}
});
return false;
});
});
Why other answers talk the salt for password?question asks why password was wrong.
I think this code have questions
if($_SESSION['session_accounttype']=="1")
The session_accounttype may be not eq 1?
Can't comment so...
There is many problems with this example.
The submit button is going to submit your form automatically to "/". Look into preventdefault in javascript to solve that problem.
You are using ajax post with a query string. This would be done using the 'data' property in jquery data: {'userid' : username ,'password':password}. Then use $_POST['userid] and $_POST['password'] in php to get the values;
Sql inject will become a problem. But i can see you are learning and hope this is just a test to better your understanding of databasing.
Hash passwords
I am having problem with ajax submit form with angular, when i click submit my entire page is reloaded?
Where can be the problem, here is my code
/*
Create the controller and inject Angular's $scope
*/
// resource2Controller
(function () {
'use strict';
angular.module("aluPlanetApp").controller('resource2Controller', resource2Controller);
resource2Controller.$inject = ['$scope'];
resource2Controller.$inject = ['$http'];
function resource2Controller($scope, $http) {
activate();
function activate() {
$scope.title = 'Contact';
$scope.id = '2';
$scope.result = 'hidden'
$scope.resultMessage;
$scope.formData; //formData is an object holding the name, email, subject, and message
$scope.submitButtonDisabled = false;
$scope.submitted = false; //used so that form errors are shown only after the form has been submitted
$scope.submit = function (contactform) {
$scope.submitted = true;
$scope.submitButtonDisabled = true;
if (contactform.$valid) {
$http({
method: 'POST',
url: 'contact-form.php',
data: $.param($scope.formData), //param method from jQuery
headers: { 'Content-Type': 'application/x-www-form-urlencoded' } //set the headers so angular passing info as form data (not request payload)
}).success(function (data) {
console.log(data);
if (data.success) { //success comes from the return json object
$scope.submitButtonDisabled = true;
$scope.resultMessage = data.message;
$scope.result = 'bg-success';
} else {
$scope.submitButtonDisabled = false;
$scope.resultMessage = data.message;
$scope.result = 'bg-danger';
}
});
} else {
$scope.submitButtonDisabled = false;
$scope.resultMessage = 'Failed <img src="http://www.chaosm.net/blog/wp-includes/images/smilies/icon_sad.gif" alt=":(" class="wp-smiley"> Please fill out all the fields.';
$scope.result = 'bg-danger';
}
}
}
}
})();
And contact-form.php
<?php
require_once 'phpmailer/PHPMailerAutoload.php';
if (isset($_POST['inputName']) && isset($_POST['inputEmail']) && isset($_POST['inputSubject']) && isset($_POST['inputMessage'])) {
//check if any of the inputs are empty
if (empty($_POST['inputName']) || empty($_POST['inputEmail']) || empty($_POST['inputSubject']) || empty($_POST['inputMessage'])) {
$data = array('success' => false, 'message' => 'Please fill out the form completely.');
echo json_encode($data);
exit;
}
//create an instance of PHPMailer
$mail = new PHPMailer();
$mail->From = $_POST['inputEmail'];
$mail->FromName = $_POST['inputName'];
$mail->AddAddress('something#test.com'); //recipient
$mail->Subject = $_POST['inputSubject'];
$mail->Body = "Name: " . $_POST['inputName'] . "\r\n\r\nMessage: " . stripslashes($_POST['inputMessage']);
if (isset($_POST['ref'])) {
$mail->Body .= "\r\n\r\nRef: " . $_POST['ref'];
}
if(!$mail->send()) {
$data = array('success' => false, 'message' => 'Message could not be sent. Mailer Error: ' . $mail->ErrorInfo);
echo json_encode($data);
exit;
}
$data = array('success' => true, 'message' => 'Thanks! We have received your message.');
echo json_encode($data);
} else {
$data = array('success' => false, 'message' => 'Please fill out the form completely.');
echo json_encode($data);
}
HTML
<div ng-controller="resource2Controller" class="panel-body">
<form ng-submit="submit(contactform)" name="contactform" method="post" action="" class="form-horizontal" role="form">
<div class="form-group" ng-class="{ 'has-error': contactform.inputName.$invalid && submitted }">
<label for="inputName" class="col-lg-2 control-label">Name</label>
<div class="col-lg-10">
<input ng-model="formData.inputName" type="text" class="form-control" id="inputName" name="inputName" placeholder="Your Name" required>
</div>
</div>
<div class="form-group" ng-class="{ 'has-error': contactform.inputEmail.$invalid && submitted }">
<label for="inputEmail" class="col-lg-2 control-label">Email</label>
<div class="col-lg-10">
<input ng-model="formData.inputEmail" type="email" class="form-control" id="inputEmail" name="inputEmail" placeholder="Your Email" >
</div>
</div>
<div class="form-group" ng-class="{ 'has-error': contactform.inputSubject.$invalid && submitted }">
<label for="inputSubject" class="col-lg-2 control-label">Subject</label>
<div class="col-lg-10">
<input ng-model="formData.inputSubject" type="text" class="form-control" id="inputSubject" name="inputSubject" placeholder="Subject Message" required>
</div>
</div>
<div class="form-group" ng-class="{ 'has-error': contactform.inputMessage.$invalid && submitted }">
<label for="inputMessage" class="col-lg-2 control-label">Message</label>
<div class="col-lg-10">
<textarea ng-model="formData.inputMessage" class="form-control" rows="4" id="inputMessage" name="inputMessage" placeholder="Your message..." required></textarea>
</div>
</div>
<div class="form-group">
<div class="col-lg-offset-2 col-lg-10">
<button type="submit" class="btn btn-default" ng-disabled="submitButtonDisabled">
Send Message
</button>
</div>
</div>
</form>
<p ng-class="result" style="padding: 15px; margin: 0;">{{ resultMessage }}</p>
</div>
Mhh I belive that maybe your problem is in the HTML which I can't see right now so make sure that you are not using the submit button. I mean Instead of <input type="submit"... use <input type="button"...Here is a reference How do I make an HTML button not reload the page
On your HTML, you call your controller ContactController while at the Angular side you call it resource2Controller. Those two should match or Angular doesn't know what to do.
I am use codeigniter framework to create a registration form I have also use jQuery to validate the fields the validation is working but after filling all details and click register button nothing is happen jQuery does not post data to controller. please help
Here is my html code:
<form method="post" action="" name="sentMessage" id="contactForm" novalidate >
<div class="row">
<div class="col-sm-12">
<h3>Registration Form</h3>
</div>
<div class="col-sm-12">
<div class="form-group">
<input class="text required" type="text" placeholder="UserName" name="username" id="uname" data-validation-required-message="Please enter your UserName." />
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input class="text required" type="text" placeholder="First Name" name="fname" id="fname" data-validation-required-message="Please enter your First Name."/>
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input class="text required " type="text" placeholder="Last Name" name="lname" id="lname" data-validation-required-message="Please enter your Last Name."/>
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input class="text required email" type="email" placeholder="Email" name="email" id="uemail" data-validation-required-message="Please enter your Email."/>
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input class="text required" type="password" placeholder="Password" name="password" id="upassword" data-validation-required-message="Please enter your Password."/>
<p class="help-block text-danger"></p>
</div>
<div class="form-group">
<input class="text required" type="password" placeholder="Confirm Password" name="cpassword" id="cpassword" data-validation-required-message="Please enter your Password."/>
<p class="help-block text-danger"></p>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 rst-contactsubmit">
<div class="form-group">
<!-- required data-validation-required-message="Please enter your message." -->
<p class="help-block text-danger"></p>
<div id="success"></div>
</div>
<input class="btn btn-primary btn-lg" type="submit" value="REGISTER" />
</div>
</div>
</form>
My jquery code :
if( jQuery("#contactForm").length ) {
jQuery("#contactForm input").jqBootstrapValidation({
preventSubmit: true,
submitError: function(jQueryform, event, errors) {
// additional error messages or events
},
submitSuccess: function(jQueryform, event) {
event.preventDefault(); // prevent default submit behaviour
// get values from FORM
var username = jQuery("input#contact-username").val();
var fname = jQuery("input#contact-fname").val();
var lname = jQuery("input#contact-lname").val();
var email = jQuery("input#contact-email").val();
var password = jQuery("input#contact-password").val();
var firstName = fname; // For Success/Failure Message
// Check for white space in name for Success/Fail message
if (firstName.indexOf(' ') >= 0) {
firstName = fname.split(' ').slice(0, -1).join(' ');
}
jQuery.ajax({
type: "POST",
url: "<?php echo base_url()?>index.php/login/create_user",
data: {
username: username,
fname: fname,
lname: lname,
email: email,
password: password,
},
cache: false,
success: function() {
// Success message
jQuery('#success').html("<div class='alert alert-success'>");
jQuery('#success > .alert-success').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×")
.append("</button>");
jQuery('#success > .alert-success')
.append("<strong>Your message has been sent. </strong>");
jQuery('#success > .alert-success')
.append('</div>');
//clear all fields
jQuery('#contactForm').trigger("reset");
},
error: function() {
// Fail message
jQuery('#success').html("<div class='alert alert-danger'>");
jQuery('#success > .alert-danger').html("<button type='button' class='close' data-dismiss='alert' aria-hidden='true'>×")
.append("</button>");
jQuery('#success > .alert-danger').append("<strong>Sorry " + firstName + ", it seems that server is not responding. Please try again later!");
jQuery('#success > .alert-danger').append('</div>');
//clear all fields
jQuery('#contactForm').trigger("reset");
},
})
},
filter: function() {
return jQuery(this).is(":visible");
}
});
}
And my controller code :
<?php
class Login extends CI_Controller
{
function __construct()
{
parent::__construct();
}
public function index(){
$this->load->helper(array('form'));
$this->load->view('login');
}
function validate_credentials(){
$this->load->model('membership_model');
$query = $this->membership_model->validate();
if($query){
$data = array('username' => $this->input->post('username'), 'is_logged_in' => true);
$this->session->set_userdata($data);
redirect('<?php base_url()index.php/user_dashboard');
}
}
function create_user(){
$this->load->library('form_validation');
$this->form_validation->set_rules('username', 'Username', 'trim|required|callback_check_username');
$this->form_validation->set_rules('fname', 'Name', 'trim|required');
$this->form_validation->set_rules('lname', 'Last Name', 'trim|required');
$this->form_validation->set_rules('email', 'Email-id', 'trim|required|valid_email|callback_check_email');
$this->form_validation->set_rules('password', 'Password', 'trim|required|min_length[4]');
$this->form_validation->set_rules('cpassword', 'Confirm Password', 'trim|required|matches[password]');
if($this->form_validation->run() == FALSE){
echo "fail";
}
else{
$this->load->model('membership_model');
if($query = $this->membership_model->create_user())
{
$data['account created'] = 'your account is created';
$this->load->view('login', $data);
}
else{
$this->load->view('register');
}
}
}
function check_username($requested_username){
$this->load->model('membership_model');
$username_available = $this->membership_model->check_username($requested_username);
if($username_available){
return TRUE;
}
else{
return FALSE;
}
}
function check_email($requested_email){
$this->load->model('membership_model');
$email_available = $this->membership_model->check_email($requested_email);
if($email_available){
return TRUE;
}
else{
return FLASE;
}
}
}
?>
The problem seems to be in the jQuery code
url: "<?php echo base_url()?>index.php/login/create_user",
jQuery doesn't read PHP code. try changing it to
url: "login/create_user",
Hope this helps.
Codeigniter Validation will not work with Jquery/Ajax Form Submission. Please manually do the validation...
foreach($_POST as $key =>$value){
if($value==''){
echo 'Error';
}
}
By this server response you can alert the user Or else simply
https://jqueryvalidation.org/documentation/ use this client side validation.