Evening all,
its been awhile posting on here last couple of days i have been working on a section on my website i have ran into an issue that i am having i have this page for adding/removing multiple input fields but the only problem is the submitting part of my script.
you see when i click on submit no errors,the page just gets refreshed and redirected to my main login area member section but what it should be doing is inserting the multiple data into the database but lookjs like nothing is be display or even called
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-rc1/jquery.min.js"></script>
<script>
$(document).ready(function(){
var i=1;
$('#add').click(function(){
i++;
$('#dynamic_field').append('<tr id="row'+i+'"><td><input type="text" name="username" /></td><td><input type="text" name="emaill" /></td><td><button type="button" name="remove" id="'+i+'" class="btn_remove">Remove</button></td></tr>');
});
$(document).on('click', '.btn_remove', function(){
var button_id = $(this).attr("id");
$('#row'+button_id+'').remove();
});
$('#recruitmember').click(function(){
$.ajax({
url:"include/includeajax/MassRecruitInsert.php",
method:"POST",
data:$('#add_me').serialize(),
success: function(data)
{
$('#add_me')[0].reset();
}
});
});
});
</script>
<form action="" method="post" name="add_me" id="add_me">
<table style="color:#FFF;" id="dynamic_field">
<td><input type="hidden" name="password[]" value="<?php echo randAlphaNum(8); ?>"></td>
<tr>
<td colspan="3">Recruit Multiple Members</td>
</tr>
<tr>
<td>Username:</td>
<td>Email:</td>
<td>Task</td>
</tr>
<tr>
<td><input type="text" name="username[]" /></td>
<td><input type="text" name="email[]" /></td>
<td><input type="button" name="add" id="add" value="Add Another" /></td>
</tr>
</table>
<input type="submit" name="recruitmember" id="recruitmember" value="Recruit Member"/>
</form>
and the php submit code for the inserting is
[CODE]
include(âdbconnect.phpâ);
$number = count($_POST[âusernameâ]);
for($i=0; $i<$number; $i++)
{
$pQuery=âinsert into members (username,password,rank,email,disable,Recruitedby,LastedLogin,joineddate,web,recruits,signons,ia,joineddate2) values('â.mysqli_real_escape_string($con, $_POST[âusernameâ][$i]).
ââ,ââ.mysqli_real_escape_string($con, $_POST[âpasswordâ][$i]).
ââ,â1â,ââ.mysqli_real_escape_string($con, $_POST[âemailâ][$i]).
ââ,â1â,â$recruiterâ,â$todayâ,â$todayâ,â0â,â0â,â0â,â0â,â$today4â)â;
echo $pQuery;
$LQuery=âINSERT INTO logs Values(ââ,â$rankâ,â$recruiterâ,âsucessfully recruited $username onâ,â$todayâ,âRecruitmentâ)â;
$rQuery=âupdate members set recruits=recruits+$number where username='â.$_SESSION[âuserâ].â'â;
$result=mysqli_query($con,$pQuery);
$result=mysqli_query($con,$LQuery);
$result=mysqli_query($con,$rQuery);
if(!$result)
{
echo âError:â.mysqli_connect_errno();
echo â
Error2:â.mysqli_error($con);
}
else
{
echo â
Member Add to Clan
The Recruits Login information is as follows:
Username: $user
Password: $password
Please Make Sure the Recruit Logins and Changes his passwordâ;
$clanwebsite=$_SERVER[âHTTP_HOSTâ];
mail(â$emailâ, âWelcome to $ClanName!â, "$username
Welcome to $ClanName! You are now, the newest member of our great clan!
____________________________________________________________
Here is your information:
User Name: $user
Password: $password
Website For Clan is $clanwebsite
Ensure you don't lose this information. If you have a problem with loggin in, please
feel free to contact an officer and they can assist you.
____________________________________________________________");
}
}
echo âData Inserted Successfullyâ;[/CODE]
now the main file (mass recruit) where the html code is presented is in the directory includes and the massrecruitinsert.php is based in the includeajax folder
so for example
massrecruit.php file is based in http://www.mysite.com/includes/massrecruit.php
massrecruitinsert.php file is based in http://www.mysite.com/includes/includesajax/massrecruitinsert.php
so when i click on the the submit button nothing is coming back or returning and i know there is a problem some where but cant find it.
is there somthing wrong with the way i am doing things?