Confirmation message after inserted data in new page - javascript

Good day all, I'm new to PHP and I really need some help. I'm trying to make a confirmation message in new page after inserting data. I tried echo and print the results, But nothing work to me!!!!. This is the only problem I faced which I could not solved !!!
Code for request.php page:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
</head>
<body dir="rtl">
<div class="container" style="width:400px;">
<div ng-app="myapp" ng-controller="formcontroller">
<form name="userForm" id="contact" ng-submit="insertData()">
<label class="text-success" ng-show="successInsert">{{successInsert}}</label>
<div class="form-group">
<label>name<span class="text-danger"></span>
</label>
<input type="text" name="name" ng-model="insert.name" class="form-control" /><span class="text-danger" ng-show="errorname">{{errorname}}</span>
</div>
<fieldset class="frmain">
<label>contact</label>
<div class="form-group">
<input type="text" name="em" ng-model="insert.em" class="form-control" placeholder="اemail" />
<span class="text-danger" ng-show="errorem">{{errorem}}</span>
<input type="text" name="telph" ng-model="insert.telph" class="form-control" placeholder="mobile" />
<span class="text-danger" ng-show="errortelph">{{errortelph}}</span>
</div>
<div class="form-group">
<label>department<span class="text-danger"></span>
</label>
<select ng-model="insert.dept" name="dept" class="form-control" style="font-family: times new roman;font-size: 18px;" />
<option value=""></option>
<option value="accounting department" </option>
<option value="huamn resources"></option>
<option value="IT department"></option>
</select>
<span class="text-danger" ng-show="errordept">{{errordept}}</span>
</div>
<div class="form-group" style="width: 320px;">
<label>details<span class="text-danger"></span>
</label>
<textarea name="det" ng-model="insert.det" class="form-control"></textarea>
<span class="text-danger" ng-show="errordet">{{errordet}}</span>
</div>
<div class="form-group">
<button name="submit" type="submit">send</button>
</div>
</form>
</div>
</div>
</body>
</html>
<script>
var application = angular.module("myapp", []);
application.controller("formcontroller", function($scope, $http) {
$scope.insert = {};
$scope.insertData = function() {
$http({
method: "POST",
url: "req_add.php",
data: $scope.insert,
}).success(function(data) {
if (data.error) {
$scope.errorname = data.error.name;
$scope.errorem = data.error.em;
$scope.errortelph = data.error.telph;
$scope.errordept = data.error.dept;
$scope.errordet = data.error.det;
$scope.successInsert = null;
} else {
$scope.insert = null;
$scope.errorname = null;
$scope.errorem = null;
$scope.errortelph = null;
$scope.errordept = null;
$scope.errordet = null;
$scope.successInsert = data.message;
}
});
}
});
</script>
Code for req_add.php page: (to insert data into DB)
<?php
//req_add.php
$connect = mysqli_connect("localhost", "root", "", "testing");
$form_data = json_decode(file_get_contents("php://input"));
mysqli_query($connect,'set names utf8') or die (mysqli_error($connect));
$data = array();
$error = array();
$date1 = date('Y/m/d H:i:s');// 2017-07-12 10:35:45
$today = date("Ymd");
$rand = strtoupper(substr(uniqid(sha1(time())),0,4));
$no1 = $today . $rand;
if(empty($form_data->name))
{
$error["name"] = "name is required";
}
if(empty($form_data->em))
{
$error["em"] = "email is required";
}
if(empty($form_data->telph))
{
$error["telph"] = "mobile number is required";
}
if(empty($form_data->dept))
{
$error["dept"] = "department is required";
}
if(empty($form_data->det))
{
$error["det"] = "details are required";
}
if(!empty($error))
{
$data["error"] = $error;
}
else
{
$name = mysqli_real_escape_string($connect, $form_data->name);
$em = mysqli_real_escape_string($connect, $form_data->em);
$telph = mysqli_real_escape_string($connect, $form_data->telph);
$dept = mysqli_real_escape_string($connect, $form_data->dept);
$det = mysqli_real_escape_string($connect, $form_data->det);
$no = mysqli_real_escape_string($connect, $form_data->no1);
$reqdate = mysqli_real_escape_string($connect, $form_data->reqdate);
$answer = mysqli_real_escape_string($connect, $form_data->answer);
$query = "INSERT INTO requests(name, em, telph, dept, det, no, reqdate, answer) VALUES ('$name','$em', '$telph', '$dept', '$det', '$no1', '$date1', 'no answer')";
if(mysqli_query($connect, $query))
{
$data["message"] = "thank you for your request, your request nymber is: " .$no1;
}
}
echo json_encode($data);
?>

One useful option is to use mysqli_insert_id to get the last id inserted.
This function get the last id in the DB, not only in the inserted table, but is sufficient.
Another is in manual form, where the query return a custom value.
In your code :
$query ="INSERT INTO requests(name, em, telph, dept, det, no, reqdate,answer)
VALUES ('$name','$em', '$telph', '$dept', '$det', '$no1','$date1', 'no answer')";
if(mysqli_query($connect, $query))
{
$data["message"] = "thank you for your request, your request nymber is: " .$no1;
}
}
echo json_encode($data);
Add this changes :
$query = "INSERT INTO requests(name, em, telph, dept, det, no, reqdate, answer)
VALUES ('$name','$em', '$telph', '$dept', '$det', '$no1', '$date1', 'no answer')";
$query .="; select 1 as insert_ok;";
if($stmt=mysqli_query($connect, $query)) // Get result
{
$fetch = mysql_fetch_object($stmt);
if ($fetch->insert_ok) {
$data["message"] = "thank you for your request, your request nymber is: " .$no1;
}else{
$data["message"] = "The register wasn't inserted";
} // else
} //if $stmt
echo json_encode($data);
And in your script code: validate the insert_ok value returned from the php script.

Related

Run PHP after JS validation

I am doing email validation for admin registration using JavaScript and save the data to database using PHP. Supposedly, the registration is done only if the email is valid. But when the email evaluates to invalid, the PHP code still run. How do I do it so that when the email is invalid, the PHP won't run.
Below is the PHP code to save data to database:
<?php
include('connection.php');
if(isset($_POST['saveBtn']))
{
$name = $_POST['name'];
$ic = $_POST['ic'];
$email = $_POST['email'];
$pass = $_POST['pass'];
$dob = $_POST['dob'];
$contact = $_POST['contact'];
$gender = $_POST['gender'];
$des = $_POST['des'];
$address = $_POST['address'];
// Check if data exist
$check = "SELECT * FROM admin WHERE admEmail = '".$email."' AND admPassword = '".$pass."'";
if(mysqli_num_rows(mysqli_query($connect,$check)) > 0)
{
?>
<script>
alert('This email and password already registered!');
</script>
<?php
}
else
{
$insert = "INSERT INTO admin (admName, admIC, admEmail, admPassword, admDOB, admContact, admGender, admDesignation, admAddress, admDateJoin) VALUES ('".$name."', '".$ic."', '".$email."', '".$pass."', '".$dob."', '".$contact."', '".$gender."', '".$des."', '".$address."', NOW())";
if(mysqli_query($connect, $insert))
{
?>
<script>
alert('Insertion Successful!');
window.close();
window.opener.location.reload();
</script>
<?php
}
else
{
?>
<script>
alert('Insertion Failed. Try Again!');
</script>
<?php
}
}
}
?>
Below is the JS:
function validateEmail() {
var email = document.addAdminForm.email.value;
var validRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+#[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/;
if (email.match(validRegex))
{
alert("Valid email address!");
return true;
}
else
{
document.getElementById("email_error").innerHTML = "Invalid email";
document.addAdminForm.email.focus();
return false;
}
}
Below is the partial HTML form:
<form class="w-100" name="addAdminForm" method="POST" onsubmit="validateEmail(this)" action="add_admin.php">
<div class="row">
<div class="col form-group">
<!-- <label for="email">Email</label> -->
<input type="text" class="form-control" name="email" placeholder="Email" required>
<span class="error email_error" id="email_error"></span>
</div>
<div class="float-right">
<input type="submit" class="btn button_primary" value="Save" name="saveBtn">
</div>
</form>
I expect PHP run when validation is true
add this:
onsubmit="return validateEmail(this)"
change your JS code to:
var validRegex = /^([a-zA-Z0-9_-])+#([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;

Provide a valid password before proceeding (Codeigniter)

Newbie here. I have a modal where staff can transfer fund to a client. Before transferring fund, the staff must input his/her password before proceeding to transaction. My goal is to have a WORKING FUNCTION about the password validation. I made a slightly working function. I have provided a video below for better explanation.
https://streamable.com/z4vgtv //Correct or wrong password, the result is the same. "Password not match"
Controller:
public function form_validation($userID)
{
$this->load->library('form_validation');
$this->form_validation->set_rules("amount","Amount", 'required|numeric');
$password = $this->input->post('password');
$exists = $this->networks->filename_exists($password);
$count = count($exists);
if($count >=1)
{
if($this->form_validation->run())
{
$ref= $this->session->userdata('uid') + time ();
$id = $this->input->post('userID');
$pData = array(
'userID' => $id,
'transactionSource' => 'FR',
'refNumber' => 'FI-0000' . $ref,
"amount" =>$this->input->post("amount"),
"transType" =>"in",
);
$this->networks->fundin($pData);
$ref= $this->session->userdata('userID') + time ();
$data1 = array(
'userID' => $this->session->userdata('uid'),
"transactionSource" => 'FR',
"refNumber" => 'FO' . $ref,
"amount" =>$this->input->post("amount"),
"transType" =>"out",
);
?>
<script> alert("password match");</script>
<?php
$this->networks->insert_data($data1);
redirect(base_url() . "network/agents");
}
else
{
$this->index();
}
}
else
{
?>
<script> alert("Password not Match");</script>
<?php
}
}
Model:
function filename_exists($password)
{
$this->db->select('*');
$this->db->from('users');
$this->db->where('password', $password);
$query = $this->db->get();
$result = $query->result_array();
return $query->result();
}
Views:
<form id="doBetting" method="post" action="<?php echo base_url('network/form_validation');?>/<?php echo $rows->userID; ?>">
<div class="input-group input-group-sm" style="width: 100%" >
<input type="hidden" id="usertransferid" name="userID">
<div class="col-lg-12" >
<input type="number" placeholder="Enter Amount" name="amount" class="form-control" id="box" required>
<br>
<input type="password" placeholder="Enter Password" name="password" class="form-control" id="cpass" required onblur="check_if_exists();">
<br>
<!-- buttons -->
<input type="submit" class="btn btn-success text-bold" name="save" id="insert" value="Transfer">
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
Ajax:
<script>
<script>
function check_if_exists() {
var password = $("#cpass").val();
$.ajax(
{
type:"post",
url: "<?php echo site_url(); ?>network/form_validation",
data:{password:password},
success:function(response)
{
// remove alert();
}
});
}
check_if_exists();
</script>
User always saved password on database with encoded form,but in your case,firstly you need to encode your password(format md5 or which format you are using to encode) and then check with your user password.
public function form_validation($userID)
{
$this->load->library('form_validation');
$this->form_validation->set_rules("amount","Amount", 'required|numeric');
$password = md5(trim($this->input->post('password')));
$exists = $this->networks->filename_exists($password);
.........
}

Update sql data using AngularJS

I need to update data using angular
I have SQL table(task list) with columns: id, taskname, date, prior
I need to have possibility to update only current field, using keypress
Field need to be updated according to its id.
HTML
<div class="task-list" ng-repeat="x in names">
<div class="col-md-1">
<input type="text" value="{{x.prior}}" ng-keypress="UpdateInfo()"/>
</div>
<div class="col-md-5">
<input type="text" value="{{x.taskname}}" ng-keypress="UpdateInfo()"/> <input type="submit" name="btnInsert" class="btn btn-info" ng-click="DeleteInfo()" value="Delete"/>
</div>
<div class="col-md-5">
<input type="date" value="{{x.startdate}}" ng-keypress="UpdateInfo()"/>
</div>
</div>
Controller
$scope.UpdateInfo = function(){
$http.post(
"update.php",
{'taskname':$scope.taskname, 'comments':$scope.comments, 'prior':$scope.prior, 'startdate':$scope.startdate }
).success(function(data){
alert(data);
if (data == true) {
getInfo();
}
});
}
PHP
There I tried to update only taskname
$data = json_decode(file_get_contents("php://input"));
if(count($data) > 0)
{
$id = mysqli_real_escape_string($connect, $data->id);
$taskname = mysqli_real_escape_string($connect, $data->taskname);
$comments = mysqli_real_escape_string($connect, $data->comments);
$startdate= mysqli_real_escape_string($connect, $data->startdate);
$prior= mysqli_real_escape_string($connect, $data->prior);
$query = "UPDATE tbl_user SET taskname='$taskname' WHERE id='$id'";
if(mysqli_query($connect, $query))
{
echo "Data Update...";
}
else
{
echo 'Error';
}
}
After keypress I see only "Data Update...".But taskname isn't updated.
You are sending a POST request so I don't think you need:
$data = json_decode(file_get_contents("php://input"));
Instead refer to the variables as $_POST['taskname'] and so on ..

Javascript is hanging up and takes almost 2 minutes to process form

I have a form up on http://coreelectric.us/contact.php that takes 2 minutes to process. On my localhost it is instantaneous. However, when I put the site live it takes forever. Here is the code in the form itself...
<form action="" method="post" class="form-content" id="contact-form" >
<div class="form-container">
<div id="thanks">Your email was sent successfully. Thank you, we will contact you soon.</div>
<div class="input-form">
<div class="input-left">
<label>*First Name :</label>
<input id="fname" type="text" name="fname" placeholder="Enter your first name" />
</div>
<div class="input-right">
<label>*Last Name :</label>
<input id="lname" type="text" name="lname" placeholder="Enter your last name" />
</div>
<div class="clearfix"></div>
</div>
<div class="input-form">
<div class="input-left">
<label>*Email :</label>
<input id="email" type="text" name="email" placeholder="Enter your valid email address " />
</div>
<div class="input-right">
<label>Phone Number :</label>
<input id="phone" type="text" name="phone" placeholder="Enter your phone only digit" />
</div>
<div class="clearfix"></div>
</div>
<div class="input-form">
<label>*Subject :</label>
<input id="subject" type="text" name="subject" placeholder="Subject"/>
<div class="clearfix"></div>
</div>
<div class="input-form">
<label>*Message :</label>
<textarea id="message" name="message" rows="10" placeholder="Enter your message here"></textarea>
</div>
<div class="input-form">
<label>*You must authenticate:</label>
<div style="float: left;" class="g-recaptcha" id="g-recaptcha" data-sitekey="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" data-callback="onReturnCallback" data-theme="light"></div>
</div>
<input type="submit" style="float: right;" class="btn st-btn btn-rounded btn-primary" value="Submit" />
<div class="error-msg"></div>
</div>
</form>
The javascript being used to process it is...
<script>
document.getElementById('phone').addEventListener('input', function (evt) {
evt.target.value = evt.target.value.replace(/\D/g, '');
});
$(document).on("keyup", "input.error", function(){
phone=$('#phone').val();
if($.isNumeric(phone)){
$('#phone').removeClass("error");
}
});
$(document).ready(function(){
$('#contact-form').submit(function(){
$('#contact-form .error').removeClass('error');
$('#contact-form .error-msg').hide()
form = true;
elm = $(this);
fname = $('#fname').val();
lname = $('#lname').val();
howhear = $('#how_hear').val();
state = $('#state').val();
street = $('#street').val();
city = $('#city').val();
zip = $('#zcode').val();
subject = $('#subject').val();
address = $('#address').val();
email = $('#email').val();
phone = $('#phone').val();
message = $('#message').val();
email_regex = /^(([^<>()[\]\\.,;:\s#\"]+(\.[^<>()[\]\\.,;:\s#\"]+)*)|(\".+\"))#((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if( email == ''){
$('#email').addClass('error');
form = false;
}else if(email_regex.test(email) == false){
$('#email').addClass('error');
form = false;
}
if(fname==''){
$('#fname').addClass('error');
form = false;
}
if(lname==''){
$('#lname').addClass('error');
form = false;
}
if(subject==''){
$('#subject').addClass('error');
form = false;
}
if(phone==''){
$('#phone').addClass('error');
form = false;
}
if(howhear==''){
$('#how_hear').addClass('error');
form = false;
}
if(state==''){
$('#state').addClass('error');
form = false;
}
if(street==''){
$('#street').addClass('error');
form = false;
}
if(zip==''){
$('#zcode').addClass('error');
form = false;
}
if(address==''){
$('#address').addClass('error');
form = false;
}
if(city==''){
$('#city').addClass('error');
form = false;
}
if(howhear==''){
$('#how_hear').addClass('error');
form = false;
}
if(message==''){
$('#message').addClass('error');
form = false;
}
if(grecaptcha.getResponse() ==""){
$('#g-recaptcha').addClass('error');
$('.error-msg').html('*Captcha ').show();
form = false;
}
if(form == false){
$('.error-msg').html('*Please filled correctly highlighted fields').show();
}
if(form){
$.ajax({
url:'email.php',
type:'post',
data: $('#contact-form').serialize(),
success: function(res){
$('#thanks').show();
setTimeout(function() {
$('#thanks').fadeOut('fast');
}, 60000); // <-- time in milliseconds
$('#contact-form')[0].reset();
}
});
}
return false;
});
});
</script>
the process page contains the following...
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$name = $fname." ".$lname;
$street = $_POST['street'];
$city = $_POST['city'];
$zip = $_POST['zcode'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$how_hear = $_POST['how_hear'];
$newsletter = $_POST['newsletter'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$domain = $_SERVER['SERVER_NAME'];
$to = "receiver#mydomain.com, ".$email;
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= "From:".$email . "\r\n";
$headers .= "BCC: myemail#mydomain.com, another#mydomain.com \r\n";
$txt = '<html style="background-color:#68B7F4">'
. '<div style="background-color:#FFF; padding: 10px;"><img
src="http://coreelectric.us/images/logo.png" alt="Core Electric" >
</div>'
. '<div>An email has been received from the contact page at
'.$domain.'. The following information was provided:<br><br></div>'
. '<table width="100%"><tr><td style="text-align: right; width:
15%;">Name: </td><td style="text-align: left; width:
85%;">'.$name.'</td></tr>'
. '<tr><td style="text-align: right; width: 15%;">Phone: </td><td
style="text-align: left; width: 85%;">'.$phone.'</td></tr>'
. '<tr><td style="text-align: right; width: 15%;">Email: </td><td
style="text-align: left; width: 85%;">'.$email.'</td></tr>'
. '<tr><td style="text-align: right; vertical-align: top; width:
15%;">Message: </td><td style="text-align: left; width:
85%;">'.$message.'</td></tr></table>'
. '<br><br>A representative will be in contact with you within 24
hours.'
. '</html>';
mail($to,$subject,$txt,$headers);
I'd truly appreciate any help understanding what could possibly be causing the hangup. It hangs up between these 2 lines of javascript...
data: $('#contact-form').serialize(),
success: function(res){
Thanks in advance
if(form){
console.log(Date.now())
$.ajax({
url:'email.php',
type:'post',
data: $('#contact-form').serialize(),
success: function(res){
console.log(Date.now())
console.log(res)
$('#thanks').show();
setTimeout(function() {
$('#thanks').fadeOut('fast');
}, 60000); // <-- time in milliseconds
$('#contact-form')[0].reset();
},
error: function(error) {
console.log(Date.now())
console.log(error)
}
});
}
and the php
if(mail($to,$subject,$txt,$headers)) {
echo "OK";
} else {
echo "Whoops";
}
By that, you might at least determine where is the problem. Also you might try to remove the if in php and try if error function in javascript won't catch a php error.
I ran my original code on a different server where I'm now running the same form on 3 different sites and it is lightning fast... narrowed it down to some issue with the other server, that i have zero interest in troubleshooting. I believe this one is closed. Thank you for the input.

I can't create a sign up form properly

I have the following box that contains a sign upform:
<!-- sign up form -->
<div id="cd-signup">
<form class="cd-form" action = "signup.php" > <?php echo "$error" ?>
<p class="fieldset">
<label class="image-replace cd-username" for="signup-username">Username</label>
<input class="full-width has-padding has-border" id="signup-username" type="text" placeholder="Username" name = "user" <?php echo "value='$user'"?>>
</p>
<p class="fieldset">
<label class="image-replace cd-password" for="signup-password">Password</label>
<input name = "pass" class="full-width has-padding has-border" <?php echo "value='$pass'" ?> id="signup-password" type="text" placeholder="Password">
<!-- <span class="cd-error-message">Password must be at least 6 characters long</span> -->
</p>
<p class="fieldset">
<input class="full-width has-padding" type="submit" value="Create account">
</p>
</form>
<!-- more text here -->
<span class="section-nav">
<ul>
<li><a id="signup" class="cd-signup" href="#0">Get Started</a></li>
<li><a id="learnmore" class="cd-learnmore" href="#section2">Learn More</a></li>
</ul>
</span>
<span class="section-nav">
<ul>
<li><a id="signup" class="cd-signup" href="#0">Get Started</a></li>
</ul>
These were implemented as a button shape.
I included at the head of my html file (index.php) the following php code:
<?php
require_once 'functions.php';
require_once 'signup.php';
$userstr = '';
if (isset($_SESSION['user'])) {
$user = $_SESSION['user'];
$loggedin = TRUE;
$userstr = " ($user)";
}
else $loggedin = FALSE;
if ($loggedin) {
header(home.php);
}
else {
?>
signup.php:
session_start();
<?php
$error = $user = $pass = "";
if (isset($_SESSION['user'])) destroySession();
if (isset($_POST['user']))
{
$user = sanitizeString($_POST['user']);
$pass = sanitizeString($_POST['pass']);
if ($user == "" || $pass == "")
$error = "Not all fields were entered<br><br>";
else
{
$result = queryMysql("SELECT * FROM members WHERE user='$user'");
if ($result->num_rows)
$error = "That username already exists<br><br>";
else
{
queryMysql("INSERT INTO members VALUES('$user', '$pass')");
die("<h4>Account created</h4>Please Log in.<br><br>");
}
}
}
?>
functions.php:
<?php
$dbhost = 'localhost'; // Unlikely to require changing
$dbname = 'socialmedia'; // Modify these...
$dbuser = 'root'; // ...variables according
$dbpass = 'mysql'; // ...to your installation
$appname = "Social Media"; // ...and preference
$connection = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
if ($connection->connect_error) die($connection->connect_error);
function queryMysql($query)
{
global $connection;
$result = $connection->query($query);
if (!$result) die($connection->error);
return $result;
}
function destroySession()
{
$_SESSION=array();
if (session_id() != "" || isset($_COOKIE[session_name()]))
setcookie(session_name(), '', time()-2592000, '/');
session_destroy();
}
function sanitizeString($var)
{
global $connection;
$var = strip_tags($var);
$var = htmlentities($var);
$var = stripslashes($var);
return $connection->real_escape_string($var);
}
function showProfile($user)
{
if (file_exists("$user.jpg"))
echo "<img src='$user.jpg' style='float:left;'>";
$result = queryMysql("SELECT * FROM profiles WHERE user='$user'");
if ($result->num_rows)
{
$row = $result->fetch_array(MYSQLI_ASSOC);
echo stripslashes($row['text']) . "<br style='clear:left;'><br>";
}
}
?>
The code works perfectly from where I got it (source: Learn Php, MySql, & Javascript), so I decided to apply it to me own website.
However, When I click on the create account button, nothing happens. The database is correctly set along with the appropriate tables (tested on original code) along with the proper Ajax Requests.
I think the problem is somewhere in index.php, maybe something I missed ?
Thank you for your help ! :)
EDIT:
here is the javascript of the button implementation
jQuery(document).ready(function ($) {
var formModal = $('.cd-user-modal'),
formSignup = formModal.find('#cd-signup'),
tabSignup = formModalTab.children('li').eq(1).children('a'),
,
backToLoginLink = formForgotPassword.find('.cd-form-bottom-message a'),
mainNav = $('.main-nav'),
sectionNav = $(".section-nav");
//open modal
mainNav.on('click', function (event) {
$(event.target).is(mainNav) && mainNav.children('ul').toggleClass('is-visible');
});
//open sign-up form
sectionNav.on('click', '.cd-signup', signup_selected);
//open login-form form
mainNav.on('click', '.cd-signin', login_selected);
//close modal
formModal.on('click', function (event) {
if ($(event.target).is(formModal) || $(event.target).is('.cd-close-form')) {
formModal.removeClass('is-visible');
}
});
//close modal when clicking the esc keyboard button
$(document).keyup(function (event) {
if (event.which == '27') {
formModal.removeClass('is-visible');
}
});
//switch from a tab to another
formModalTab.on('click', function (event) {
event.preventDefault();
($(event.target).is(tabLogin)) ? login_selected() : signup_selected();
});
function signup_selected() {
mainNav.children('ul').removeClass('is-visible');
formModal.addClass('is-visible');
formLogin.removeClass('is-selected');
formSignup.addClass('is-selected');
formForgotPassword.removeClass('is-selected');
tabLogin.removeClass('selected');
tabSignup.addClass('selected');
}
Take a look at this line:
<p class="fieldset">
<input class="full-width has-padding" type="submit" value="Create account">
</p>
Your submit button should have a name of user.
<p class="fieldset">
<input class="full-width has-padding" name="user" type="submit" value="Create account">
</p>

Categories

Resources