Ajax email Availability check with php not working - javascript

I want to check email availability but it's not working. and also I am new to javascript and ajax please help me.
his is my code
email input with span to show output(for now there is no output)
<input class="input--style-4" id="email" type="email" name="email" required>
<span id="user-availability-status"></span>
JS
<script>
$(document).ready(function() {
$('#email').blur(function() {
var email = $(this).val();
$.ajax({
url: 'includes\emailAvailability.php',
method: "POST",
data: {
email_val: email
},
success: function(data) {
if (data != 0) {
$('#user-availability-status').html('<span>Username blah not available</span>');
$('#register').attr("disabled", true);
} else {
$('#user-availability-status').html('<span>Username blah Available</span>');
$('#register').attr("disabled", false);
}
}
})
});
});
</script>
PHP file
<?php
if (isset($_POST["email_val"])) {
include("DbConn.php");
$email = mysqli_real_escape_string($conn, $_POST["email_val"]);
$query = "SELECT * FROM customer WHERE email = '" . $email . "'";
$result = mysqli_query($conn, $query);
echo mysqli_num_rows($result);
}

You should check link I refered in comment its your complete answer.
here is a Simple example with your code.
include("DbConn.php");
// Set alerts as array
$error = "";
// I should just trrim and let you check if email is empty .lol
if (empty($_POST["email_val"])) {
$error .= "<p class='error'>Fill email value.</p>";
//Check if this is a real email
} elseif(!filter_var($_POST["email_val"],FILTER_VALIDATE_EMAIL)){
$error .= "<p class='error'>Wrong email type.</p>";
}else{
$email = mysqli_real_escape_string($conn, $_POST["email_val"]);
//You should use prepare statement $email, Shame on you .lol
$query = "SELECT * FROM customer WHERE email = '{$email}'");
$result = mysqli_query($conn, $query);
echo mysqli_num_rows($result);
$error .= "ok";
}
$data = array(
'error' => $error
);
This Jquery :
$(document).ready(function(){
$('#myform').submit(function(event){
event.preventDefault();
var formValues = $(this).serialize();
$.ajax({
url:"includes\emailAvailability.php",
method:"POST",
data:formValues,
dataType:"JSON",
success:function(data){
if(data.error === 'ok'){
$('#result').html(data.error);
} else {
$('#result').html(data.error);
$('#myform')[0].reset();
}
}
});
});
});
And Html :
<form id="myform">
<input class="input--style-4" id="email" type="email" name="email_val">
<span id="result"></span>
<button type="button" class="btn btn-primary">Send</button>
</form>

you can use type:"POST" instead of method:"POST" I think work thanks

Related

Login redirect using jquery

i'll be glad if anyone can help out am working on a login system using jquery but i encounter a problem
what i want to achieve is user filling out their details on the login page and i'll process it using jQuery at the back end without reloading the page, i have achive that but the problem now is when the details they provide and the details in the database is correct i want to redirect them to another page
here is my login form
<form class="form-login" id="loginmyForm" method="post">
<input class="input input_auth" type="text" name="loginemail" id="loginemail" placeholder="E-mail" required />
<span id="loginError_username" class="error error-opacit"></span>
<input class="input input_auth" type="password" name="loginpassword" id="loginpassword" placeholder="Password" required />
<span id="loginError_password" class="error error-opacit"></span>
<input type="hidden" name="source" value="login" id="source">
<button class="btn pulse input_auth" type="button" id="submitFormData" onclick="loginSubmitFormData();" value="Submit">Login</button>
<div class="forgot-password">
<a id="forgotPass" href="#" class="link-btn open-modal" data-openModal="modal-recovery">Forgot your password?</a>
</div>
Here is jquery code
<script type="text/javascript">
function loginSubmitFormData() {
var loginemail = $("#loginemail").val();
var loginpassword = $("#loginpassword").val();
var source = $("#source").val();
$.post("authlogin.php", { loginemail: loginemail, loginpassword: loginpassword },
function(data) {
$('#loginresults').html(data);
$('#loginmyForm')[0].reset();
});
}
</script>
And here is the login authentication authlogin.php
<?php
session_start();
include 'config/info.php';
// get the details from form
$email=$_POST['loginemail'];
$password = stripslashes($_REQUEST['loginpassword']);
$password = mysqli_real_escape_string($conn,$password);
$sql="SELECT * FROM user_info WHERE email='".$email."'";
$result = mysqli_query($conn,$sql);
$Countrow = mysqli_num_rows($result);
if ($Countrow == 1) {
$fetchrow = mysqli_fetch_assoc($result);
$loginpassword = $fetchrow['password'];
// Verify the password here
if (password_verify($password, $loginpassword)) {
$_SESSION['email'] = $email;
//setcookie('username', $adminID, time() + (86400 * 30), "/");
$date = date('Y-m-d H:i:s');
$ActivityStmt = "INSERT INTO login_activity (`email`, `last_login`, `browser`, `os`, `ip_address`) VALUES('".$email."', '".$date."', '".$gen_userBrowser."', '".$gen_userOS."', '".$gen_userIP."')";
$ActivityResult = mysqli_query($conn, $ActivityStmt);
echo 'Login Successfully! Click to proceed';
exit();
}
else{
echo 'Incorrect Password';
exit();
}
}
else{
echo 'User does not exit';
exit();
}
?>
I have tried using
header('Location: account');
and
window.location.href = "account";
after the session is saved but none is working, please who can help me on how to get this done
You should try this jQuery Code and PHP Code by replacing them in your code section, It will definitely work for you:
<script type="text/javascript">
function loginSubmitFormData() {
var loginemail = $("#loginemail").val();
var loginpassword = $("#loginpassword").val();
var source = $("#source").val();
$.post("authlogin.php", { loginemail: loginemail, loginpassword: loginpassword },
function(data) {
var data = jQuery.parseJSON( data );
console.log(data);
$('#loginresults').html(data.message);
if(data.redirect_url){
window.location.href = data.redirect_url;
}
$('#loginmyForm')[0].reset();
});
}
</script>
<?php
session_start();
include 'config/info.php';
// get the details from form
$email=$_POST['loginemail'];
$password = stripslashes($_REQUEST['loginpassword']);
$password = mysqli_real_escape_string($conn,$password);
$sql="SELECT * FROM user_info WHERE email='".$email."'";
$result = mysqli_query($conn,$sql);
$Countrow = mysqli_num_rows($result);
if ($Countrow == 1) {
$fetchrow = mysqli_fetch_assoc($result);
$loginpassword = $fetchrow['password'];
// Verify the password here
if (password_verify($password, $loginpassword)) {
$_SESSION['email'] = $email;
//setcookie('username', $adminID, time() + (86400 * 30), "/");
$date = date('Y-m-d H:i:s');
$ActivityStmt = "INSERT INTO login_activity (`email`, `last_login`, `browser`, `os`, `ip_address`) VALUES('".$email."', '".$date."', '".$gen_userBrowser."', '".$gen_userOS."', '".$gen_userIP."')";
$ActivityResult = mysqli_query($conn, $ActivityStmt);
$message = 'Login Successfully!';
$response = array(
'message' => $message,
'redirect_url' => 'https://www.example.com',
);
exit();
}
else{
$message = 'Incorrect Password';
$response = array(
'message' => $message
);
exit();
}
}
else{
$message = 'User does not exit';
$response = array(
'message' => $message,
);
exit();
}
echo json_encode( $response);
?>

What is missing from this AJAX call code?

I apologize for not providing the full code for context, I am VERY new to this. Here is the code for the signup.php file:
<?php
session_start();
include('connection.php');
$missingUsername='<p><strong>Please enter a username</strong></p>';
$missingEmail='<p><strong>Please enter your email address</strong></p>';
$InvalidEmail='<p><strong>Please enter a valid email address</strong></p>';
$missingPassword='<p><strong>Please enter a password</strong></p>';
$InvalidPassword='<p><strong>Your password should be at least 6 characters long and include one capital letter and one number</strong></p>';
$differentPassword='<p><strong>Passwords don\'t match</strong></p>';
$missingPassword2='<p><strong>Please confirm your password</strong></p>';
if(empty($_POST["username"])){
$errors .= $missingUsername;
}else{
$username = filter_var($_POST["username"], FILTER_SANITIZE_STRING);
}
if(empty($_POST["email"])){
$errors .= $missingEmail;
}else{
$email = filter_var($_POST["email"], FILTER_SANITIZE_EMAIL);
if(!filter_var($email, FILTER_VALIDATE_EMAIL)){
$errors .= $InvalidEmail;
}
}
if(empty($_POST["password"])){
$errors .= $missingPassword;
}elseif(!(strlen($_POST["password"])>6 and preg_match('/[A-Z]/',$_POST["password"]) and preg_match('/[0-9]/',$_POST["password"]))){
$errors .= $InvalidPassword;
}else{
$password = filter_var($_POST["password"], FILTER_SANITIZE_STRING);
if(empty($_POST["password2"])){
$errors .= $missingPassword2;
}else{
$password2 = filter_var($_POST["password2"], FILTER_SANITIZE_STRING);
if($password !== $password2){
$errors .= $differentPassword;
}
}
}
if($errors){
$resultMessage = '<div class="alert alert-danger">' . $errors .'</div>'
echo $resultMessage;
}
$username = mysqli_real_escape_string($link, $username);
$email = mysqli_real_escape_string($link, $email);
$password = mysqli_real_escape_string($link, $password);
$password = hash('sha256', $password);
$sql = "SELECT * FROM users WHERE username = '$username'";
$result = mysqli_query($link, $sql);
if(!$result){
echo '<div class="alert alert-danger">Error running the query!</div>';
exit;
}
$results = mysqli_num_rows($result);
if($results){
echo '<div class="alert alert-danger">That username is already registered. Do you want to log in?</div>';
exit;
}
$sql = "SELECT * FROM users WHERE email = '$email'";
$result = mysqli_query($link, $sql);
if(!$result){
echo '<div class="alert alert-danger">Error running the query!</div>';
exit;
}
$results = mysqli_num_rows($result);
if($results){
echo '<div class="alert alert-danger">That email is already registered. Do you want to log in?</div>';
exit;
}
$activationKey = bin2hex(openssl_random_pseudo_bytes(16));
$sql = "INSERT INTO users ('username', 'email', 'password', 'activation') VALUES ('$username', '$email', '$password', '$activationKey')";
$result = mysqli_query($link, $sql);
if(!$result){
echo '<div class="alert alert-danger">There was an error inserting the user details in the database!</div>';
exit;
}
$message = "Please click on this link to activate your account:\n\n";
$message .= "http://studenttest.host20.uk/activate.php?email=" . urlencode($email) . "&key=$activationKey";
if(mail($email, 'Confirm your Registration', $message, 'From:'.'msyed0230#gmail.com')){
echo "<div class='alert alert-success'>Thank you for registration! Confirmation email has been sent to $email. Please click on the activation link to activate your account.</div>";
}
?>
Here again is the JS code block I'm working with within a broad goal of making a proper sign-up form:
$("#signupform").submit(function(event){
event.preventDefault();
var datatopost = $(this).serializeArray();
console.log(datatopost);
$.ajax({
url: "signup.php",
type: "POST",
data: datatopost,
success: function(data){
if(data){
$("#signupmessage").html(data);
}
},
error: function(){
$("#signupmessage").html("<div class='alert alert-danger'>There was an error with the Ajax call. Please try again later.</div>");
}
});
});
For some reason, I keep getting the AJAX error instead of the typical error messages I set up for username entry, password entry, etc. It is linked to the correct files (put in the script tag in my main index.php file) and with everything else.
What could be going on?
You might have an error in your signup.php page so it would be better if you put the whole code so as to find the issue and to fix it.
I've made a little example with almost the same code as yours and it works fine :
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" >
<div id="signupmessage"></div>
<form id="signupform" action="" method="POST">
<input type="text" name="firstname" placeholder="Enter your first name" /><br /><br />
<input type="text" name="lastname" placeholder="Enter your last name" /><br /><br />
<input type="submit" value="submit">
</form>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script type='text/javascript'>
$("#signupform").submit(function(event){
event.preventDefault();
var datatopost = $(this).serializeArray();
console.log(datatopost);
$.ajax({
url: "signup.php",
type: "POST",
data: datatopost,
success: function(data){
$("#signupmessage").html(data);
},
error: function(data){
$("#signupmessage").html(data);
}
});
});
</script>
--------- signup.php -----------
<?php
if(isset($_POST['firstname']) && isset($_POST['lastname'])){
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
echo $firstname."<br />";
echo $lastname;
}
else{
echo "<div class='alert alert-danger'>There was an error with the Ajax call. Please try again later.</div>";
}
?>

PHP Ajax not responding

In the username availability check I created two pages: register.php and registercontrol.php controlling it. I check the database connection its on work. Everything (all statements, insertin data into db) that was previously created on a single php page. But when ajax validates other inputs its duplicates the html content and shows the error inside of it instead of showing error messages in a just single html element.
So I seperated it into two pages but now ajax not shows any error and responds. Here is my work:
registercontrol.php
<?php
require('../includes/config.php');
if(isset($_POST['username'])){
//username validation
$username = $_POST['username'];
if (! $user->isValidUsername($username)){
$infoun[] = 'Your username must be at least 6 alphanumeric characters';
} else {
$stmt = $db->prepare('SELECT username FROM members WHERE username = :username');
$stmt->execute(array(':username' => $username));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if (! empty($row['username'])){
$errorun[] = 'This username already in use';
}
}
}
?>
register.php
<script type="text/javascript">
$(document).ready(function(){
$("#username").keyup(function(event){
event.preventDefault();
var username = $(this).val().trim();
if(username.length >= 3){
$.ajax({
url: 'registercontrol.php',
type: 'POST',
data: {username:username},
success: function(response){
// Show response
$("#uname_response").html(response);
}
});
}else{
$("#uname_response").html("");
}
});
});
</script>
<form id="register-form" class="user" role="form" method="post" action="registercontrol.php" autocomplete="off">
<input type="text" name="username" id="username" class="form-control form-control-user" placeholder="Username" value="<?php if(isset($error)){ echo htmlspecialchars($_POST['username'], ENT_QUOTES); } ?>" tabindex="2" required>
<div id="uname_response" ></div>
</form>
we need to print the response in registercontrol.php so that we can get response in your register.php
Change your code as below
<?php
require('../includes/config.php');
if(isset($_POST['username'])){
//username validation
$username = $_POST['username'];
if (! $user->isValidUsername($username)){
echo 'Your username must be at least 6 alphanumeric characters';
} else {
$stmt = $db->prepare('SELECT username FROM members WHERE username = :username');
$stmt->execute(array(':username' => $username));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if (! empty($row['username'])){
echo 'This username already in use';
}
}
}
?>
You need to return or echo something from registercontrol.php
<?php
require('../includes/config.php');
if(isset($_POST['username'])){
//username validation
$username = $_POST['username'];
if (! $user->isValidUsername($username)){
$infoun[] = 'Your username must be at least 6 alphanumeric characters';
echo json_encode($infoun);
exit;
} else {
$stmt = $db->prepare('SELECT username FROM members WHERE username = :username');
$stmt->execute(array(':username' => $username));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
if (! empty($row['username'])){
$errorun[] = 'This username already in use';
echo json_encode($errorun);
exit;
}
echo $row[username];
exit;
}
}
?>

My pdo ajax code for search is not working

What I want to do is: when a user types their email, my ajax code will run and show the user pass in the password inputbox.
The problem is that while my ajax code is sending the email to search.php, my search.php isn't giving the data to my ajax to show.
I think the problem is in my search.php because when i go to search.php after i type an email in my index the search.php is just blank no data is showing.
Index (Form):
email <input type="text" id="query" name="myemail" class="search_textbox" /><br />
Your Password <input type="text" id="mypass" name="mypass" readonly="readonly" /><br />
<script>
$(document).ready(function(){
$('.search_textbox').on('blur', function(){
$('#query').change(updateTextboxes);
updateTextboxes()
})
$('.search_textbox').on('keydown', function(){
$('#query').change(updateTextboxes);
updateTextboxes()
})
$('#query').change(updateTextboxes);
var $mypass = $('#mypass');
function updateTextboxes(){
$.ajax({
url:"search.php",
type:"GET",
data: { term : $('#query').val() },
dataType:"JSON",
success: function(result) {
var ii = 1;
for (var i = 0; i < result.length; i++) {
$mypass.val(result[i].value).show().trigger('input');
ii++;
}
}
});
};
});
</script>
search.php
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
$host = "localhost";
$user = "root";
$pass = "";
$db = "test";
$dbc = new PDO("mysql:host=" . $host . ";dbname=" . $db, $user, $pass);
$dbc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if (isset($_GET['term'])) {
$q = $_GET['term'];
$sql = "SELECT password FROM students WHERE email = :term";
$query = $dbc->prepare($sql);
$query->bindParam(':term', $q);
$results = $query->execute();
$data = array();
while ($row = $results->fetch()) {
$data[] = array(
'value' => $row['password']
);
}
header('Content-type: application/json');
echo json_encode($data);
}
?>
I noticed header('Content-type: application/json');. I don't think it is necessary. Remove the line and try again. I am not sure but I think php header is needed for a new page. Since you have echo json_encode($data); and in your AJAX call, you are already processing the return data as json, the header(...) is not needed.
EDIT
$q = $_GET['term'];
$sql = "SELECT password FROM students WHERE email = :term";
$query = $dbc->prepare($sql);
$query->bindParam(':term', $q);
if($query->execute() && $query->rowCount()){
echo json_encode($query->fetch(PDO::FETCH_ASSOC));
}
SCRIPT
function updateTextboxes(){
$.ajax({
url:"search.php",
type:"GET",
data: { term : $('#query').val() },
dataType:"JSON",
success: function(result) {
//check here if you have a result, if yes than...
$("#mypass").val(result.password);
}
}

How do I perform 2 AJAX requests on one form submit?

Short version:
I have code to insert a forms contents into a database
I have code to send the form data to Salesforce as a lead
Both of these work fine ALONE (If I change the form "action" to either of the PHP scripts) -- but when I attempt to combine them into 1 PHP script, the form invalidates and I can't figure out why.
Here's the code for inserting into DB:
<?php
include ".db_config.php";
/* open a connection to the database */
$link = connect_db();
/* grab all of the required fields */
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$pcode = $_POST['pcode'];
$terms = $_POST['terms'];
$news = $_POST['news'];
$facebookConnection = '0';
/* check to make sure it's valid email address */
$email = isset( $_POST['email'] ) ? preg_replace( "/[^\.\-\_\#a-zA-Z0-9]/", "", $_POST['email'] ) : "";
$language = $_POST['language'];
/* check to see if this was a facebook connection */
$facebookID = '';
if(isset($_POST['facebookID'])){
$facebookID = $_POST['facebookID'];
}
/* check to see if this signature connected to Facebook */
if($facebookID != ""){
$facebookConnection = '1';
}
/* set the true/false flag for the terms and conditions agreement. */
if ($terms == 'terms'){
$terms = 1;
}
else{
$terms = 0;
}
/* set the true/false flag for the updates sign up */
if($news =='news'){
$news = 1;
}
else {
$news =0;
}
$success='';
$error='';
// Check to see if the email exists already in the database
$query = "select count(*) as counting from signedUsers where eMailAddress ='$email'";
$result = do_query($query);
$emailIncluded = '0';
/* get the number of rows from the table where this email address is. */
while($row = mysql_fetch_array($result))
{
/* if there is 1 or more row, then the email exists. */
if ($row["counting"] > 0)
{
$emailIncluded = '1';
}
}
/* if the email address doesn't exist, save it and return 'success' */
if ($emailIncluded == '0'){
$insert = "insert into signedUsers (FirstName, LastName, eMailAddress, PostalCode, ToC,eMailUpdates, language, facebookID, FacebookConnection) values('$firstName','$lastName','$email', '$pcode', $terms, $news, '$language', '$facebookID', $facebookConnection)";// Do Your Insert Query
if(mysql_query($insert)) {
$success='1';
} else {
$error='failed insert';
}
}
/* if the email address exists, return 'error' to be dealt with on the front end that explains it. */
else {
$error = 'email exists';
$success = '';
}
$arr = array(
'success'=>$success,
'error'=>$error
);
if ($success == '1')
{
header('Content-Type: application/json');
$arr = array(
'success'=>$success,
);
echo json_encode($arr);
}
else
{
header('HTTP/1.1 500 Internal Server');
header('Content-Type: application/json');
//die('ERROR');
// or:
die(json_encode(array('message' => 'ERROR', code => $error)));
}
mysql_close($link);
?>
Here's the code to send to sailesforce:
<?php
$req = "&lead_source=" . urlencode($_GET["1"]);
$req .= "&first_name=" . urlencode($_GET["2"]);
$req .= "&last_name=" . urlencode($_GET["3"]);
$req .= "&zip=" . urlencode($_GET["4"]);
$req .= "&email=" . urlencode($_GET["5"]);
$req .= "&debug=" . urlencode("0");
$req .= "&oid=" . urlencode("00Di0000000fnSP");
$req .= "&retURL=" . urlencode("#");
$req .= "&debugEmail=" . urlencode("sam.stiles#orangesprocket.com");
$header = "POST /servlet/servlet.WebToLead?encoding=UTF-8 HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Host: www.salesforce.com\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
$fp = fsockopen ('www.salesforce.com', 80, $errno, $errstr, 30);
if (!$fp) {
echo "No connection made";
} else {
fputs ($fp, $header . $req);
while (!feof($fp)) {
$res = fgets ($fp, 1024);
echo $res;
}
}
fclose($fp);
?>
Again, these both work INDIVIDUALLY, bot not together in the same PHP file.
Here's the form & the AJAX:
//Setup contact form validation
jQuery('#petition-form').validate({
rules: {
firstName: "defaultInvalid",
lastName: "defaultInvalid",
email: "defaultInvalid",
email: "emailValid",
emailConfirm: "defaultInvalid",
emailConfirm: "emailValid",
pcode: "postalcode"
},
messages: {
firstName: "",
lastName: "",
email: "",
emailConfirm: "",
pcode: "",
terms: ""
},
errorLabelContainer: '#message',
onkeyup: false,
onfocusout: false,
onclick: false,
submitHandler: function(form){
//Serialize the form data
//Serialize the form data
var formData = jQuery('#petition-form').serialize();
//Send the form data to the script
jQuery.ajax({
type: 'POST',
url: '/resource/php/signThePetition.php',
data: formData,
dataType: 'json',
error: contactFormErrorMsg,
success: contactFormSuccessMsg
});
//Stop the form from refreshing the page on submit
return false;
}
});
});
//Contact form error messages
function contactFormErrorMsg() {
jQuery('#message').show();
jQuery('[name="emailConfirm"]').val('This email has already signed the petition. Thank you.');
return false;
/* this means that the email address already exists */
}
//Contact form success messages
function contactFormSuccessMsg() {
jQuery('input, select').removeClass('error').removeClass('valid');
jQuery('#petition-2').fadeOut();
jQuery('#petition-3').fadeIn();
resetForm(jQuery('#petition-form'));
}
// ]]>
</script>
<form name="petition-form" id="petition-form" action="/resource/php/sendEmail_contact.php" method="post">
<p id="message">There was an error in the form below. Please fix it before proceeding.</p>
<input type="text" name="firstName" placeholder="First name*" class="required short pad">
<input type="text" name="lastName" placeholder="Last name*" class="required short"><br />
<input type="text" name="email" id="email" placeholder="Email*" class="required email"><br />
<input type="text" name="emailConfirm" placeholder="Confirm email*" class="required email" equalTo="#email"><br />
<input type="text" name="pcode" placeholder="Postal code*" class="required short pad"><br />
<input type="checkbox" name="terms" value="terms" class="required"><span class="terms">I have read and agree to the terms and conditions</span><br />
<input type="checkbox" name="news" value="news" checked="checked">Send me updates and action alerts from Partners for Mental Health
<input type="hidden" name="language" id="language" value="en_US" class="required" ><br />
<input type="hidden" name="facebookID" id="facebookID" value="" class="required" >
<div id="form-buttons">
<button type="submit" value="Submit" name="submit" class="black-button">Submit</button>
</div>
</form>
Are you outputting HTTP headers twice when you combine the scripts?
Incidentally, there's no reason you can't fire off jQuery.ajax() twice in a row, once to each script.

Categories