social_experiment wrote:jonnyfortis wrote:without having to change the whole form, can i leave the jquery alerts and just have the save as that inputs the information to the db and the submit that sends the user to the payment page?
this is possible yes, you will just have to test which button was clicked but that is easy; the code for that is in the previous posts
ok i have added the code that you sent but it doesnt seem to be working.
i have included the code for the page.
<?php
error_reporting(E_ALL);
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
//$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if (isset($_POST['save']) && $_POST['save'] == 'Save form') {
// save button clicked, execute corresponding code
}
else {
// now the save button isn't clicked but you have to check if the
// submit button was clicked
if (isset($_POST['submit']) && $_POST['submit'] == 'Submit form') {
// submit button clicked, execute corresponding code
}
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
$insertSQL = sprintf("INSERT INTO plus_signup (terms, prop_id, StartDate, weeks, EndDate, Title, userid, password, sex, DOBDate, DOBMonth, DOBYear, Nationality, `Marital Status`, PhoneDay, PhoneEvening, PhoneMobile, email, Smoker, NextKin, CurrentAddress, PrevAddress, LivingStatus, Student, BankFinCCJ, BankFinArrears, BankFinBankR, BankFinNone, BankName, BankAccNum, BankSortCode, BankDuration, BankDCard, BankElectoral, LLName, LLTele, LLEmail, LLHost, LLAddress, GuName, GuTitle, GuDobDate, GuDobMonth, GuDobYear, GuSex, GuMarital, GuPhoneDay, GuPhoneEven, GuPhoneMob, GuPhoneEmail, GuCurrentAdd, GuPrevAdd, GuBankName, GuBankAccNu, GuBankSort, GuBankDurat, GuBankDebit, GuBankElect, GuEmpProffes, GuEmpAnnWa, GuEmpPayroll, GuSelfEmp, GuHaveAcc, GuAccName, GuAccContName, GuAccAdd, GuAccDayTel, GuAccMobTel, GuAccEmail, GuAccAdditional, GuEmployerNam, GuEmployerAdd, GuEmployerContactName, GuEmployerTele, GuEmployerEmail, GuEmployerCCj, GuEmployerArr, GuEmployerBankR, GuEmployerNone) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString(isset($_POST['terms']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['prop_id'], "text"),
GetSQLValueString($_POST['StartDate'], "text"),
GetSQLValueString($_POST['weeks'], "text"),
GetSQLValueString($_POST['EndDate'], "text"),
GetSQLValueString($_POST['Title'], "text"),
GetSQLValueString($_POST['userid'], "text"),
GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($_POST['sex'], "text"),
GetSQLValueString($_POST['DOBDate'], "text"),
GetSQLValueString($_POST['DOBMonth'], "text"),
GetSQLValueString($_POST['DOBYear'], "text"),
GetSQLValueString($_POST['Nationality'], "text"),
GetSQLValueString($_POST['Marital_Status'], "text"),
GetSQLValueString($_POST['PhoneDay'], "text"),
GetSQLValueString($_POST['PhoneEvening'], "text"),
GetSQLValueString($_POST['PhoneMobile'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['Smoker'], "text"),
GetSQLValueString($_POST['NextKin'], "text"),
GetSQLValueString($_POST['CurrentAddress'], "text"),
GetSQLValueString($_POST['PrevAddress'], "text"),
GetSQLValueString($_POST['LivingStatus'], "text"),
GetSQLValueString($_POST['Student'], "text"),
GetSQLValueString(isset($_POST['BankFinCCJ']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['BankFinArrears']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['BankFinBankR']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['BankFinNone']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString($_POST['BankName'], "text"),
GetSQLValueString($_POST['BankAccNum'], "text"),
GetSQLValueString($_POST['BankSortCode'], "text"),
GetSQLValueString($_POST['BankDuration'], "text"),
GetSQLValueString($_POST['BankDCard'], "text"),
GetSQLValueString($_POST['BankElectoral'], "text"),
GetSQLValueString($_POST['LLName'], "text"),
GetSQLValueString($_POST['LLTele'], "text"),
GetSQLValueString($_POST['LLEmail'], "text"),
GetSQLValueString($_POST['LLHost'], "text"),
GetSQLValueString($_POST['LLAddress'], "text"),
GetSQLValueString($_POST['GuName'], "text"),
GetSQLValueString($_POST['GuTitle'], "text"),
GetSQLValueString($_POST['GuDobDate'], "text"),
GetSQLValueString($_POST['GuDobMonth'], "text"),
GetSQLValueString($_POST['GuDobYear'], "text"),
GetSQLValueString($_POST['GuSex'], "text"),
GetSQLValueString($_POST['GuMarital'], "text"),
GetSQLValueString($_POST['GuPhoneDay'], "text"),
GetSQLValueString($_POST['GuPhoneEven'], "text"),
GetSQLValueString($_POST['GuPhoneMob'], "text"),
GetSQLValueString($_POST['GuPhoneEmail'], "text"),
GetSQLValueString($_POST['GuCurrentAdd'], "text"),
GetSQLValueString($_POST['GuPrevAdd'], "text"),
GetSQLValueString($_POST['GuBankName'], "text"),
GetSQLValueString($_POST['GuBankAccNu'], "text"),
GetSQLValueString($_POST['GuBankSort'], "text"),
GetSQLValueString($_POST['GuBankDurat'], "text"),
GetSQLValueString($_POST['GuBankDebit'], "text"),
GetSQLValueString($_POST['GuBankElect'], "text"),
GetSQLValueString($_POST['GuEmpProffes'], "text"),
GetSQLValueString($_POST['GuEmpAnnWa'], "text"),
GetSQLValueString($_POST['GuEmpPayroll'], "text"),
GetSQLValueString($_POST['GuSelfEmp'], "text"),
GetSQLValueString($_POST['GuHaveAcc'], "text"),
GetSQLValueString($_POST['GuAccName'], "text"),
GetSQLValueString($_POST['GuAccContName'], "text"),
GetSQLValueString($_POST['GuAccAdd'], "text"),
GetSQLValueString($_POST['GuAccDayTel'], "text"),
GetSQLValueString($_POST['GuAccMobTel'], "text"),
GetSQLValueString($_POST['GuAccEmail'], "text"),
GetSQLValueString($_POST['GuAccAdditional'], "text"),
GetSQLValueString($_POST['GuEmployerNam'], "text"),
GetSQLValueString($_POST['GuEmployerAdd'], "text"),
GetSQLValueString($_POST['GuEmployerContactName'], "text"),
GetSQLValueString($_POST['GuEmployerTele'], "text"),
GetSQLValueString($_POST['GuEmployerEmail'], "text"),
GetSQLValueString(isset($_POST['GuEmployerCCj']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['GuEmployerArr']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['GuEmployerBankR']) ? "true" : "", "defined","'Y'","'N'"),
GetSQLValueString(isset($_POST['GuEmployerNone']) ? "true" : "", "defined","'Y'","'N'"));
mysql_select_db($database_hostprop, $hostprop);
$Result1 = mysql_query($insertSQL, $hostprop) or die(mysql_error());
// Auto Login User
if (!isset($_SESSION)) {
session_start();
}
$_SESSION['MM_Username'] = $_POST['userid'];
$_SESSION['MM_UserGroup'] = "";
// Redirect user to make-payment.php
// With relevant POST Data
$post_data = array("amount"=>250,"type"=>"deposit");
$content_length = strlen($post_data);
$_SESSION['post_data'] = $post_data;
header("location:
http://www.hoststudent.co.uk/make-payment.php");
exit();
}
mysql_select_db($database_hostprop, $hostprop);
$query_rsApplyNow = "SELECT * FROM host_editprop WHERE available = 0";
$rsApplyNow = mysql_query($query_rsApplyNow, $hostprop) or die(mysql_error());
$row_rsApplyNow = mysql_fetch_assoc($rsApplyNow);
$totalRows_rsApplyNow = mysql_num_rows($rsApplyNow);
?>
<script type="text/javascript">
$().ready(function() {
// validate signup form on keyup and submit
$("#form2").validate({
rules: {
StartDate: "required",
EndDate: "required",
Nationality: "required",
PhoneDay: "required",
PhoneEvening: "required",
PhoneMobile: "required",
NextKin: "required",
CurrentAddress: "required",
PrevAddress: "required",
BankName: "required",
BankAccNum: "required",
BankSortCode: "required",
BankDuration: "required",
LLName: "required",
LLTele: "required",
LLEmail: "required",
LLAddress: "required",
GuName: "required",
GuPhoneDay: "required",
GuPhoneEven: "required",
GuPhoneMob: "required",
GuPhoneEmail: "required",
GuCurrentAdd: "required",
GuPrevAdd: "required",
GuBankName: "required",
GuBankAccNu: "required",
GuBankSort: "required",
GuBankDurat: "required",
GuEmpProffes: "required",
GuEmpAnnWa: "required",
GuEmpPayroll: "required",
GuAccName: "required",
GuAccContName: "required",
GuAccAdd: "required",
GuAccDayTel: "required",
GuAccMobTel: "required",
GuAccEmail: "required",
GuEmployerNam: "required",
GuEmployerAdd: "required",
GuEmployerContactName: "required",
GuEmployerTele: "required",
GuEmployerEmail: "required",
userid: {
required: true,
minlength: 2
},
password: {
required: true,
minlength: 5
},
email: {
required: true,
email: true
},
terms: "required"
},
messages: {
StartDate: "Please select a start date",
EndDate: "Please select an end date",
Nationality: "Please enter your nationality",
PhoneDay: "Please enter a daytime phone number",
PhoneEvening: "Please enter a evening phone number",
PhoneMobile: "Please enter a mobile number",
NextKin: "Please enter your next of kin",
CurrentAddress: "Please enter a current address",
PrevAddress: "Please enter a previous address",
BankName: "Please enter your bank name",
BankAccNum: "Please enter your account number",
BankSortCode: "Please enter your sort code",
BankDuration: "Please enter your bank duration",
LLName: "Please enter landlords name",
LLTele: "Please enter landlords telephone number",
LLEmail: "Please enter landlords email address",
LLAddress: "Please enter landlords address",
GuName: "Please enter guarantor name",
GuPhoneDay: "Please enter guarantor phone number",
GuPhoneEven: "Please enter guarantor evening number",
GuPhoneMob: "Please enter guarantor mobile number",
GuPhoneEmail: "Please enter guarantor email address",
GuCurrentAdd: "Please enter guarantor current address",
GuPrevAdd: "Please enter previous address",
GuBankName: "Please enter guarantor bank name",
GuBankAccNu: "Please enter guarantor account number",
GuBankSort: "Please enter guarantor sort code",
GuBankDurat: "Please enter guarantor bank duration",
GuEmpProffes: "Please enter guarantor proffesion",
GuEmpAnnWa: "Please enter guarantor annual wage",
GuEmpPayroll: "Please enter guarantor payroll number",
GuAccName: "Please enter guarantor accountant name",
GuAccContName: "Please enter guarantors accountant contact",
GuAccAdd: "Please enter guarantors accountants address",
GuAccDayTel: "Please enter guarantors accountants daytime numbers",
GuAccMobTel: "Please enter guarantors accountants mobile",
GuAccEmail: "Please enter guarantors accountants email",
GuAccAdditional: "Please enter guarantors accounts additional info",
GuEmployerNam: "Please enter guarantors employers name",
GuEmployerAdd: "Please enter guarantors employers address",
GuEmployerContactName: "Please enter guarantors employers contact",
GuEmployerTele: "Please enter enter guarantors employers number",
GuEmployerEmail: "Please enter guarantors employers email",
userid: {
required: "Please enter a user ID",
minlength: "Your username must consist of at least 2 characters"
},
password: {
required: "Please provide a password",
minlength: "Your password must be at least 5 characters long"
},
confirm_password: {
required: "Please provide a password",
minlength: "Your password must be at least 5 characters long",
equalTo: "Please enter the same password as above"
},
email: "Please enter a valid email address",
terms: "Please accept our policy"
}
});
$.metadata.setType("attr", "validate");
$(document).ready(function() {
$("#form2").validate();
$("#selecttest").validate();
});
});
</script>
<script type="text/javascript">
$(function(){
$('.date-pick').datepicker({ dateFormat: 'dd/mm/yy' });
$("input[name='weeks']").change(function() {
var start = $('input[name="StartDate"]').val();
var weeks = $('input:radio[name="weeks"]:checked').val();
var date = new Date(start);
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
myInteger = parseInt(weeks);
var edate= new Date(y, m, d+myInteger);
edate = edate.format("dd/mm/yyyy");
$('input[name="EndDate"]').val(edate);
});
});
</script>
<form class="cmxform"action="<?php echo $editFormAction; ?>" method="post" name="form2" id="form2">
<input type="hidden" name="MM_insert" value="form2" />
form content
<input type="submit" name="submit" value="submit form" />
<input type="submit" name="save" value="save form" />
</form>