form with two buttons one saving form other submit

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: form with two buttons one saving form other submit

Post by social_experiment »

jonnyfortis wrote:but obviously if they want to save the application they will not have to complete the form??
indeed; i realised this immediately after i made my previous post; You could generate a new form (which requires all fields to be filled in) if a username / password is already present, this wouldn't have a save button and the user would be obliged to complete it
jonnyfortis wrote:When they start the form the have to provide a username and password, this can be used to log back in and complete the form when needed
if i had to do this i would have 2 forms; one where a user can 'register' and a second one where details about the user can be entered at a later stage
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: form with two buttons one saving form other submit

Post by jonnyfortis »

social_experiment wrote:
jonnyfortis wrote:but obviously if they want to save the application they will not have to complete the form??
indeed; i realised this immediately after i made my previous post; You could generate a new form (which requires all fields to be filled in) if a username / password is already present, this wouldn't have a save button and the user would be obliged to complete it
jonnyfortis wrote:When they start the form the have to provide a username and password, this can be used to log back in and complete the form when needed
if i had to do this i would have 2 forms; one where a user can 'register' and a second one where details about the user can be entered at a later stage

ok this might the the only way of doing it, i think i am getting the form to do too much?
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: form with two buttons one saving form other submit

Post by jonnyfortis »

ok i have the what i call "manual form" working fine. i have put a default value in the db fields as required. We send to user login details, they then login and complete the form, if its not complete then they submit it and can go back in and make changes.(one thing to note is with the manual form they are not redirected to a payment page as they have already made payment manually)

but...i havent got the save and submit working...

i can do the same for the main form, where they as you say create a login first then go to the form....but with this form if they are complete they are sent to a payment page, if not complete they save and they are directed to the userpage.


does this make sense?
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: form with two buttons one saving form other submit

Post by social_experiment »

jonnyfortis wrote:does this make sense?
Honestly no;
jonnyfortis wrote:but...i havent got the save and submit working...
I think you should focus on this because all the details you are supplying is muddying the water for on this matter; do you have any code created for this matter at the moment?
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: form with two buttons one saving form other submit

Post by jonnyfortis »

social_experiment wrote:
jonnyfortis wrote:does this make sense?
Honestly no;
jonnyfortis wrote:but...i havent got the save and submit working...
I think you should focus on this because all the details you are supplying is muddying the water for on this matter; do you have any code created for this matter at the moment?
maybe it would be easier to send a link to both pages?

what do you think?
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: form with two buttons one saving form other submit

Post by jonnyfortis »

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?
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: form with two buttons one saving form other submit

Post by social_experiment »

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
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: form with two buttons one saving form other submit

Post by jonnyfortis »

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>
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: form with two buttons one saving form other submit

Post by jonnyfortis »

i have tried what was suggested but it still doesnt seem to work, can someone tell me where i am going wrong?
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: form with two buttons one saving form other submit

Post by social_experiment »

Code: Select all

<?php
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
}
?>
The code that does the work doesn't seem to be in the proper place; If you want something to happen when a certain button is clicked you need to place it in the prober conditional statements; It seems that you have just placed the code you had below the code you have received here;

The code you pasted is difficult to read; if you use the PHP Code button to wrap it in, it will be easier to read and easier to assist you :)
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: form with two buttons one saving form other submit

Post by jonnyfortis »

social_experiment wrote:

Code: Select all

<?php
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
}
?>
The code that does the work doesn't seem to be in the proper place; If you want something to happen when a certain button is clicked you need to place it in the prober conditional statements; It seems that you have just placed the code you had below the code you have received here;

The code you pasted is difficult to read; if you use the PHP Code button to wrap it in, it will be easier to read and easier to assist you :)

Im sorry I thought I embedded the code you gave me into the correct place

$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")) {



"The code you pasted is difficult to read; if you use the PHP Code button to wrap it in, it will be easier to read and easier to assist you :)"

sorry i didnt see the button, i will do that in future
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

Re: form with two buttons one saving form other submit

Post by jonnyfortis »

social_experiment wrote:

Code: Select all

<?php
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
}
?>
The code that does the work doesn't seem to be in the proper place; If you want something to happen when a certain button is clicked you need to place it in the prober conditional statements; It seems that you have just placed the code you had below the code you have received here;

The code you pasted is difficult to read; if you use the PHP Code button to wrap it in, it will be easier to read and easier to assist you :)

Code: Select all

<?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>
Post Reply