Forums

multiple page form?

samoht 27 Jun, 2008
hello,

I was wondering if there is a way to setup a multi-page form.

I have a form that will take shipping/billing info and cc info for authorize.net - and I wanted the user to be able to confirm the information at the end. (kinda like the virtuemart process)

Any ideas??

Thanks,
Andy
GreyHead 27 Jun, 2008
Hi Andy,

I've done this recently with a couple of forms. Is this one page to complete then another to confirm?

You can do that by using different values for Submit buttons. The form to be completed had a 'Submit' button, the confirm form had 'Edit' and 'Pay' buttons. The nuts and bolts of it are like this.

In the form HTML filed
// Check if the form is editable or not 
$readonly = "";
$edit = true;
if ( $result_array['submit'] && $result_array['submit'] == "Confirm" ) {
    $edit = false;
    $readonly = "readonly='readonly'";
}
we then use the $readonly variable to set the input fields to readonly (checkboxes and radio buttons are a bit more fiddly). The submit bottons look like:[code]if ( $edit ) {
?>
<div>
<input type="submit" name="submit" value="Submit" >
</div>
<?php
} else {
?>
<div>
<input type="submit" name="submit" value="Pay" >
samoht 27 Jun, 2008
Thanks for the help,

I tried to set up my code in a similar fashion - but now when I hit submit the form just reloads empty - and the "submit" button still shows? - when I turn debug on all my field names are there?
samoht 27 Jun, 2008
I wonder if the code in the 'On Submit before' should have "Pay" instead of 'Confirm' in line 2 of the code??
samoht 27 Jun, 2008
Well I've been messing around with the code snippets as posted - and the only thing I can think of that keeps this from going on to the confirm stage is the variable $result_array['submit']??

so I have attached a backup of the form to analyze [file name=giftcard.cfbak size=31133]http://www.chronoengine.com/images/fbfiles/files/giftcard.cfbak[/file]
GreyHead 28 Jun, 2008
Hi samoht,

Sorry, you can replace $result array with $_POST, I copy the results into a new array because it helps deal with some 'null' results like empty checkboxes.

Bob

Later: Removed square brackets as they break post formatting.
samoht 28 Jun, 2008
Thanks Bob,

I made that change and now pass through to the "Pay" "Edit" form with readonly inputs - but for some reason they are all blank.

is there more code that needs to be added to the "Submit" that will keep the data? Like so I need to put [code]<?php if(isset($_POST[..[/code] in the value field ??

Also How do I treat checkboxes since I have some on my form - and even more tricky is that I allow the user to select multiple checkbox values? Currently I have
value="checkbox[]" name=...


Thanks
GreyHead 29 Jun, 2008
Hi samoht,

Yes, you need to have some code in there to preserve the values. For input fields this needs to be like:
<?php echo $_POST['field_name']; ?>
for checkboxes it's tricker. Here's a snippet that I wrote for a pair of radio-boxes - it should extend Ok to checkboxes.[code] <div><label for='1_gender'>Gender </label>
<?php
// set checked field for radio buttons
$check = array('m' => '', 'f' => '');
foreach ($check as $k => $v ) {
if ( $k == $_POST['gender'] ) {
$check[$k] = "checked='checked'";
} elseif ( !$edit ) {
$check[$k] = "disabled='disabled'";
}
}
?>
<input name='gender' type='radio' id='gender_m' value='m'
<?php echo $check['m']; ?> />
samoht 01 Jul, 2008
Bob,

sorry to bother again, but in your sample code you have a different name for each radio
('gender' and 'gender]')
I am using about ten checkboxes and they all have the name
checkbox[]
-
but this doesn't seem to work with your example code.

I am trying to understand if your suggestion will work for an array or only for a 'either or' situation? [code]<?php
// set checked field(s) for checkboxes
$mark = array('50' => '', '75' => '', '100' => '', '125' => '', '150' => '', '200' => '', '250' => '', '300' => '', '500' => '', '750' => '', '1000' => '');
foreach ($check as $k => $v ) {
if ( $k == $_POST['checkbox'] ) {
$mark[$k] = "checked='checked'";
} elseif ( !$edit ) {
$mark[$k] = "disabled='disabled'";
}
}
?>
<td colspan="2" class="noborders">
<input type="checkbox" name="checkbox[]" value="50"
style="border:0;" <?php echo $mark['50'];?> />
$50
GreyHead 01 Jul, 2008
Hi samoht,

That stray square bracket was a typo. I simplified the code to paste it here - the original ahd a two dimensional array in there.

For your version you probably need to replace
 if ( $k == $_POST['checkbox'] )
with something like
 if ( in_array($k, $_POST['checkbox'] ) )
Not tested so I may have got the array indexes and values mixed up.

Bob
samoht 01 Jul, 2008
Thanks for the tip,

I dug around and found the syntax for in_array() which is:
bool in_array('value_to_find', array_to_lookin', bool[strict mode])

after getting errors I found that
if (sizeof($arr_to_searchin) == 0 || !in_array($value, $arr_to_searchin)) { ... }

will let you search through an empty array (which is what I have the first time around)

So I changed my code to:
<?php 
    // set checked field(s) for checkboxes 
    $mark = array('50' => '', '75' => '', '100' => '', '125' => '', '150' => '', '200' => '', '250' => '', '300' => '', '500' => '', '750' => '', '1000' => ''); 
	    foreach ($mark as $k => $v ) {  
	        if (sizeof($mark) == 0 || !in_array( $_POST['checkbox'], $mark )) { 
            $mark[$k] = "checked='checked'"; 
	        } elseif ( !$edit ) { 
            $mark[$k] = "disabled='disabled'"; 
        } 
    } 
?> 

Which seems to work except the second time through the form all of the checkboxes are checked.
if I change the array to lookin to $k I get as many errors as I have checkboxes and the first time around all the ckeckboxes are marked??

do you have any ideas??

Thanks
samoht 01 Jul, 2008
well I found a solution that also cleaned up my code a bit so I thought I would share it here if anyone might benefit:

[code] <tr>
<td colspan="2" class="noborders">
<?php
// set checked field(s) for checkboxes
$amounts = array(50,75,100,125,150,200,250,300,500,750,1000);
foreach ($amounts as $amount) {
echo '<input type="checkbox" name="checkbox[]" value="'.$amount.'" style="border:0;" ';
if (is_array($_POST['checkbox']) && in_array($amount,$_POST['checkbox']))
echo 'checked="checked" ';
elseif ( !$edit )
echo 'disabled="disabled"';
echo ' /> $'.$amount.'
GreyHead 01 Jul, 2008
Hi samoht,

Just back - that's pretty much what I would have given you I think. The is_array check also helps avoid some pesky PHP notices.

Bob
joeey 21 Jul, 2008
Hi,
I'm sorry for bringing up such an old post but I happen to be doing a form for my project using joomla and chrono forms. Its very easy to use but I'm required to add a confirmation page to the form. I'm new to programming and this is my first time touching joomla, php and chronoforms. I got lost after reading the second post and was wondering how to impliment it into my form. I tried pasting the codes on this post into my form but I got a blank page. Please go easy on me as I still do not know much about the terms and programming of chronoforms and joomla yet.
samoht 21 Jul, 2008
joeey,

maybe if you posted your form code we could help you a bit more.

The confrim page can be designed separately from the first page but all the code can be in the same php file by using a conditional statement you can tell if the user is visiting your form for the first time or if he needs to confirm what he filled out.

This little bit of code at the top of the "form HTML"
<?php
// Check if the form is editable or not  
$readonly = ""; 
$edit = true; 
if ( $_POST['submit'] && $_POST['submit'] == "Confirm" ) { 
  $edit = false; 
  $readonly = "readonly='readonly'"; 
}
?>
is what handles what the form will be (Confirm or input). Then you can add additional code to test if you are "Confirming" to display the posted info:[code]<?php if($_POST['fromname']){
?>
<div class="info">
<h3>From:</h3>
<p>
<?php echo $_POST['fromname'];?>
joeey 22 Jul, 2008
Hi, sorry to bother you again I would like to ask if those codes you provided me with will work out of the box. And thanks for the reply, you made it very understandable for a newbie like me.
samoht 22 Jul, 2008
hello joeey,

yes, the code provided can work out-of-the-box as it was taken directly from my working form. but I encourage you to go through the steps of setting up your form as you need it and then working on plugging in the right php code. Chronos is actually quite easy to use once you get used to it.
joeey 22 Jul, 2008
Hi, I've changed the codes to suit my form but it seems there are some problems with it. When I click submit, the data would be submitted into the database instead of showing the confirmation page. It does the same when I click on the edit button. This is the code I've used for my form.

[code]<?php
// Check if the form is editable or not
$readonly = "";
$edit = true;
if ( $_POST['submit'] && $_POST['submit'] == "Confirm" ) {
$edit = false;
$readonly = "readonly='readonly'";
}
?>

<p align="center">Name:
<input type="text" name="username" />
</p>
<p align="center">Admin No.:
<input type="text" name="admin" />
</p>
<p align="center">Gender:
<select name="gender">
<option value="Male" selected>Male</option>
<option value="Female">Female</option>
</select>
</p>
<p align="center">Address:
<textarea name="address" cols="40"></textarea />
</p>
<p align="center">Home Phone:
<input type="text" name="hometel" /> <br>
</p>
<p align="center">Mobile Phone:
<input type="text" name="hp" />
</p>
<p align="center">Contact Email:
<input type="text" name="email" /> <br>
</p>
<p align="center">Course:
<select name="course">
<option value="ECC">ECC</option>
</select>
</p>
<p align="center">Acad Year:
<input type="text" name="year" />
</p>
<p align="center">Path:
<select name="path">
<option value="1">B1</option>
<option value="2">B2</option>
<option value="3">B3</option>
</select>
</p>
<p align="center">Project Title:
<textarea name="title" cols="40"></textarea>
</p>
<p align="center">Project Supervisor:
<select name="supervisor">
<option value="Mr. Stephen Liew K C" selected>Mr. Stephen Liew K C</option>
<option value="Mr. Steven Ng">Mr. Steven Ng</option>
</select>
</p>
<p align="center">


<?php
if($_POST['username']){
?>
<div class="info"> <h3>From:</h3> <p>
<?php echo $_POST['admin'];?>
joeey 22 Jul, 2008
Hi again, I've tried doing the form and the comfirmation page via a simpler way as I'm quite short on time. I've created a form and create a "confirmation form" using chronoform. The $_POST data can be read on the confirmation form but it can't be saved into the database.
Here is the code for the confirmation form:

<?php

echo'<div align="center">';
echo '<p>Name:  '.$_POST["username"].' <br />';
echo 'Admin No.:  '.$_POST["admin"].' <br />';
echo 'Gender:  '.$_POST["gender"].' <br />';
echo 'Address: '.$_POST["address"].' <br />';
echo 'Home Phone:  '.$_POST["hometel"].' <br />';
echo 'Handphone: '.$_POST["hp"].' <br />';
echo 'Contact Email:  '.$_POST["email"].' <br />';
echo 'Course: '.$_POST["course"].' <br />';
echo 'Acad Year: '.$_POST["year"].' <br />';
echo 'Path: '.$_POST["path"].' <br />';
echo 'Project title:'.$_POST["title"].' <br />';
echo 'Project Supervisor: '.$_POST["supervisor"].' <br />';



$_POST["username"] = $username;
$_POST["admin"] = $admin;
$_POST["gender"] = $gender;
$_POST["address"] = $address;
$_POST["hometel"] = $hometel;
$_POST["hp"] = $hp;
$_POST["email"] = $email;
$_POST["course"] = $course;
$_POST["year"] = $year;
$_POST["title"] = $title;
$_POST["supervisor"] = $supervisor;
?>
<p>
    <input type="submit" name="Submit" value="Submit">
	</form>
</p>
  <p>
    <input name="button" type=button onClick=window.history.back() value=Back back>
  </p>
GreyHead 22 Jul, 2008
Hi joeey,

That's because there isn't any *form* data to save, all you have in here is a submit button, if you turn debug on I think that you will see that the $_POST array that is returned to ChronoForms is empty.

Put the variables in hidden fields if you want to go this route.

Bob
samoht 22 Jul, 2008
joeey,

Bob is correct - you need to do something like this:
[code]
<?php
// Check if the form is editable or not
$readonly = "";
$edit = true;
if ( $_POST['submit'] && $_POST['submit'] == "Confirm" ) {
$edit = false;
$readonly = "readonly='readonly'";
}
?>

<?php if($_POST['fromname']){
//this is where you display the data to be confirmed and style the way you like
echo'<div align="center">';
echo '<p>Name: '.$_POST["username"].' <br />';
echo 'Admin No.: '.$_POST["admin"].' <br />';
echo 'Gender: '.$_POST["gender"].' <br />';
echo 'Address: '.$_POST["address"].' <br />';
echo 'Home Phone: '.$_POST["hometel"].' <br />';
echo 'Handphone: '.$_POST["hp"].' <br />';
echo 'Contact Email: '.$_POST["email"].' <br />';
echo 'Course: '.$_POST["course"].' <br />';
echo 'Acad Year: '.$_POST["year"].' <br />';
echo 'Path: '.$_POST["path"].' <br />';
echo 'Project title:'.$_POST["title"].' <br />';
echo 'Project Supervisor: '.$_POST["supervisor"].' <br /></div>';
//now you need to have hidden input's to store and re-POST your data

echo '<input name="username" type="hidden" value="'.$_POST["username"].'" /><br />';
echo '<input name="admin" type="hidden" value="'.$_POST["admin"].'" /> <br />';
echo '<input name="gender" type="hidden" value="'.$_POST["gender"].'" /> <br />';
echo '<input name="address" type="hidden" value="'.$_POST["address"].'" /> <br />';
echo '<input name="hometel" type="hidden" value="'.$_POST["hometel"].'" /> <br />';
echo '<input name="hp" type="hidden" value="'.$_POST["hp"].'" /> <br />';
echo '<input name="email" type="hidden" value="'.$_POST["email"].'" /> <br />';
echo '<input name="course" type="hidden" value="'.$_POST["course"].'" /> <br />';
echo '<input name="year" type="hidden" value="'.$_POST["year"].'" /> <br />';
echo '<input name="path" type="hidden" value="'.$_POST["path"].'" /> <br />';
echo '<input name="title" type="hidden" value="'.$_POST["title"].'" /> <br />';
echo '<input name="supervisor" type="hidden" value="'.$_POST["supervisor"].'" /> <br />';
} else {
// now you need the original and edit state of the form here...
?>

<p align="center">Name:
<input type="text" name="username" />
</p>
<p align="center">Admin No.:
<input type="text" name="admin" />
</p>
<p align="center">Gender:
<select name="gender">
<option value="Male" selected>Male</option>
<option value="Female">Female</option>
</select>
</p>
<p align="center">Address:
<textarea name="address" cols="40"></textarea />
</p>
<p align="center">Home Phone:
<input type="text" name="hometel" /> <br>
</p>
<p align="center">Mobile Phone:
<input type="text" name="hp" />
</p>
<p align="center">Contact Email:
<input type="text" name="email" /> <br>
</p>
<p align="center">Course:
<select name="course">
<option value="ECC">ECC</option>
</select>
</p>
<p align="center">Acad Year:
<input type="text" name="year" />
</p>
<p align="center">Path:
<select name="path">
<option value="1">B1</option>
<option value="2">B2</option>
<option value="3">B3</option>
</select>
</p>
<p align="center">Project Title:
<textarea name="title" cols="40"></textarea>
</p>
<p align="center">Project Supervisor:
<select name="supervisor">
<option value="Mr. Stephen Liew K C" selected>Mr. Stephen Liew K C</option>
<option value="Mr. Steven Ng">Mr. Steven Ng</option>
</select>
</p>

<?php
}
if ( $edit ) {
//and finally you have your buttons to determine the action the form should take
?>
<div>
<input type="submit" name="submit" value="Submit" >
GreyHead 22 Jul, 2008
Hi Joeey,

That's good, or you can combine the two parts by toggling readonly on and off. In short:
<?php   
// Check if the form is editable or not   
$readonly = "";   
$edit = true;   
if ( $_POST['submit'] && $_POST['submit'] == "Confirm" ) {   
  $edit = false;   
  $readonly = "readonly='readonly'";   
}   
?>
<label>Name: <input type="text" name="username" 
  <?php echo 'value="'.$_POST["path"].'" '.$readonly; ?> /></label> 
. . .
?>
joeey 23 Jul, 2008
Hi everyone, first of all I would like to thank samoht and Bob for your wonderful help. This is one of the best forums I've been to where people are so eager to help. But I've tried the codes and there seems to be an error. I've changed the codes alittle by inserting my form into the code. Using samoht codes purely would result in a blank page. I've tried integrating Bob's code with Samoht and alittle of mine and now it displays the confirmation page directly instead of showing the input page. Clicking on Submit and edit sends the data into the database. I wonder if the codes are acting weird due to problems on my side like improper installation or due to me using IIS as my webserver. Lastly could you guys tell me where I can learn more about joomla and chronoform ? My knowledge is on those two are really bad and I wish to learn more so that I do not need to bother anyone.

Here is the modified codes I'm currently using:
[code]<?php
// Check if the form is editable or not
$readonly = "";
$edit = true;
if ( $_POST['submit'] && $_POST['submit'] == "Confirm" ) {
$edit = false;
$readonly = "readonly='readonly'";
}
?>
<p align="center">
<label>Name: <input type="text" name="username"
<?php echo 'value="'.$_POST["path"].'" '.$readonly; ?> />
</p></label><p align="center">Admin No.:

<input type="text" name="admin" />
</p>
<p align="center">Gender:
<select name="gender">
<option value="Male" selected>Male</option>
<option value="Female">Female</option>
</select>
</p>
<p align="center">Address:
<textarea name="address" cols="40"></textarea />
</p>
<p align="center">Home Phone:
<input type="text" name="hometel" /> <br>
</p>
<p align="center">Mobile Phone:
<input type="text" name="hp" />
</p>
<p align="center">Contact Email:
<input type="text" name="email" /> <br>
</p>
<p align="center">Course:
<select name="course">
<option value="ECC">ECC</option>
</select>
</p>
<p align="center">Acad Year:
<input type="text" name="year" />
</p>
<p align="center">Path:
<select name="path">
<option value="1">B1</option>
<option value="2">B2</option>
<option value="3">B3</option>
</select>
</p>
<p align="center">Project Title:
<textarea name="title" cols="40"></textarea>
</p>
<p align="center">Project Supervisor:
<select name="supervisor">
<option value="Mr. Stephen Liew K C" selected>Mr. Stephen Liew K C</option>
<option value="Mr. Steven Ng">Mr. Steven Ng</option>
</select>
</p>
<p align="center">
>
<?php if($_POST['fromname'])
{ //this is where you display the data to be confirmed and style the way you like
echo'<div align="center">';
echo '<p>Name: '.$_POST["username"].' <br />';
echo 'Admin No.: '.$_POST["admin"].' <br />';
echo 'Gender: '.$_POST["gender"].' <br />';
echo 'Address: '.$_POST["address"].' <br />';
echo 'Home Phone: '.$_POST["hometel"].' <br />';
echo 'Handphone: '.$_POST["hp"].' <br />';
echo 'Contact Email: '.$_POST["email"].' <br />';
echo 'Course: '.$_POST["course"].' <br />';
echo 'Acad Year: '.$_POST["year"].' <br />';
echo 'Path: '.$_POST["path"].' <br />';
echo 'Project title:'.$_POST["title"].' <br />';
echo 'Project Supervisor: '.$_POST["supervisor"].' <br /></div>';
//now you need to have hidden input's to store and re-POST your data
echo '<input name="username" type="hidden"
value="'.$_POST["username"].'" /><br />';
echo '<input name="admin" type="hidden"
value="'.$_POST["admin"].'" /> <br />';
echo '<input name="gender" type="hidden"
value="'.$_POST["gender"].'" /> <br />';
echo '<input name="address" type="hidden"
value="'.$_POST["address"].'" /> <br />';
echo '<input name="hometel" type="hidden"
value="'.$_POST["hometel"].'" /> <br />';
echo '<input name="hp" type="hidden"
value="'.$_POST["hp"].'" /> <br />';
echo '<input name="email" type="hidden"
value="'.$_POST["email"].'" /> <br />';
echo '<input name="course" type="hidden"
value="'.$_POST["course"].'" /> <br />';
echo '<input name="year" type="hidden"
value="'.$_POST["year"].'" /> <br />';
echo '<input name="path" type="hidden"
value="'.$_POST["path"].'" /> <br />';
echo '<input name="title" type="hidden"
value="'.$_POST["title"].'" /> <br />';
echo '<input name="supervisor" type="hidden"
value="'.$_POST["supervisor"].'" /> <br />';
} else {
// now you need the original and edit state of the form here...
?>
<?php
}
if ( $edit ) {
//and finally you have your buttons to determine the action the form should take
?>
<div> <input type="submit" name="submit" value="Submit" >
joeey 23 Jul, 2008
Hi, sorry to bother you again but I would like to ask how do you preserve the input data so that if you go to the 2nd page and click back again, the data would still be in the text box ? Currently I'm using
onClick=window.history.back() 
to go back to the form. I'm currently using a very simple form which links to the confirmation form. Its extremely simple and there might be a huge flaw in it but I'm short on time as I need to hand in a report about this next week. I'm currently trying to find the function stated above and studying your codes so that I can make a better form and hopeful use it before I need to show it to my supervisor.

Here is the code for my confirmation form. If you stop any flaws please tell me. Thank you.

<?php
echo'<div align="center">';
echo '<p>Name:  '.$_POST["username"].' <br />';
echo 'Admin No.:  '.$_POST["admin"].' <br />';
echo 'Gender:  '.$_POST["gender"].' <br />';
echo 'Address: '.$_POST["address"].' <br />';
echo 'Home Phone:  '.$_POST["hometel"].' <br />';
echo 'Handphone: '.$_POST["hp"].' <br />';
echo 'Contact Email:  '.$_POST["email"].' <br />';
echo 'Course: '.$_POST["course"].' <br />';
echo 'Acad Year: '.$_POST["year"].' <br />';
echo 'Path: '.$_POST["path"].' <br />';
echo 'Project title:'.$_POST["title"].' <br />';
echo 'Project Supervisor: '.$_POST["supervisor"].' <br />';

echo '<input name="username" type="hidden" 
  value="'.$_POST["username"].'" /><br />';
 echo '<input name="admin" type="hidden" 
  value="'.$_POST["admin"].'" /> <br />';
 echo '<input name="gender" type="hidden" 
  value="'.$_POST["gender"].'" /> <br />';
 echo '<input name="address" type="hidden" 
  value="'.$_POST["address"].'" /> <br />';
 echo '<input name="hometel" type="hidden" 
  value="'.$_POST["hometel"].'" /> <br />';
 echo '<input name="hp" type="hidden" 
  value="'.$_POST["hp"].'" /> <br />'; 
echo '<input name="email" type="hidden" 
  value="'.$_POST["email"].'" /> <br />'; 
echo '<input name="course" type="hidden" 
  value="'.$_POST["course"].'" /> <br />';
 echo '<input name="year" type="hidden"  
  value="'.$_POST["year"].'" /> <br />'; 
echo '<input name="path" type="hidden" 
  value="'.$_POST["path"].'" /> <br />'; 
echo '<input name="title" type="hidden" 
  value="'.$_POST["title"].'" /> <br />'; 
echo '<input name="supervisor" type="hidden"
  value="'.$_POST["supervisor"].'" /> <br />';
?>
<p>
    <input type="submit" name="Submit" value="Submit">
	</form>
</p>
  <p>
    <input name="button" type=button onClick=window.history.back() value=Back back>
  </p>
GreyHead 23 Jul, 2008
Hi joeey,

A back button doesn't normally preserve form entries so I'm not quite sure what you are asking here.

If there was already data in the $_POST array then this will be redisplayed though.

Bob

PS For more information on Joomla you should check out the docs at Joomla.org. Joomla 1.5 is still very new and docs for that are patchy but improving. The best (only) info on ChronoForms is here - but much of this is PHP and you can find PHP lessons at w3schools or php.net.
samoht 23 Jul, 2008
Hi joeey,

I realized that I left in a field from my code in the conditional.

(i.e. if you change <?php if($_POST['fromname']){ to something with one of your field names like <?php if($_POST['username']){ Then the code I posted should work fine as is... technically I think you can just put <?php if($_POST) { and avoid field names all-together )

What Bob was suggesting is a time/code saver but not as easy to style with CSS since all your data is inside an input. For my client they wanted a particular look to the confirmation page that would have been tedious work to try styling the readonly inputs.

So my advise is to try understanding the code bit by bit. Ask questions when you don't understand what something does. When you mix and match your code can get confusing and hard to fix when it breaks.

Concerning a "back button" - the code I posted has an "edit" button which will take you back to the form with all the data intact. $_POST is the php dumping container for your data from you form. When you first go to your form $_POST will be empty, because nothing is filled out. When you fill out the form $_POST will contain what ever you filled out - the action of the form will determine what you do with that $_POST data. If you have a confirm page (like we are describing here) then $_POST will empty out the stored data back into your form (same goes for edit page) so $_POST is now empty again but the form will look full. That is why you need to have an input will a value somewhere on your confirm page to repost or fill $_POST back up before finaly submitting the form data. (You probably know all this, but it can't hurt)
joeey 25 Jul, 2008
To samoht : Thanks for the information. I would like you to help me verify if my knowledge on your codes are correct. First of,
<?php
// Check if the form is editable or not  
$readonly = ""; 
$edit = true; 
if ( $_POST['submit'] && $_POST['submit'] == "Confirm" ) { 
  $edit = false; 
  $readonly = "readonly='readonly'"; 
}


The above codes means that unless I click submit twice, the code won't be submitted right ?
Second would be,
<?php
}
if ( $edit ) { 
?> 
<div> 
<input type="submit" name="submit" value="Submit" > 
  
<input type="reset" value="Reset Form">
</div> 

Does this means that if edit is true it would display Submit and Reset ?
Also I've manage to get part of the code working. It is able to display the form and confirmation page correctly. However when I click on edit on the confirmation page, it brings me back to the form page but instead of the form, It show the information from the confirmation page. This is the code I've used to display the form :

<?php if($_POST['username'] == ""){ 
?>

Do you know how I can solve this ?
Thanks for helping me out.

To Bob,

Sorry for not stating clearly. What I meant was if you submit a form and it goes to the confirmation page. And you spot an error on the confirmation page. Clicking on the edit button or back button brings you back to the form. I would like the information remain in the form's textbox when you go back. Is it possible ? Thanks.

Edit: I've recently stumbled accross this code
$my = & JFactory::getUser();

if($my->id){

foreach($fields as $i=>$field){

if($field->name=='fullname') $fields->default_value = $my->name; //Assuming your rsform text field is called
"fullname"

if($field->name=='email') $fields->default_value = $my->email; //Assuming your rsform email text field is called
"email"

}

}

Can this code be used in Chrono ? I've tried searching but only one topic came up and it did not show how to use the code.
GreyHead 25 Jul, 2008
Hi joeey,

Yes, sure you can set it up so that the Edit button shows you an editable form with your data in it. That's what the code that I posted right at the beginning of this thread was designed to do (though it may have suffered a bit in being simplifed to post here). I don't know about the browser back button though - that's less reliable than having a controlled 'Edit' button.

And the code you posted from RSForms should work OK - provided that you have a $fields array to cycle through.

Bob
samoht 25 Jul, 2008
hi joeey,
yes, the first bit of code means that you wont submit the form until you go through it twice (at least).

the second question reveals that I forgot to add something to the conditional statement so that edit take you where you want to go. All you need is a litte !$edit
So it would look like this for you:
<?php if (!$edit && $_POST['username']) { 

BTW you dont need to say == " " - because this check if the field is empty and php will use NULL as " " so in the condition
if($_POST['whatever']) - you are already checking if the field is empty. if it is empty you wont execute the code after your condition.
Also a ! is a negation so !$edit = means "your not in edit mode".

Hope this helps
joeey 28 Jul, 2008
To Bob,
Hi, I would like to ask something regarding about the codes you have posted previously. If I were to include my form $_POST variables into your code which I think is suppose to look like this can it work ? Or am I missing out on something ?
<?php   
// Check if the form is editable or not   
$readonly = "";   
$edit = true;   
if ( $_POST['submit'] && $_POST['submit'] == "Confirm" ) {   
  $edit = false;   
  $readonly = "readonly='readonly'";   
}   
if ($edit) { 
?>
<label>Name: <input type="text" name="username" 
  <?php echo 'value="'.$_POST["username"].'" '.$readonly; ?> /></label> 
<label>Name: <input type="text" name="admin" 
  <?php echo 'value="'.$_POST["admin"].'" '.$readonly; ?> /></label>
<p align="center">Gender:
  <select name="gender">
    <option value="Male" selected>Male</option>
    <option value="Female">Female</option>
      </select>
</p>
<label>Name: <input type="text" name="address" 
  <?php echo 'value="'.$_POST["address"].'" '.$readonly; ?> /></label></br>
<label>Name: <input type="text" name="hometel" 
  <?php echo 'value="'.$_POST["hometel"].'" '.$readonly; ?> /></label></br>
<label>Name: <input type="text" name="hp" 
  <?php echo 'value="'.$_POST["hp"].'" '.$readonly; ?> /></label></br>
<label>Name: <input type="text" name="email" 
  <?php echo 'value="'.$_POST["email"].'" '.$readonly; ?> /></label></br>
<p align="center">Course:
<select name="course">
  <option value="ECC">ECC</option>
</select>
</p></br>
<label>Name: <input type="text" name="year" 
  <?php echo 'value="'.$_POST["year"].'" '.$readonly; ?> /></label></br>
<p align="center">Path:
<select name="path">
  <option value="1">B1</option>
  <option value="2">B2</option>
  <option value="3">B3</option>
</select>
</p></br>
<label>Name: <input type="text" name="title" 
  <?php echo 'value="'.$_POST["title"].'" '.$readonly; ?> /></label></br>
<p align="center">Project Supervisor:
<select name="supervisor">
  <option value="Mr. Stephen Liew K C" selected>Mr. Stephen Liew K C</option>
  <option value="Mr. Steven Ng">Mr. Steven Ng</option>
</select>
</p></br>
<p align="center">
<?php
}
?>

Thanks.

To Samoht,
Hi, currently the form is working as it should by using <?php if ($edit) { ?> above my form codes. I would also like to enquire about the codes you have posted. The codes are suppose to be posted before the form am I right ? If so doesn't the !edit prevent the form from being displayed? Sorry If I'm wrong as I'm alittle confused about the codes.
GreyHead 28 Jul, 2008
Hi joeey,

I think that should work OK.

Bob

PS (You had an extra ?> tag near the first if statement that would cause problems. I edited it out.)
samoht 28 Jul, 2008
Hi joeey,

yes the condition goes before the form the way I posted it, but it doesn't have too if you write the condition correctly.

Here is what I mean:
The first thing the form(page) should see is the php code that checks if you have submitted the form already or not. Thus Bob's first bit of code sets $readonly to blank and $edit to true because it is the first time through, or if the condition is met it sets $readonly to "readonly" and $edit to false because you must be confirming the page not editing it.

Now that your into the form and the form knows what mode it should be in you have to determine what to show the end user. If you want the confirm page not to look like a bunch of input boxes - but more like a finalized invoice or document - then you can use the set up I suggested (with hidden inputs) and in that case you need the condition before that code that asks if we are in edit mode or not. If not (i.e. !$edit) then show the confirm page with hidden inputs - if we are in edit mode (i.e. if($edit)) then you show the editable form with showing inputs.

does that help?
joeey 31 Jul, 2008
Hi sorry for posting so late, I'm currently busy writing a report on my project. Thanks samoht for the info. I'm would like to ask perhaps one final question as I'm handing up this form and doing a presentation on it soon. The data in the textbox are displayed correctly but the data in the drop down list always revert to its default selection. http://www.plus2net.com/php_tutorial/pb-drop.php?t1=Tue can I use the codes in the website in my form ?
GreyHead 31 Jul, 2008
Hi joeey,

Here's a full div for a select box that 'remembers' values:
<div class="optional">
<label for="contact_pref"
	class='labelSelect'>I prefer to be contacted by: </label>
<select name="contact_pref" size="1" id="contact_pref">
<?php
    // set a default value.
    if ( !$result_array['contact_pref'] ) {
        $result_array['contact_pref'] = "phone";
    }
    // check for selected values
    $cpref_array = array("phone" => "Telephone", "email" => "Email", "post" => "Postal");
    foreach ( $cpref_array as $cpref => $title ) {
        if ( $cpref == $result_array['contact_pref'] ) {
            $s = "selected='selected'";
        } else {
            $s = "";
        }
        echo "<option value='$cpref' $s >$title</option>";
    }
?>
</select></div>
NB $result_array has values for all fields in the form - the values from the last submission, or default/stored values if nothing was submitted. This avoids some potential PHP notices and warnings.

Bob
joeey 01 Aug, 2008
Hi Bob,
I've used your codes but the problem still occurs. I've changed the values to suit my form so perhaps it could be due to me. I'm including the codes for the whole form as there might be something in the form conflicting with the codes.
<?php   
// Check if the form is editable or not   
$readonly = "";   
$edit = true;   
if ( $_POST['submit'] && $_POST['submit'] == "Confirm" ) {   
  $edit = false;   
  $readonly = "readonly='readonly'";   
}   
if ($edit) { 
?>
<p align="left">
<label>Name: <input type="text" name="username" 
  <?php echo 'value="'.$_POST["username"].'" '.$readonly; ?> /></label> </br>
<label>Admin: <input type="text" name="admin" 
  <?php echo 'value="'.$_POST["admin"].'" '.$readonly; ?> /></label>
</p>
<div class="optional">
<label for="Gender"
   class='labelSelect'>Gender: </label>
<select name="gender" size="1" id="gender">
<?php
    // set a default value.
    if ( !$result_array['gender'] ) {
        $result_array['gender'] = "male";
    }
    // check for selected values
    $cpref_array = array("male" => "Male", "female" => "Female");
    foreach ( $cpref_array as $cpref => $title ) {
        if ( $cpref == $result_array['gender'] ) {
            $s = "selected='selected'";
        } else {
            $s = "";
        }
        echo "<option value='$cpref' $s >$title</option>";
    }
?>
</select></div>
<p align="left">
<label>Address: <input type="text" name="address" 
  <?php echo 'value="'.$_POST["address"].'" '.$readonly; ?> /></label></br>
<label>Home Telephone: <input type="text" name="hometel" 
  <?php echo 'value="'.$_POST["hometel"].'" '.$readonly; ?> /></label></br>
<label>Handphone Number: <input type="text" name="hp" 
  <?php echo 'value="'.$_POST["hp"].'" '.$readonly; ?> /></label></br>
<label>Email: <input type="text" name="email" 
  <?php echo 'value="'.$_POST["email"].'" '.$readonly; ?> /></label></br>
</p>
<p align="left">Course:
<select name="course">
  <option value="ECC">ECC</option>
  <option value="MIT">MIT</option>
  <option value="MF">MF</option>
</select>
</p>
<p align="left">
<label>Year: <input type="text" name="year" 
  <?php echo 'value="'.$_POST["year"].'" '.$readonly; ?> /></label></br>
</p>
<p align="left">Path:
<select name="path">
  <option value="1">B1</option>
  <option value="2">B2</option>
  <option value="3">B3</option>
  
</select>
</p>
<p align="left">
<label>Title: <input type="text" name="title" 
  <?php echo 'value="'.$_POST["title"].'" '.$readonly; ?> /></label></br>
</p>
<p align="left">Project Supervisor:
<select name="supervisor">
  <option value="Mr. Stephen Liew K C" selected>Mr. Stephen Liew K C</option>
  <option value="Mr. Steven Ng">Mr. Steven Ng</option>
</select>
</p></br>
<p align="center">
<?php
}
?>

<?php if( !$edit ){ 
?>
  <div class="info">
  <h3>From:</h3>
  <p>
  Name:
  <?php echo $_POST['username'];?><br />
  Admin:
  <?php echo $_POST['admin'];?><br />
  Gender:
  <?php echo $_POST['gender'];?><br />
  Address:
  <?php echo $_POST['address'];?><br />
  Home Telephone Number: 
  <?php echo $_POST['hometel'];?><br />
  Handphone Number:
  <?php echo $_POST['hp'];?><br />
  Email:
  <?php echo $_POST['email'];?><br /> 
  Course:
  <?php echo $_POST['course'];?><br />
  Year:
  <?php echo $_POST['year'];?><br /> 
  Path:
  <?php echo $_POST['path'];?><br />
  Title:
  <?php echo $_POST['title'];?><br /> 
  Supervisor:
  <?php echo $_POST['supervisor'];?><br />
  <input name="username" type="hidden" 
    value="<?php echo $_POST['username'];?>" />
  <input name="admin" type="hidden" 
    value="<?php echo $_POST['admin'];?>" />
  <input name="gender" type="hidden" 
    value="<?php echo $_POST['gender'];?>" />
  <input name="address" type="hidden" 
    value="<?php echo $_POST['address'];?>" />
  <input name="hometel" type="hidden" 
    value="<?php echo $_POST['hometel'];?>" />
  <input name="hp" type="hidden" 
    value="<?php echo $_POST['hp'];?>" />
  <input name="email" type="hidden" 
    value="<?php echo $_POST['email'];?>" />
  <input name="course" type="hidden" 
    value="<?php echo $_POST['course'];?>" />
  <input name="year" type="hidden" 
    value="<?php echo $_POST['year'];?>" />
  <input name="path" type="hidden" 
    value="<?php echo $_POST['path'];?>" />
  <input name="title" type="hidden" 
    value="<?php echo $_POST['title'];?>" />
  <input name="supervisor" type="hidden" 
    value="<?php echo $_POST['supervisor'];?>" />


</p>

<?php
}
if ( $edit ) { 
?> 
<div> 
<input type="submit" name="submit" value="Submit" > 
  
<input type="reset" value="Reset Form">
</div> 
<?php 
} else { 
?> 
<div> 
<input type="submit" name="submit" value="Confirm"  >  
<input type="submit" name="submit" value="Edit"  > 
</div>  
<?php 
}
?>
joeey 04 Aug, 2008
Hi, I would like to know if <p align="justify" > can be used in chronoforms.
Max_admin 04 Aug, 2008

Hi, I would like to know if <p align="justify" > can be used in chronoforms.



of course, why not!
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
joeey 05 Aug, 2008
Ok thanks. I'm just curious as I'm trying to make my form presentable. Also I've read that justify is buggy and not all browser support it so I'm asking to make sure first.
Max_admin 05 Aug, 2008
Chronoforms doesn't care about the code you add, it will be shown as it is and will work but at last, its the browser job to render this code!

Best regards,

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
joeey 13 Aug, 2008
Hi, I would like to enquire about the previous codes Bob posted. I've tried the codes but it does not seem to work. The values are stored and displayed in the confirmation page correctly. However, the drop down box still reverts to its default settings. In the codes, there is a $s in it. I would like to know more about it. I've tried searching the net but the results mostly shows the code being used rather than explaining it.

Thanks
GreyHead 13 Aug, 2008
Hi joeey,

If you are talking about the code I posted in this thread then $s is just a variable name. Here's the code snippet
        if ( $cpref == $result_array['gender'] ) {
            $s = "selected='selected'";
        } else {
            $s = "";
        }
        echo "<option value='$cpref' $s >$title</option>"

$s is either empty or selected='selected'

Bob
joeey 13 Aug, 2008
Thank you Bob. I'll try playing around with the codes to get it working. It seems that problems keep occurring when the due date is so close.
gmignard 04 Sep, 2008
Help please,
I thought I was close but seem to have missed something.
I have a registration form, confirmation then post. But I also need to implement the discount for certain coupons. Could someone point me in the right direction?
TIA
Gail

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<hr><p>
<input type="hidden" name="business" value="gail_mignard@yahoo.com">
<input type="hidden" name="item_name" value="DenverBound 2008 Event">

<?php 
  $amount = "86.50" ;
  echo "<input type=\"hidden\" name=\"amount\" value=\"$amount\">";

?>
<?php
if ($_POST['coupon']  && $_POST['coupon'] == "DB2007E") {
  $amount = "77.85" ;
   echo " <input type=\"hidden\" name=\"amount\" value=\"$amount\"> ";
} elseif 
 ( $_POST['coupon'] == "DB2008W") {
  $amount = "77.85" ;
   echo " <input type=\"hidden\" name=\"amount\" value=\"$amount\"> ";
} elseif 
 ( $_POST['coupon'] == "DB2006E" ) {
  $amount = "77.85";
   echo " <input type=\"hidden\" name=\"amount\" value=\"$amount\"> ";
} elseif 
 ( $_POST['coupon'] == "" ) {
  $amount = "86.50";
   echo " <input type=\"hidden\" name=\"amount\" value=\"$amount\"> ";
}
?>	

<input type="hidden" name="shipping" value="0.00">
<input type="hidden" name="page_style" value="DenverboundEvent">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="tax" value="0.00">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-ShopCartBF">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="item_number" value="db-2008">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="tax" value="0.00">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">

<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">

  
  <?php
    // Check if the form is editable or not 
    $readonly = "";
    $edit = true;
    if ( $_POST['submit'] && $_POST['submit'] == "Confirm" ) {
      $edit = false;
      $readonly = "readonly='readonly'";
    }

    ?>


<tr><td width="25%">First Name</td>
    <td width="75%" colspan="4"><input type="text" name="first_name" size="20"></td>
  </tr>
<tr>
    <td width="25%">Last Name</td>
    <td width="75%" colspan="4"><input type="text" name="last_name" size="20"></td>
  </tr>
<tr>
    <td width="25">DenverBound Membership Number<br><i>(If you have one.)</i></td>
    <td width="75" colspan="4"><input type="text" name="dbmember" size="20"></td>
  </tr>
<tr>
    <td width="25">Scene Name<br><i>(If you have one.)</i></td>
    <td width="75" colspan="4"><input type="text" name="scenename" size="20"></td>
  </tr>
<tr>
    <td width="25%">Address</td>
    <td width="75%" colspan="4"><input type="text" name="address1" size="20"><br>
    <input type="text" name="address2" size="20"></td>
  </tr>
<tr>
    <td width="25%">City</td>
    <td width="75%" colspan="4"><input type="text" name="city" size="20"></td>
  </tr>
<tr>
    <td width="25%">State</td>
    <td width="75%" colspan="4"><input type="text" name="state" size="2"></td>
  </tr>
<tr>
    <td width="25%">Zip</td>
    <td width="75%" colspan="4"><input type="text" name="zip" size="10"></td>
  </tr>
<tr>
    <td width="25%">Email</td>
    <td width="75%" colspan="4"><input type="text" name="email" size="30"></td>
  </tr>
<tr>
     <td width="25%">Night Time Phone</td>
     <td width=75%" colspan="4"><input type="text" name="night_phone_a" size="3"> - <input type="text" name="night_phone_b" size="3"> - <input type="text" name="night_phone_c" size="4"><br></td>
  </tr>
  <tr>
  <td width="25%">Coupon</td>
  <td width="75%" colspan="4"><input type="text" name="coupon" size="30"><br><br></td></tr>


<?php 
if (!$edit && $_POST['first_name']){ 	
?>




    echo "<tr><td colspan="5"><HR><P> Welcome, please confirm your registration information.<br></td></tr> <tr><td colspan="5"> ";

           echo "Scenename:  \'.$_POST[\"scenename\"].\'<br>";
           echo "Name:  '.$_POST['first_name'].' '.$_POST['last_name'].'<br />";
           echo "Address:  '.$_POST['address1'].'<br />";


            echo " '.$_POST['address2'].'<br />';



        echo " '.$_POST['city'].', '.$_POST['state'].' '.$_POST['zip'].'<br />";
            echo "Email:  '.$_POST['email'].'<br />";
            echo "Phone:  '.$_POST['night_phone_a'].'-'.$_POST['night_phone_b'].'- '.$_POST['night_phone_c'].'<br />";
echo "<hr>";
echo "<input name="scenename" type="hidden"
  value="'.$_POST['scenename'].'" /><br />";
echo "<input name="first_name" type="hidden"
  value="'.$_POST['first_name'].'" /><br />";
echo "<input name="last_name" type="hidden"
  value="'.$_POST['last_name'].'" /><br />";
echo "<input name="address1" type="hidden"
  value="'.$_POST['address1'].'" /><br />";
echo "<input name="address2" type="hidden"
  value="'.$_POST['address2'].'" /><br />";
echo "<input name="city" type="hidden"
  value="'.$_POST['city'];?>.'" /><br />";
echo "<input name="state" type="hidden"
  value="'.$_POST['state'].'" /><br />";
echo "<input name="zip" type="hidden"
  value="'.$_POST['zip'].'" /><br />";
echo "<input name="night_phone_a" type="hidden"
  value="'.$_POST['night_phone_a'].'" /><br />";
echo "<input name="night_phone_b" type="hidden"
  value="'.$_POST['night_phone_b'].'" /><br />";
echo "<input name="night_phone_c" type="hidden"
  value="'.$_POST['night_phone_c'].'" /><br />";
echo "<input name="email" type="hidden"
  value="'.$_POST['email'].'" /><br />";
echo "<name="coupon" type="hidden" value="'.$_POST['coupon']." /><br />";






echo "<input type="hidden" name="business" value="gail_mignard@yahoo.com" /><br />";
echo "<input type="hidden" name="item_name" value="DenverBound 2008 Event" /><br />";
echo "<input type="hidden" name="shipping" value="0.00" /><br />";
echo "<input type="hidden" name="page_style" value="DenverboundEvent" /><br />":
echo "<input type="hidden" name="no_shipping" value="1" /><br />";
echo "<input type="hidden" name="return" value="http://" /><br />";
echo "<input type="hidden" name="no_note" value="1" /><br />";
echo "<input type="hidden" name="currency_code" value="USD" /><br />";
echo "<input type="hidden" name="tax" value="0.00" /><br />";
echo "<input type="hidden" name="lc" value="US" /><br />";

echo "<input type="hidden" name="bn" value="PP-ShopCartBF" /><br />";
echo "<input type="hidden" name="cmd" value="_xclick" /><br />";
echo "<input type="hidden" name="item_number" value="db-2008" /><br />";
echo "<input type="hidden" name="no_shipping" value="0" /><br />";
echo "<input type="hidden" name="no_note" value="1" /><br />";
echo "<input type="hidden" name="currency_code" value="USD" /><br />";
echo "<input type="hidden" name="tax" value="0.00" /><br />";
echo "<input type="hidden" name="lc" value="US" /><br />";
echo "<input type="hidden" name="bn" value="PP-BuyNowBF" /><br />";

echo "<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"/><br />";
echo "<hr></td></tr>";
?>


   <?php
    }
    if ( $edit ) {
    ?>
    <tr><td colspan="5"><div>
    <input type="submit" name="submit" value="Confirm" >
      
    <input type="reset" value="Reset Form">
    </div>
    <?php
    } else {
    ?>
    <div>
 <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_paynow_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" value="pay">
    <input type="submit" name="submit" value="Pay"  > 
    <input type="submit" name="submit" value="Edit"  >
    </div> 
    <?php
    }
    ?>
  
    </td>
  </tr></form>
  <tr>
    <hr></td>
  </tr>



 
</table>
<?php
function check_input($data)
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;
}
?>
Max_admin 04 Sep, 2008
Hi Gail,

first thing is that you have a form tag inside code, this will make problems!

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
gmignard 04 Sep, 2008
I moved the php inside the </form> tag and still have the same problem.
Max_admin 04 Sep, 2008
sorry, I cant understand, can you show me your code here again ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
gmignard 05 Sep, 2008
Thank you for looking at this again.
I need to
a) gather the information.
b) show confirmation page with appropriate discount applied
c) submit form to paypal

I have the form gathering the information.
But can get the discount to apply or the submit correct.



form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<hr><p>
<input type="hidden" name="business" value="lillykay@qwest.net">
<input type="hidden" name="item_name" value="DenverBound 2008 Event">

<?php 
  $amount = "86.50" ;
  echo "<input type=\"hidden\" name=\"amount\" value=\"$amount\">";

?>
<?php
if ($_POST['coupon']  && $_POST['coupon'] == "DB2007E") {
  $amount = "77.85" ;
   echo " <input type=\"hidden\" name=\"amount\" value=\"$amount\"> ";
} elseif 
 ( $_POST['coupon'] == "DB2008W") {
  $amount = "77.85" ;
   echo " <input type=\"hidden\" name=\"amount\" value=\"$amount\"> ";
} elseif 
 ( $_POST['coupon'] == "DB2006E" ) {
  $amount = "77.85";
   echo " <input type=\"hidden\" name=\"amount\" value=\"$amount\"> ";
} elseif 
 ( $_POST['coupon'] == "" ) {
  $amount = "86.50";
   echo " <input type=\"hidden\" name=\"amount\" value=\"$amount\"> ";
}
?>	

<input type="hidden" name="shipping" value="0.00">
<input type="hidden" name="page_style" value="DenverboundEvent">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="return" value="http://www.denverbound.org/index.php?option=com_content&amp;task=view&amp;id=30">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="tax" value="0.00">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-ShopCartBF">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="item_number" value="db-2008">
<input type="hidden" name="no_shipping" value="0">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="tax" value="0.00">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">

<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">

  
  <?php
    // Check if the form is editable or not 
    $readonly = "";
    $edit = true;
    if ( $_POST['submit'] && $_POST['submit'] == "Confirm" ) {
      $edit = false;
      $readonly = "readonly='readonly'";
    }

    ?>


<tr><td width="25%">First Name</td>
    <td width="75%" colspan="4"><input type="text" name="first_name" size="20"></td>
  </tr>
<tr>
    <td width="25%">Last Name</td>
    <td width="75%" colspan="4"><input type="text" name="last_name" size="20"></td>
  </tr>
<tr>
    <td width="25">DenverBound Membership Number<br><i>(If you have one.)</i></td>
    <td width="75" colspan="4"><input type="text" name="dbmember" size="20"></td>
  </tr>
<tr>
    <td width="25">Scene Name<br><i>(If you have one.)</i></td>
    <td width="75" colspan="4"><input type="text" name="scenename" size="20"></td>
  </tr>
<tr>
    <td width="25%">Address</td>
    <td width="75%" colspan="4"><input type="text" name="address1" size="20"><br>
    <input type="text" name="address2" size="20"></td>
  </tr>
<tr>
    <td width="25%">City</td>
    <td width="75%" colspan="4"><input type="text" name="city" size="20"></td>
  </tr>
<tr>
    <td width="25%">State</td>
    <td width="75%" colspan="4"><input type="text" name="state" size="2"></td>
  </tr>
<tr>
    <td width="25%">Zip</td>
    <td width="75%" colspan="4"><input type="text" name="zip" size="10"></td>
  </tr>
<tr>
    <td width="25%">Email</td>
    <td width="75%" colspan="4"><input type="text" name="email" size="30"></td>
  </tr>
<tr>
     <td width="25%">Night Time Phone</td>
     <td width=75%" colspan="4"><input type="text" name="night_phone_a" size="3"> - <input type="text" name="night_phone_b" size="3"> - <input type="text" name="night_phone_c" size="4"><br></td>
  </tr>
  <tr>
  <td width="25%">Coupon</td>
  <td width="75%" colspan="4"><input type="text" name="coupon" size="30"><br><br></td></tr>


<?php 
if (!$edit && $_POST['first_name']){ 	
?>




    echo "<tr><td colspan="5"><HR><P> Welcome, please confirm your registration information.<br></td></tr> <tr><td colspan="5"> ";

           echo "Scenename:  \'.$_POST[\"scenename\"].\'<br>";
           echo "Name:  '.$_POST['first_name'].' '.$_POST['last_name'].'<br />";
           echo "Address:  '.$_POST['address1'].'<br />";


            echo " '.$_POST['address2'].'<br />';



        echo " '.$_POST['city'].', '.$_POST['state'].' '.$_POST['zip'].'<br />";
            echo "Email:  '.$_POST['email'].'<br />";
            echo "Phone:  '.$_POST['night_phone_a'].'-'.$_POST['night_phone_b'].'- '.$_POST['night_phone_c'].'<br />";
echo "<hr>";
echo "<input name="scenename" type="hidden"
  value="'.$_POST['scenename'].'" /><br />";
echo "<input name="first_name" type="hidden"
  value="'.$_POST['first_name'].'" /><br />";
echo "<input name="last_name" type="hidden"
  value="'.$_POST['last_name'].'" /><br />";
echo "<input name="address1" type="hidden"
  value="'.$_POST['address1'].'" /><br />";
echo "<input name="address2" type="hidden"
  value="'.$_POST['address2'].'" /><br />";
echo "<input name="city" type="hidden"
  value="'.$_POST['city'];?>.'" /><br />";
echo "<input name="state" type="hidden"
  value="'.$_POST['state'].'" /><br />";
echo "<input name="zip" type="hidden"
  value="'.$_POST['zip'].'" /><br />";
echo "<input name="night_phone_a" type="hidden"
  value="'.$_POST['night_phone_a'].'" /><br />";
echo "<input name="night_phone_b" type="hidden"
  value="'.$_POST['night_phone_b'].'" /><br />";
echo "<input name="night_phone_c" type="hidden"
  value="'.$_POST['night_phone_c'].'" /><br />";
echo "<input name="email" type="hidden"
  value="'.$_POST['email'].'" /><br />";
echo "<name="coupon" type="hidden" value="'.$_POST['coupon']." /><br />";






echo "<input type="hidden" name="business" value="lillykay@qwest.net" /><br />";
echo "<input type="hidden" name="item_name" value="DenverBound 2008 Event" /><br />";
echo "<input type="hidden" name="shipping" value="0.00" /><br />";
echo "<input type="hidden" name="page_style" value="DenverboundEvent" /><br />":
echo "<input type="hidden" name="no_shipping" value="1" /><br />";
echo "<input type="hidden" name="return" value="http://www.denverbound.org/index.php?option=com_content&amp;task=view&amp;id=30" /><br />";
echo "<input type="hidden" name="no_note" value="1" /><br />";
echo "<input type="hidden" name="currency_code" value="USD" /><br />";
echo "<input type="hidden" name="tax" value="0.00" /><br />";
echo "<input type="hidden" name="lc" value="US" /><br />";

echo "<input type="hidden" name="bn" value="PP-ShopCartBF" /><br />";
echo "<input type="hidden" name="cmd" value="_xclick" /><br />";
echo "<input type="hidden" name="item_number" value="db-2008" /><br />";
echo "<input type="hidden" name="no_shipping" value="0" /><br />";
echo "<input type="hidden" name="no_note" value="1" /><br />";
echo "<input type="hidden" name="currency_code" value="USD" /><br />";
echo "<input type="hidden" name="tax" value="0.00" /><br />";
echo "<input type="hidden" name="lc" value="US" /><br />";
echo "<input type="hidden" name="bn" value="PP-BuyNowBF" /><br />";

echo "<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"/><br />";
echo "<hr></td></tr>";
?>


   <?php
    }
    if ( $edit ) {
    ?>
    <tr><td colspan="5"><div>
    <input type="submit" name="submit" value="Confirm" >
      
    <input type="reset" value="Reset Form">
    </div>
    <?php
    } else {
    ?>
    <div>
 <input type="image" src="https://www.paypal.com/en_US/i/btn/btn_paynow_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" value="pay">
    <input type="submit" name="submit" value="Pay"  > 
    <input type="submit" name="submit" value="Edit"  >
    </div> 
    <?php
    }
    ?>
  
    </td>
<?php
function check_input($data)
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;
}
?>

  </tr></form>
Max_admin 05 Sep, 2008
Hi,

the best way to get these things to work if you are not very familiar with them is to cut them into pieces and test them one by one, so for the coupons part, take out any other code or make a different form to test this only!🙂

I see you put 2 amount fields!!!

after this, put the code of a simple Paypal form with static values, and when you get it working also start adding your dynamic values, that's how it should be done😉

Regards,

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
samoht 23 Oct, 2008
Hey guy's,

did something change in version 3.0 that wont let me do this multiple page form any more?
when I tried to backup and restore my multiple page form from version 2 of chronoforms I got an error when I tried to restore it in version 3.0. So I just manually put all the code in version 3.0 - problem is I now don't get to my confirmation page??

Is there some other trick to version 3.0 to getting a multiple page form?

Thanks
Max_admin 23 Oct, 2008
show me the form code

Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
gmignard 23 Oct, 2008
Got the form working,
Thanks for the help.
samoht 23 Oct, 2008
Max,
were you asking for my form code?

<?php

global $cf_AUTHNET_response_code, $cf_AUTHNET_response_subcode, $cf_AUTHNET_response_reason_code, $cf_AUTHNET_response_reason_text, $cf_AUTHNET_approval_code, $cf_AUTHNET_avs_result_code, $cf_AUTHNET_transaction_id;

// Check if the form is editable or not  
$readonly = ""; 
$edit = true; 
if ( $_POST['submit'] && $_POST['submit'] == "Confirm" ) { 
    $edit = false; 
    $readonly = "readonly='readonly'"; 
}

   echo '<input name="AUTHNET_response_code" type="hidden" value="'. $cf_AUTHNET_response_code.'" />';
   echo '<input name="AUTHNET_trans_id" type="hidden" value="'. $cf_AUTHNET_transaction_id.'" />';

?>

<style type="text/css">
input[readonly] {border:none; background:transparent;}
.cb {display:block; float:left; width:5.5em;}
.info {text-align:left;}
</style>
<div class="mainform">
<p align="right"><a href="javascript:window.close();">Close Window</a></p>

<h3>GIFT CARD ORDER <?php if($_POST['fromname']){echo 'CONFIRMATION';}else{ echo 'FORM';}?></h3>
<?php if($_POST['fromname']){ ?>
<p>Your order is not complete. Please review the following information and click to confirm your order at the bottom of this page.</p>
<?php } ?>
<?php if(!$edit && $_POST['fromname']){ ?>
	<div class="info">
		<h3>From:</h3>
		<p>
			<?php echo $_POST['fromname2'];?> <?php echo $_POST['fromname2'];?><br />
			<?php echo $_POST['fromaddress'];?><br />
			<?php echo $_POST['fromcity'];?>, <?php echo $_POST['fromstate'];?> <?php echo $_POST['fromzip'];?><br />
			Home #: <?php echo $_POST['fromhome'];?> • Buisness #: <?php echo $_POST['frombusiness'];?><br />
			Fax #: <?php echo $_POST['fromfax'];?> •  E-mail: <?php echo $_POST['fromemail'];?><br />

			<input name="fromname" type="hidden" value="<?php echo $_POST['fromname'];?>" />
			<input name="fromname2" type="hidden" value="<?php echo $_POST['fromname2'];?>" />
			<input name="fromaddress" type="hidden" value="<?php echo $_POST['fromaddress'];?>" />
			<input name="fromcity" type="hidden" value="<?php echo $_POST['fromcity'];?>" />
			<input name="fromstate" type="hidden" value="<?php echo $_POST['fromstate'];?>" />
			<input name="fromzip" type="hidden" value="<?php echo $_POST['fromzip'];?>" />
			<input name="billaddress" type="hidden" value="<?php if($_POST['billaddress']){ echo $_POST['billaddress'];}else{ echo $_POST['fromaddress'];}?>" /> 
			<input name="billcity" type="hidden" value="<?php if($_POST['billcity']){ echo $_POST['billcity'];}else{ echo $_POST['fromcity'];}?>" /> 
			<input name="billstate" type="hidden" value="<?php if($_POST['billstate']){ echo $_POST['billstate'];}else{ echo $_POST['fromstate'];}?>" /> 
			<input name="billzip" type="hidden" value="<?php if($_POST['billzip']){ echo $_POST['billzip'];}else{ echo $_POST['fromzip'];}?>" /> 
			<input name="fromhome" type="hidden" value="<?php echo $_POST['fromhome'];?>" />
			<input name="frombusiness" type="hidden" value="<?php echo $_POST['frombusiness'];?>" />
			<input name="fromfax" type="hidden" value="<?php echo $_POST['fromfax'];?>" />
			<input name="fromemail" type="hidden" value="<?php echo $_POST['fromemail'];?>" />
		</p>
		<h3>For:</h3>
		<p>
			<?php echo $_POST['forname'];?> <?php echo $_POST['forname2'];?><br />
			<?php echo $_POST['foraddress'];?><br />
			<?php echo $_POST['forcity'];?>, <?php echo $_POST['forstate'];?> <?php echo $_POST['forzip'];?><br />
			Home #: <?php echo $_POST['forhome'];?> • Buisness #: <?php echo $_POST['forbuisness'];?><br />
			Fax #: <?php echo $_POST['forfax'];?> •  E-mail: <?php echo $_POST['foremail'];?><br />
			<input name="forname" type="hidden" value="<?php echo $_POST['forname'];?>" />
			<input name="forname2" type="hidden" value="<?php echo $_POST['forname2'];?>" />
			<input name="foraddress" type="hidden" value="<?php echo $_POST['foraddress'];?>" />
			<input name="forcity" type="hidden" value="<?php echo $_POST['forcity'];?>" />
			<input name="forstate" type="hidden" value="<?php echo $_POST['forstate'];?>" />
			<input name="forzip" type="hidden" value="<?php echo $_POST['forzip'];?>" />
			<input name="forhome" type="hidden" value="<?php echo $_POST['forhome'];?>" />
			<input name="forbusiness" type="hidden" value="<?php echo $_POST['forbusiness'];?>" />
			<input name="forfax" type="hidden" value="<?php echo $_POST['forfax'];?>" />
			<input name="foremail" type="hidden" value="<?php echo $_POST['foremail'];?>" />
		</p>
		<p>Send To: <?php foreach($_POST['mailto'] as $mt) $nnmt = $mt; echo $mt;?>
		<input type="hidden" name="mailto[]" value="<?php echo $nnmt;?>" />
		</p>
		<?php
		foreach($_POST['checkbox'] as $cb)
			echo '<input type="hidden" name="checkbox[]" value="'.$cb.'" />';
		?>
		<input type="hidden" name="otheramount" value="<?php echo $_POST['otheramount'];?>" >
		<input type="hidden" name="totalamount" value="<?php echo array_sum($_POST['checkbox']) + $_POST['otheramount'] + $_POST['Shipping'];?>" >
		<input type="hidden" name="Shipping" value="<?php echo $_POST['Shipping'];?>" >
		<input type="hidden" name="CardType" value="<?php echo $_POST['CardType'];?>" >
		<input type="hidden" name="cardnumber" value="<?php echo $_POST['cardnumber'];?>" >
		<input type="hidden" name="expirationmonth" value="<?php echo $_POST['expirationmonth'];?>" >
		<input type="hidden" name="expirationyear" value="<?php echo $_POST['expirationyear'];?>" >
		<input type="hidden" name="cardname" value="<?php echo $_POST['cardname'];?>" >
		<br />
		<h3>Amount:</h3>
		<table border=0 cellpadding=0 cellspacing=0 width=47% style='border-collapse: collapse;'>
		<?php 
		if($_POST['checkbox']){
			foreach ($_POST['checkbox'] as $gc){
					echo '<tr><td> Gift card .............</td><td>$'.$gc . '.00</td></tr>'."\n";
			}
			if($_POST['otheramount']){
			echo '<tr><td> Gift card .............</td><td>$'.$_POST['otheramount'] . '.00</td></tr>'."\n";
			}
			echo '<tr><td> Shipping .............</td><td>$'.$_POST['Shipping'].'.00</td></tr>'."\n";
		}
		?>
		<tr><td colspan="2" style='border-bottom:1px solid black'> </td></tr>
		<tr><td><b>Total</b> .............</td><td>$<?php if( $_POST['checkbox']){ echo array_sum($_POST['checkbox']) + $_POST['otheramount'] + $_POST['Shipping'].'.00';}else{ echo $_POST['otheramount'] + $_POST['Shipping'].'.00';} ?></td></tr>
		</table>
		<h3>Credit Card Information</h3>
		<p>
			Card Type: <?php echo $_POST['CardType'];?><br />
			Card Number: <?php echo $_POST['cardnumber'];?><br />
			Expiration Date: <?php echo $_POST['expirationmonth'];?> / <?php echo $_POST['expirationyear'];?><br />
			Card Name: <?php echo $_POST['cardname'];?><br />
		</p>
	</div>
	<?php
	} else {
	?>
<table align="center" width="450" cellpadding="3" >
	<tr class="rowTitle">
		<td  colspan="2"><center>
			<b>This Gift Card is from:</b>
			(Purchaser)
			</center>
		</td>
	</tr>
	<tr>
		<td >First Name:<font color="#ff0000">*</font> </td>
		<td ><input name="fromname" type="text" value="<?php if(isset($_POST['fromname'])) echo $_POST['fromname'];?>" size="35" <?php echo $readonly;?> class="required" /></td>
	</tr>
	<tr>
		<td >Last Name:<font color="#ff0000">*</font> </td>
		<td ><input name="fromname2" type="text"  <?php echo $readonly;?> class="required" id="fromname2" value="<?php if(isset($_POST['fromname2'])) echo $_POST['fromname2'];?>" size="35" /></td>
	</tr>
	<tr>
		<td >Address:<font color="#ff0000">*</font> </td>
		<td ><input name="fromaddress" type="text" value="<?php if(isset($_POST['fromaddress'])) echo $_POST['fromaddress'];?>" size="35" <?php echo $readonly;?> class="required" /></td>
	</tr>
	<tr>
		<td >City: <font color="#ff0000">*</font></td>
		<td ><input name="fromcity" type="text" value="<?php if(isset($_POST['fromcity'])) echo $_POST['fromcity'];?>" size="35" <?php echo $readonly;?> class="required" /></td>
	</tr>
	<tr>
		<td >State:<font color="#ff0000">*</font> </td>
		<td ><?php 
				if(!$edit){
				$frmstate = $_POST['fromstate'];
					echo '<input name="fromstate" type="text" value="'. $frmstate .'" readonly="readonly" >';
				}else { 
					//set up all the states in selectbox
					$states = array ('NJ','AL','AZ','AR','CA','CO','CT','DE','DC','FL','GA','HI','ID','IL','IN','IA','KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE',
					'NV','NH','AK','NM','NY','NC','ND','OH','OR','PA','PR','RI','SC','SD','TN','TX','UT','VT','VA','WA','WV','WI','WY');
						echo '<select name="fromstate" size="1"'. $readonly. ' class="required">';
					foreach ($states as $state) {
						if (is_array($_POST['fromstate']) && in_array($state,$_POST['fromstate']))
							echo '<option selected value="'.$state.'">'.$state.'</option>'."\n";	
						elseif ( !$edit ) 
							echo $state;
						elseif ( $edit )	
							echo '<option value="'.$state.'">'.$state.'</option>'."\n";	
					}
						echo '</select>';
				}
				?>
				<span >   Zip:<font color="#ff0000">*</font> </span>
				<input name="fromzip" type="text" value="<?php if(isset($_POST['fromzip'])) echo $_POST['fromzip'];?>" size="10" <?php echo $readonly;?> class="required" /></td>
	</tr>
	<tr>
		<td >Home Phone:<font color="#ff0000">*</font> </td>
		<td ><input name="fromhome" type="text" value="<?php if(isset($_POST['fromhome'])) echo $_POST['fromhome'];?>" size="25" <?php echo $readonly;?> class="required" /></td>

	</tr>
	<tr>
		<td >Business Phone: </td>
		<td ><input name="frombusiness" type="text" value="<?php if(isset($_POST['frombusiness'])) echo $_POST['frombusiness'];?>" size="25" <?php echo $readonly;?> /></td>
	</tr>
	<tr>
		<td >Fax: </td>
		<td ><input name="fromfax" type="text" value="<?php if(isset($_POST['fromfax'])) echo $_POST['fromfax'];?>" size="25" <?php echo $readonly;?> /></td>

	</tr>
	<tr>
		<td >E-mail:<font color="#ff0000">*</font> </td>
		<td ><input name="fromemail" type="text" value="<?php if(isset($_POST['fromemail'])) echo $_POST['fromemail'];?>" size="35" <?php echo $readonly;?> class="required" /></td>
	</tr>
</table>
<br />
<br />
<p>If billing address for your credit card is different please fill out the Billing section so that the transaction will not be rejected. If the address is the  same as above you can leave the fields blank.</p>
	<?php if($edit) {?>
	<div id="bill" style="">
	<table  align="center" width="450"  cellpadding="3">
	  <tr class="rowTitle">
		<td  colspan="2"><center>
			<b>Billing address:</b> 
			(if different)
		  </center></td>
	  </tr>
	  <tr>
		<td >Address:<font color="#ff0000">*</font> </td>
		<td ><input name="billaddress" type="text" value="<?php if(isset($_POST['billaddress'])) { echo $_POST['billaddress']; }else if($_POST['fromaddress']){ echo $_POST['fromaddress'];}?>" size="35" <?php echo $readonly;?> ></td>
	  </tr>
	  <tr>
		<td >City:<font color="#ff0000">*</font> </td>

		<td ><input name="billcity" type="text" value="<?php if(isset($_POST['billcity'])) { echo $_POST['billcity'];}else if($_POST['fromcity']){ echo $_POST['fromcity'];}?>" size="35" <?php echo $readonly;?> ></td>
	  </tr>
	  <tr>
		<td >State:<font color="#ff0000">*</font> </td>
		<td ><?php 
		if(!$edit){
			$bstate = $_POST['billstate'];
			echo '<input name="billstate" size="5" type="text" value="'. $bstate .'" readonly="readonly" >';
		}else { 
			//set up all the states in selectbox
			$states = array ('NJ','AL','AZ','AR','CA','CO','CT','DE','DC','FL','GA','HI','ID','IL','IN','IA','KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE',
			'NV','NH','AK','NM','NY','NC','ND','OH','OR','PA','PR','RI','SC','SD','TN','TX','UT','VT','VA','WA','WV','WI','WY');
			echo '<select name="billstate" size="1"'. $readonly. ' class="required">';
			foreach ($states as $state) {
				if (is_array($_POST['billstate']) && in_array($state,$_POST['billstate']))
					echo '<option selected value="'.$state.'">'.$state.'</option>'."\n";	
				elseif ( !$edit ) 
					echo $state;
				elseif ( $edit )	
					echo '<option value="'.$state.'">'.$state.'</option>'."\n";	
			}
			echo '</select>';
		}
		?>	                                       <span >   Zip:<font color="#ff0000">*</font></span>
		  <input name="billzip" type="text" value="<?php if(isset($_POST['billzip'])) { echo $_POST['billzip'];}else if($_POST['fromzip']){ echo $_POST['fromzip'];}?>" size="10" <?php echo $readonly;?> ></td>
	  </tr>
	  <tr>
	</table>	
	</div>
	<br />
	<br />
	<?php } ?>
<table  align="center" width="450"  cellpadding="3" >
	<tr class="rowTitle">
		<td  colspan="2"><center>
		<b>This Gift Card is for:</b> 
		(Recipient)
		</center></td>
	</tr>
	<tr>
		<td >First Name:<font color="#ff0000">*</font> </td>
		<td ><input name="forname" type="text" value="<?php if(isset($_POST['forname'])) echo $_POST['forname'];?>" size="35" <?php echo $readonly;?> class="required" /></td>
	</tr>
	<tr>
		<td >Last Name:<font color="#ff0000">*</font> </td>
		<td ><input name="forname2" type="text" <?php echo $readonly;?> class="required" id="forname2" value="<?php if(isset($_POST['forname2'])) echo $_POST['forname2'];?>" size="35" /></td>
	</tr>
	<tr>
		<td >Address:<font color="#ff0000">*</font> </td>
		<td ><input name="foraddress" type="text" value="<?php if(isset($_POST['foraddress'])) echo $_POST['foraddress'];?>" size="35" <?php echo $readonly;?> class="required" /></td>
	</tr>
	<tr>
		<td >City:<font color="#ff0000">*</font> </td>
		<td ><input name="forcity" type="text" value="<?php if(isset($_POST['forcity'])) echo $_POST['forcity'];?>" size="35" <?php echo $readonly;?> class="required" /></td>
	</tr>
	<tr>
		<td >State:<font color="#ff0000">*</font> </td>
		<td ><?php 
			if(!$edit){
			$fstate = $_POST['forstate'];
				echo '<input name="forstate" type="text" value="'. $fstate .'" readonly="readonly" >';
			}else { 
				//set up all the states in selectbox
				$states = array ('NJ','AL','AZ','AR','CA','CO','CT','DE','DC','FL','GA','HI','ID','IL','IN','IA','KS','KY','LA','ME','MD','MA','MI','MN','MS','MO','MT','NE',
				'NV','NH','AK','NM','NY','NC','ND','OH','OR','PA','PR','RI','SC','SD','TN','TX','UT','VT','VA','WA','WV','WI','WY');
				echo '<select name="forstate" size="1"'. $readonly. ' class="required">';
				foreach ($states as $state) {
					if (is_array($_POST['forstate']) && in_array($state,$_POST['forstate']))
						echo '<option selected value="'.$state.'">'.$state.'</option>'."\n";	
					elseif ( !$edit ) 
						echo $state;
					elseif ( $edit )	
						echo '<option value="'.$state.'">'.$state.'</option>'."\n";	
				}
				echo '</select>';
			}
			?>	                                       
			<span >   Zip:<font color="#ff0000">*</font></span>
			<input name="forzip" type="text" value="<?php if(isset($_POST['forzip'])) echo $_POST['forzip'];?>" size="10" <?php echo $readonly;?> class="required" /></td>
	</tr>
	<tr>
		<td >Home Phone:<font color="#ff0000">*</font></td>
		<td ><input name="forhome" type="text" value="<?php if(isset($_POST['forhome'])) echo $_POST['forhome'];?>" size="25" <?php echo $readonly;?> class="required" /></td>
	</tr>
	<tr>
		<td >Business Phone: </td>
		<td ><input name="forbusiness" type="text" value="<?php if(isset($_POST['forbusiness'])) echo $_POST['forbusiness'];?>" size="25" <?php echo $readonly;?> /></td>
	</tr>
	<tr>
		<td >Fax: </td>
		<td ><input name="forfax" type="text" value="<?php if(isset($_POST['forfax'])) echo $_POST['forfax'];?>" size="25" <?php echo $readonly;?> /></td>
	</tr>
	<tr>
		<td >E-mail : </td>
		<td ><input name="foremail" type="text" value="<?php if(isset($_POST['foremail'])) echo $_POST['foremail'];?>" size="35" <?php echo $readonly;?> class="required" /></td>
	</tr>
	<tr>
		<td > Mail Gift <br />Card To:<span color="#ff0000">*</span></td>
		<td><?php 
			// set checked field for radio buttons 
			$checks = array('purchaser','receipient');
			foreach ($checks as $check){
				echo '<input type="radio" name="mailto[]" value="'.$check.'" ';
				if (is_array($_POST['mailto']) && in_array($check,$_POST['mailto']))
					echo 'checked="checked" '; 
				elseif ( !$edit ) 
					echo 'disabled="disabled"'; 
				echo ' /> '.ucwords($check);
			} 
			?>
		</td>    
	</tr>
</table>
<br />
<br />
<table  align="center" width="450"  cellpadding="3" >
	<tr class="rowTitle">
		<td  colspan="2"><center><b>Amount:</b></center></td>
	</tr>
	<tr>
		<td  colspan="2"><center> 
		Please select a dollar amount, <br />
		or write in the denomination that you choose.
		</center></td>
	</tr>







	<tr>
		<td  colspan="2" class="noborders">
		<?php 
		// set checked field(s) for checkboxes
		$amounts = array(50,75,100,125,150,200,250,300,500,750,1000); 
		foreach ($amounts as $amount) {
			echo '<span class="cb"><input type="radio" name="checkbox[]" onclick="javascript:document.ChronoContact_newgc.otheramount.disabled=true" value="'.$amount.'" style="border:0;" ';
			if (is_array($_POST['checkbox']) && in_array($amount,$_POST['checkbox']))
				echo 'checked="checked" '; 
			elseif ( !$edit ) 
				echo 'disabled="disabled"'; 
			echo ' /> $'.$amount.'</span>'."\n";
		} 
		?> 
		</td>
	</tr>
	<tr>
		<td  colspan="2"><span>Other Amount:  $</span>
		<input name="otheramount" type="text" value="<?php if(isset($_POST['otheramount'])) echo $_POST['otheramount'];?>" size="4"  <?php echo $readonly;?> onclick="javascript:document.ChronoContact_newgc.checkbox[].disabled=true" />
		<span>.00</span><br />
		<br />
		</td>
	</tr>
	<tr class="rowTitle">
		<td  colspan="2"><center>
		<b>Credit Card Information:</b>
		</center></td>
	</tr>
	<tr>
		<td >Card Type:<font color="#ff0000">*</font> </td>
		<td class="form2"><select size="1" name="CardType"  class="required"  <?php echo $readonly;?>>
		<option>Please Select One</option>
		<option <?php if($_POST['CardType']== "Visa")echo 'selected';?>>Visa</option>
		<option <?php if($_POST['CardType']== "MasterCard")echo 'selected';?>>MasterCard</option>
		<option <?php if($_POST['CardType']== "American Express")echo 'selected';?>>American Express</option>
		</select></td>
	</tr>
	<tr>
		<td >Card Number:<font color="#ff0000">*</font> </td>
		<td ><input name="cardnumber" type="text" value="<?php if(isset($_POST['cardnumber'])) echo $_POST['cardnumber'];?>" size="25"  class="required" /></td>
	</tr>
	<tr>
		<td >Expiration Date:<font color="#ff0000">*</font> </td>
		<td class="form2"><?php
			if(!$edit){
				$xm = $_POST['expirationmonth'];
				echo '<input name="expirationmonth" size="3" type="text" value="'. $xm .'" readonly="readonly" >';
				}else { 
					//set up months
					$xmonths = array ('01','02','03','04','05','06','07','08','09','10','11','12');
					echo '<select name="expirationmonth"  class="required" '.$readonly.'>';								
				foreach($xmonths as $xmonth) {
					if (is_array($_POST['expirationmonth']) && in_array($xmonth,$_POST['expirationmonth']))
						echo '<option selected value="'.$xmonth.'">'.$xmonth.'</option>'."\n";	
					elseif ( !$edit ) 
						echo $xmonth;
					elseif ( $edit )	
						echo '<option value="'.$xmonth.'">'.$xmonth.'</option>'."\n";	
				}
				echo '</select>';
				}		
			?>								
			<span >  /  </span>
			<?php
			if(!$edit){
			$xy = $_POST['expirationyear'];
			echo '<input name="expirationyear" size="3" type="text" value="'. $xy .'" readonly="readonly" >';
			}else { 
				//set up years
				$xyears = array ('08','09','10','11','12','13','14','15','16','17','18','19');
				echo '<select name="expirationyear"  class="required" '.$readonly.'>';								
				foreach($xyears as $xyear) {
					if (is_array($_POST['expirationyear']) && in_array($xmonth,$_POST['expirationyear']))
						echo '<option selected value="'.$xyear.'">'.$xyear.'</option>'."\n";	
					elseif ( !$edit ) 
						echo $xyear;
					elseif ( $edit )	
						echo '<option value="'.$xyear.'">'.$xyear.'</option>'."\n";	
				}
				echo '</select>';
			}
			?></td>
	</tr>
	<tr>
		<td >Name on Card: <font color="#ff0000">*</font></td>
		<td ><input <?php echo $readonly;?> name="cardname" type="text" value="<?php if(isset($_POST['cardname'])) echo $_POST['cardname'];?>" size="35"  class="required" /></td>
	</tr>
</table>
<br />
<br />
<table width="450" align="center">
	<tr class="rowTitle">
		<td  colspan="2"><center>
		<b>Shipping Information:</b>
		</center></td>
	</tr>
	<tr>
		<td colspan="2"></td>
	</tr>
	<tr>
		<td ><strong>Shipping Method: </strong></td>
		<td class="form2"><select size="1" name="Shipping" <?php echo $readonly;?>>
		<option value="3">Please Select One</option>
		<option value="3" <?php if($_POST['Shipping']== "3")echo 'selected';?>>USPS (regular mail) $3</option>
		<option value="15" <?php if($_POST['Shipping']== "15")echo 'selected';?>>2nd Day $15</option>
		<option value="25" <?php if($_POST['Shipping']== "25")echo 'selected';?>>Overnight $25</option>
		<option value="45" <?php if($_POST['Shipping']== "45")echo 'selected';?>>Saturday Delivery $45</option>
		</select></td>
	</tr>
</table>
<p>All order requests received before 3pm will be processed and mailed the  same day. </p>

<table width="80%" border="0" align="center">
	<tr>
		<td><strong>Delivery Option </strong></td>
		<td><strong>Delivery Cost </strong></td>
		<td><strong>Carrier Delivery Time </strong></td>
		<td><strong>Total Delivery Time </strong></td>
	</tr>
	<tr>
		<td valign="top"><p>Regular Mail</p></td>
		<td valign="top"><p>$3.00</p></td>
		<td valign="top"><p>5-7 business days</p></td>
		<td valign="top"><p>5-7 business days</p></td>
	</tr>
	<tr>
		<td valign="top"><p>UPS 2- Day Air*</p></td>
		<td valign="top"><p>$15.00</p></td>
		<td valign="top"><p>2 business days</p></td>
		<td valign="top"><p>2 business days</p></td>
	</tr>
	<tr>
		<td valign="top"><p>UPS Next Day Air*</p></td>
		<td valign="top"><p>$25.00</p></td>
		<td valign="top"><p>1 Business days</p></td>
		<td valign="top"><p>1 business day</p></td>
	</tr>
</table>
<p align="center">*Saturday deliveries are available with 2-day Air and Next  Day Air delivery.  <br />

Deliveries made on Saturday will be a total delivery  cost of $45.00.  </p>
<p align="center">Business  Days: Monday – Friday excluding federal holidays within the United States.<br />
UPS 2-Day  Air, UPS Next Day Air:  Orders must be placed by 3p.m. Eastern Standard Time to be processed on  the same business day.  All orders placed  after 3 p.m. will be  processed the following business day.  In  order to receive a gift card next business day, please select the UPS Next Day  Air and the order must be received by 3:00pm   EST, Monday through Friday. UPS Saturday delivery must be received  by 3:00pm EST, Friday.      </p>

<table width="430" align="center">
	<tr>
		<td colspan="2"><center>
		<?php
		}
		if ( $edit ) { 
		?> 
		<div> 
			<input type="submit" name="submit" value="Submit" /> 
			  
			<input type="reset" value="Reset Form" />
		</div> 
		<?php 
		} else { 
		?> 
		<div> 
			<input type="submit" name="submit" value="Pay"  />  
			<input type="submit" name="submit" value="Edit" /> 
		</div>  
		<?php 
		}?>
		</center></td>
	</tr>
</table>
</div>

here is my Form Html

<?php
global  $cf_AUTHNET_response_code, $cf_AUTHNET_response_subcode, $cf_AUTHNET_response_reason_code, $cf_AUTHNET_response_reason_text, $cf_AUTHNET_approval_code, $cf_AUTHNET_avs_result_code, $cf_AUTHNET_transaction_id;

// If the form has just been submitted  
// re-display with Edit & Pay buttons 
if ( $_POST['submit'] == 'Submit') { 
    $_POST['submit'] = 'Confirm'; 
    $error_found = true; 
    showform($_POST); 
} elseif ( $_POST['submit'] == 'Edit') { 
    $_POST['submit'] = 'Submit'; 
    $error_found = true; 
    showform($_POST); 
} elseif ( $_POST['submit'] == 'Pay') {

 $_POST['AUTHNET_response_code'] = $anet_response_code;
 $_POST['AUTHNET_trans_id'] = $anet_trans_id;

    if($cf_AUTHNET_response_code == 'Declined'){
    $rows[0]->emailresults = 0;
    }

    echo '<p style="font-size:2em; font-weight:bold;">' .$cf_AUTHNET_response_code .'</p>';
    if ($cf_AUTHNET_response_code == 'Declined' || $cf_AUTHNET_response_code != 'Approved') {
      echo '<p>Sorry your transaction was declined by the payment gateway.<br>Please try again.</p>';
    }else{
      echo '<h5>Thank-you for your submission.<br> An email confirmation should be sent to you shortly.</h5>';
    }    
  echo '<p align="center"><a href="javascript:window.close();">Close Window</a></p>';

}
?>

and this is my "On Submit" before email

worked fine with version 2?
Max_admin 24 Oct, 2008
Hi samoht,

try to cut the onsubmit code into pieces and test, try to add an "else" to the if statement too.

Cheers,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
samoht 25 Oct, 2008
well I have parsed up my On submit as many times as I could think. I even made the form super simple - but each time the form just disappears after the first submit.

here is what debug gives me on the super simple form:


* Form passed first SPAM check OK
* Form passed the submissions limit (if enabled) OK
* Form passed the Image verification (if enabled) OK
* Form passed the server side validation (if enabled) OK
* Form passed the plugins step (if enabled) OK
* Debug End

_POST: Array ( [date_0] => 2008-10-16 [date_1] => 2008-10-24 [submit] => Submit [04eeb9624a4a5d758aa82bb900b4d92f] => 1 )

And here is my super simple html:
<?php

// Check if the form is editable or not  
$readonly = ""; 
$edit = true; 
if ( $_POST['submit'] && $_POST['submit'] == "Confirm" ) { 
    $edit = false; 
    $readonly = "readonly='readonly'"; 
}
?>
<?php 
if ( $edit ) { ?> 
<div  class="form_item">
	<div class="form_element cf_datetimepicker">
	<label class="cf_label">Start Time:</label>
	<input onclick="new Calendar(this);" class="cf_datetime" size="20" id="date_0" name="date_0" type="text">
	</div>
	<div class="clear"> </div>
</div>
<div  class="form_item">
	<div class="form_element cf_datetimepicker">
	<label class="cf_label">End Time:</label>
	<input onclick="new Calendar(this);" class="cf_datetime" size="20" id="date_1" name="date_1" type="text">
	</div>
	<div class="clear"> </div>
</div>
<?php } ?>
<div  class="form_item">
		<?php
		if ( $edit ) { 
		?> 
	<div class="form_element cf_button">
		<input value="Submit" name="submit" type="submit"> 
		<input value="Reset" type="reset">
	</div>
		<?php
		} else { 
		?> 
	<div class="form_element cf_button"> 
		<input type="submit" name="submit" value="Send">  
		<input type="submit" name="submit" value="Edit"> 
	</div>  
		<?php 
		}?>		
	<div class="clear"> </div>
</div>
<?php if(!$edit && $_POST['date_0']){ ?>
<p>Something should be here!</p>
<?php } ?>
GreyHead 25 Oct, 2008
Hi samoht,

That looks OK . . . and what's in the OnSubmit code box? Please post a whole Form Backup here so that we can see all the parts working together.

Bob
samoht 25 Oct, 2008
Hi Bob,

yes, here is a form backup of the simplified form.
Max_admin 25 Oct, 2008
Hi samoht,

I was suggesting that you remove all the onsubmit code and test, then add another piece and test..etc.

now, does your form have any enabled emails ? if not then the onsubmit before email will NOT run!!! add it to the after email one!

Cheers,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
samoht 25 Oct, 2008
Thanks Max,

I will have email recipients but I just had not set them up yet.

Max, you helped me with a query of another table - but I am not understanding how to right a while loop with this object oriented stuff.
global $mainframe;
$database =& JFactory::getDBO();
$database->setQuery( 'SELECT TIMEDIFF(ts_timeout, ts_timein) as totaltime, TIME_TO_SEC(TIMEDIFF(ts_timeout, ts_timein)) as totalsecs, ts_client, ts_dscr, ts_created 
					FROM jos_chronoforms_timesheet2 
					WHERE ts_created BETWEEN "' .$_POST['date_0'].'" AND "'.$_POST['date_1'].'"
					ORDER BY ts_client, ts_created');
$record = $database->loadObject();


If I want to loop through these records do I say:
while ($database->next_record()){
or
while ($record->next_record()) {

or something else obviously - but I don't even now how to google this problem - so I could use some help.

Thanks
GreyHead 25 Oct, 2008
Hi samoht,

Change
$record = $database->loadObject();
to
$record = $database->loadObjectList();
and you should get an array of objects back that you can loop through with foreach. See the Joomla API docs here for a full list of methods.

Bob
samoht 25 Oct, 2008
Hi Bob,

Yes I tried that - but it didn't like that too much so I changed it to
$records = $database->loadAssocList();


and then did a:
foreach ($records as $row) {


That works good.

However, I do have a question with a multiple page form and the email template. Will I be able to email the results of a multiple page form (only the second page) If my results are repeating?

In otherwords, since I loop through my db and separate the results on my form by looping through each client - will the email template be able to handle the loop? I have added hidden inputs to the form and given them names and id's.

here is a screen shot of the second phase of my form.
GreyHead 25 Oct, 2008
Hi samoht,

Pass . . . it depends on how you code it. You can email the whole contents of the Joomla database with the right code. I exaggerate a little perhaps. You have to think through what data you want where and how you are going to get it there. It may be that you need to save your form data before you do the loop. That's possible . . .

If in doubt sketch out a flow chart to make sure that you have the process clear before you write all the code.

Bob
samoht 25 Oct, 2008
Hi Bob,

Thanks for the suggestion. I have tried to sketch out a flow chart - but my ignorance about repeating info in a form is slowing me down.
If you saw my screen shot you saw an example of how the data repeats. In the end I want to mail out several things - Or maybe attachments??
The first thing I want to mail is what you saw in the screen shot.
A single page with all the clients billable work on it. I don't mind saving this data - but I don't think I should because there is calculated data.
I keep thinking I can loop through my $_POST since it is an Array - to build my email ??

The next thing I want to do is breakdown the clients into their own separate emails (or attachments).

If I can code it - I should be able to email it right?
Max_admin 26 Oct, 2008
Hi samoht,

after achieving the result I see in the screenshot, whats your next problem exactly ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
samoht 26 Oct, 2008
Hi Max,

My next problem is setting up my email template to send those results.

if I don't set up the template myself here is what chronoforms auto generates:
<div class="mainform">
<h3>TNTmax Invoice CONFIRMATION</h3>
setQuery( 'SELECT TIMEDIFF(ts_timeout, ts_timein) as totaltime, TIME_TO_SEC(TIMEDIFF(ts_timeout, ts_timein)) as totalsecs, ts_client, ts_dscr, ts_created  					FROM jos_chronoforms_timesheet2  					WHERE ts_created BETWEEN "' .$_POST['date_0'].'" AND "'.$_POST['date_1'].'" 					ORDER BY ts_client, ts_created'); $database->query(); $records = $database->loadAssocList(); 								 $c=1; $prevclient = ''; 	//while($row = mysql_fetch_assoc( $q )){ foreach( $records as $row ) { 		if($row['ts_client'] != $prevclient){ 			if($prevclient != '') { 				//close each client table except for the last 				echo ' 			'."\n"; 			//get the total time in seconds and convert it to a decimal for each client 			$n=$gt/3600; 			echo ' 			          
<table style="border-collapse: collapse; table-layout: fixed; width: 17.3em;" border="0" cellspacing="0" cellpadding="1" align="center">
<tbody>
<tr align="right">
<td><strong>Total time: </strong></td>
<td><strong>'.gmdate("H:i:s", $gt).'<span>{cttime'.$c.'}</span></strong></td>
</tr>
<tr align="right">
<td><strong>Decimal time: </strong></td>
<td><strong>'.round($n, 1) .'<span>{dtime'.$c.'}</span></strong></td>
</tr>
<tr align="right">
<td><strong>Total Cost: </strong></td>
<td><strong>$'.round($n * 37.75, 2) .'<span>{tcost'.$c.'}</span></strong></td>
</tr>
</tbody>
</table>
<br style="clear: both;" />'."\n"; 			//set these back to 0 so that the total does not include the previous clients 			$n=0; 			$gt = 0; 			} 			echo "\n
<h3>SIGN/OFF CLIENT: ".$row['ts_client']."<span>{client".$c."}</span></h3>
\n"; 			echo ' 			          
<table style="border-collapse: collapse; table-layout: fixed; width: 47em;" border="0" cellspacing="0" cellpadding="0" width="97%">
<tbody>
<tr height="20" bgcolor="#555500">
<th>Date:</th><th>Time:</th><th>Description:</th>
</tr>
'; 			$prevclient = $row['ts_client']; 		} 		echo ' 				          
<tr>
<td>'.$row['ts_created'].'<span>{cdate'.$c.'}</span></td>
<td>'.$row['totaltime'].'<span>{ttime'.$c.'}</span></td>
<td>'.$row['ts_dscr'].'<span>{dscr'.$c.'}</span></td>
</tr>
'; 		$gt += $row['totalsecs']; 		$gtt += $row['totalsecs']; 		$c++; 	} 	echo '
</tbody>
</table>
'."\n"; $n=$gt/3600; echo ' 			          
<table style="border-collapse: collapse; table-layout: fixed; width: 17.3em;" border="0" cellspacing="0" cellpadding="1" align="center">
<tbody>
<tr align="right">
<td><strong>Total time: </strong></td>
<td><strong>'.gmdate("H:i:s", $gt).'<span>{cttime'.$c.'}</span></strong></td>
</tr>
<tr align="right">
<td><strong>Decimal time: </strong></td>
<td><strong>'.round($n, 1) .'<span>{dtime'.$c.'}</span></strong></td>
</tr>
<tr align="right">
<td><strong>Total Cost: </strong></td>
<td><strong>$'.round($n * 37.75, 2) .'<span>{tcost'.$c.'}</span></strong></td>
</tr>
</tbody>
</table>
<br style="clear: both;" />'."\n";  echo '
<div class="oa">
<p><strong>Over all Total hours: '.gmdate("H:i:s", $gtt) .'<span>{gthrs}</span></strong><br /> <strong>Over all Total cost: $'. round($gtt/3600 * 37.75, 2) .'<span>{gtcost}</span></strong></p>
</div>
'."\n";  ?></div>
<h3>TNTmax Invoice FORM</h3>
<div class="form_item">
<div class="form_element cf_datetimepicker"><label class="cf_label">Start Time:</label> <span>{date_0}</span></div>
</div>
<div class="form_item">
<div class="form_element cf_datetimepicker"><label class="cf_label">End Time:</label> <span>{date_1}</span></div>
</div>


Which is kind of a mixture of my code but broken -
I assume I can use some of it for my template - but I need to get rid of my query and now loop through $_POST and separate into tables each clients info.
This is where I am struggling - I currently setup hidden inputs for all my returned values and added a counter to them - so $row['ts_client'] has a hidden input id ="client'.$c." (the $_POST would look like $_POST['client1'] etc) Do I need to add a counter like that so that each client is unique? I guess not, but I'm not sure.
samoht 26 Oct, 2008
Part of my problem is that I dont think I can use php in the email template - so I don't know how to set up the loop?

This code looks pretty close if I could use php:

<div class="mainform">
<h3>Invoice List for Andrew for {sdate} to {edate}</h3>
<?php
$prevclient = '';
$c=1;
	foreach( $_POST as $row ) {
	$client = '{client'.$c.'}';
		if($client != $prevclient){ 
			if($prevclient != '') { 				
				//close each client table except for the last 				
				echo '</table>'."\n"; 						
				echo '		
				<table style="border-collapse: collapse; table-layout: fixed; width: 17.3em;" border="0" cellspacing="0" cellpadding="1" align="center">
					<tbody>
						<tr align="right">
							<td><strong>Total time: </strong></td>
							<td><strong><span>{cttime'.$c.'}</span></strong></td>
						</tr>
						<tr align="right">
							<td><strong>Decimal time: </strong></td>
							<td><strong><span>{dtime'.$c.'}</span></strong></td>
						</tr>
						<tr align="right">
							<td><strong>Total Cost: </strong></td>
							<td><strong><span>{tcost'.$c.'}</span></strong></td>
						</tr>
					</tbody>
				</table>
				<br style="clear: both;" />'."\n"; 					
			} 			
			echo "\n<h3>SIGN/OFF CLIENT: <span>{client".$c."}</span></h3>\n"; 			
			echo ' 			          
			<table style="border-collapse: collapse; table-layout: fixed; width: 47em;" border="0" cellspacing="0" cellpadding="0" width="97%">
				<tbody>
					<tr height="20" bgcolor="#555500">
						<th>Date:</th>
						<th>Time:</th>
						<th>Description:</th>
					</tr>'; 			
			$prevclient = '{client'.$c.'}'; 		
		} 		
		echo ' 				          
		<tr>
			<td><span>{cdate'.$c.'}</span></td>
			<td><span>{ttime'.$c.'}</span></td>
			<td><span>{dscr'.$c.'}</span></td>
		</tr>'; 		
		$gt += $row['totalsecs']; 		
		$gtt += $row['totalsecs']; 	
		$c++;
	} 	
	echo '
	</tbody>
</table>'."\n";  
echo ' 			          
	<table style="border-collapse: collapse; table-layout: fixed; width: 17.3em;" border="0" cellspacing="0" cellpadding="1" align="center">
		<tbody>
			<tr align="right">
				<td><strong>Total time: </strong></td>
				<td><strong><span>{cttime'.$c.'}</span></strong></td>
			</tr>
			<tr align="right">
				<td><strong>Decimal time: </strong></td>
				<td><strong><span>{dtime'.$c.'}</span></strong></td>
			</tr>
			<tr align="right">
				<td><strong>Total Cost: </strong></td>
				<td><strong>$<span>{tcost'.$c.'}</span></strong></td>
			</tr>
		</tbody>
	</table>
	<br style="clear: both;" />'."\n";  
	echo '
	<div class="oa">
		<p><strong>Over all Total hours: <span>{gthrs}</span></strong><br /> 
		<strong>Over all Total cost: $<span>{gtcost}</span></strong></p>
	</div>'."\n";  
	?>
</div>
Max_admin 26 Oct, 2008
Hi samoht,

if you can do all that with the onsubmit code then you CAN do it in the template, the template can run PHP, disable the editor for the email in the Email properties area and then "apply" then save the whole form, then open it again to find that the email template editor is just a normal textarea to let you write your own code with PHP!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
samoht 26 Oct, 2008
Hi Max,

Are you referring to the editor in the attached screen shot?
I dont seem to have access??

[attachment=0]editor.gif[/attachment]
GreyHead 26 Oct, 2008
Hi samoht,

You need to add From Email field to enable this email box - then you will have access.

Bob
samoht 26 Oct, 2008
I had "From Email" on their ??

But I did notice that when I added "From Name" the background turned from red to green. But I still did not get access to the editor??
GreyHead 27 Oct, 2008
Hi Samoht,

My mistake - it was late at night. You need to go through a little process.

Create an email, set the 'Email Template Editor' to No, click Apply for the Email, then Apply for the form. Then when you open the Emails Template tab you should see an open text area without the WYSIWYG editor.

Bob

[attachment=0]27-10-2008 05-56-12.png[/attachment]
samoht 28 Oct, 2008
Thanks for that Bob!
samoht 29 Oct, 2008
I do still have one problem.

For some reason I am sending out two emails?
One is basically blank because the template code has not fired and the second is what I want.

I set my On Submit Before email to check the name of the "Submit" and tried to repress sending an email like this:
<?php

// If the form has just been submitted  
// re-display with Edit & Pay buttons 
if ( $_POST['submit'] == 'Submit') { 
    $_POST['submit'] = 'Confirm'; 
    $error_found = true;
    $rows[0]->emailresults = 0;
    showform($_POST); 
} elseif ( $_POST['submit'] == 'Edit') { 
    $_POST['submit'] = 'Submit'; 
    $error_found = true; 
    showform($_POST); 
} else {

  echo '<h5>Thank-you for your submission.<br> An email confirmation should be sent to you shortly.</h5>';
    
  echo '<p align="center"><a href="javascript:window.close();">Close Window</a></p>';

}


this worked fine in version 2.0 - what am I doing wrong??
Max_admin 29 Oct, 2008
I can't understand what the code does but an example of a problem is the $rows[0]->emailresults line which doesn't exist anymore in V3

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
samoht 29 Oct, 2008
yes I thought that might be a problem.

I guess I still need away to not send the first form $error_found = true; doesn't seem to work and as you say $rows[0]->emailresults
is no longer valid in v3.0

Any Ideas how to only send the last form?

Also - can I send attachments with chronoforms?
Max_admin 29 Oct, 2008
Hi,

in V3, $emails[0]->enabled = 0; will block the first email you have setup.

you can try the file uploads tab

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
samoht 29 Oct, 2008
Thanks Max,

Regarding the file uploads - to try to send attachments: Can I add an input that contains the file name to be added as an attachment?
if yes, does this need a certain syntax and name?

Also, the tool tip makes it sound like file uploads - section just makes the form "allow" uploads though the form - and if I don't specify extensions that anything will be allowable?
Max_admin 29 Oct, 2008
Hi samoht, Did you look at the fileuploads tab hints and tooltips ? I think all this is just written there!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
samoht 29 Oct, 2008
No I didn't see that. Where is it?
samoht 29 Oct, 2008
Basically,
I have the attachments in the root folder and they all have a name that ends with "-invoice_m-d-Y.doc" (where m-d-Y is the date the file was created)
I want to be able to query the directory for all files that match today's m-d-Y in the end of their file name and include those as attachments to my email.

If file uploads will help me - then great. But I assume that Ill need a input (or multiple inputs) that stores the path to the file - yes?
Max_admin 29 Oct, 2008
Hi, I didn't understand this, this is a very custom solution and you will need some PHP code to do this task, after you get the PHP code to parse your files and get their names and path, you can post again and I will show you the code to attach them to the email itself, assuming you have V3 stable installed!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
samoht 29 Oct, 2008
cool,

yes I have V3 installed.
Here is the code that creates the WORD documents (it works!)


<?php

// Check if the form is editable or not  
$readonly = ""; 
$edit = true; 
if ( $_POST['submit'] && $_POST['submit'] == "Confirm" ) { 
    $edit = false; 
    $readonly = "readonly='readonly'"; 
}
?>

<?php if($_POST['date_0']){ ?>
<div class="mainform">

<h3>TNTmax Invoice CONFIRMATION</h3>

<?php
global $mainframe;
$database =& JFactory::getDBO();
$database->setQuery( 'SELECT TIMEDIFF(ts_timeout, ts_timein) as totaltime, TIME_TO_SEC(TIMEDIFF(ts_timeout, ts_timein)) as totalsecs, ts_client, ts_dscr, ts_created 
					FROM jos_chronoforms_timesheet2 
					WHERE ts_created BETWEEN "' .$_POST['date_0'].'" AND "'.$_POST['date_1'].'"
					ORDER BY ts_client, ts_created');
$database->query();
$records = $database->loadAssocList();
								

$c=1;
$t=0;
$prevclient = '';
 
	foreach( $records as $row ) {
		if($row['ts_client'] != $prevclient){
			if($prevclient != '') {
				//this is just to add extra rows for filling out the page!
				for($w=0; $w < 17 - $t; $w++){
					$str .=  '
					<tr>
						<td> </td>
						<td> </td>
						<td> </td>
						<td> </td>
					</tr>';
				}
				//get the total time in seconds and convert it to a decimal for each client
				$n=$gt/3600;
				//close each client table except for the last
				$str .=  '
							<tr style="page-break-inside:avoid;height:.2in">
							  <td width=414 valign=top style="width:310.5pt;border:none;padding:2.15pt 5.75pt 2.15pt 5.75pt;  height:.2in">
							  <p class=MsoNormal> </p>
							  </td>
							  <td width=204 colspan=2 style="width:153.0pt;border:none;border-right:solid windowtext 1.0pt;  padding:2.15pt .15in 2.15pt .15in;height:.2in">
							  <p class=RightAligned>TOTAL</p>
							  </td>
							  <td width=102 style="width:76.5pt;border-top:none;border-left:none;  border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;  padding:2.15pt .15in 2.15pt .15in;height:.2in">
							  <p class=Amount>$'.round($n * 37.75, 2) .'</p>
							  </td>
							</tr>
						</table>
					</div>
					<p class=MsoNormal> </p>
					<div align=center>
						<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=720 style="width:7.5in;border-collapse:collapse">
						 <tr style="height:109.9pt">
						  <td width=720 valign=bottom style="width:7.5in;padding:5.75pt 5.75pt 5.75pt 5.75pt;  height:109.9pt">
						  <p class=MsoNormal>Make all checks payable to Andrew Adcock</p>
						  <p class=MsoNormal>Total due in 15 days. Overdue accounts subject to a  service charge of 1% per month.</p>
						  <p class=MsoNormal> </p>
						  </td>
						 </tr>
						 <tr style="height:.3in">
						  <td width=720 style="width:7.5in;padding:0in 5.4pt 0in 5.4pt;height:.3in">
						  <p class=Thankyou>Thank you for your business!</p>
						  </td>
						 </tr>
						</table>
					</div>
					<p class=MsoNormal> </p>
					</body>
				</html>	'."\n";
				fwrite($fp, $str);
				fclose($fp); 
				//set these back to 0 so that the total does not include the previous clients
				$n=0;
				$gt = 0;
				$t=0;
				$fp='';
				$str='';
			}
			// start the new WORD document
			
			$cname = str_replace(".","-",$row['ts_client']);
			$filename = $cname.'-invoice_'.date('m-j-Y').'.doc';
			$fp = fopen($filename, 'x+');
			//start writting the file contents.
			//throw in some style 
			$str = '
			<html>
			<style>
			<!--
			 /* Font Definitions */
			 @font-face
				{font-family:Tahoma;
				panose-1:2 11 6 4 3 5 4 4 2 4;}
			 /* Style Definitions */
			 p.MsoNormal, li.MsoNormal, div.MsoNormal
				{margin:0in;
				margin-bottom:.0001pt;
				line-height:110%;
				font-size:8.5pt;
				font-family:Tahoma;
				letter-spacing:.2pt;}
			h1
				{margin:0in;
				margin-bottom:.0001pt;
				text-align:right;
				line-height:110%;
				font-size:20.0pt;
				font-family:Tahoma;
				color:gray;
				letter-spacing:.2pt;}
			h2
				{margin:0in;
				margin-bottom:.0001pt;
				line-height:110%;
				font-size:8.0pt;
				font-family:Tahoma;
				text-transform:uppercase;
				letter-spacing:.2pt;}
			h3
				{margin:0in;
				margin-bottom:.0001pt;
				line-height:110%;
				font-size:8.5pt;
				font-family:Tahoma;
				letter-spacing:.2pt;
				font-weight:normal;
				font-style:italic;}
			p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
				{margin:0in;
				margin-bottom:.0001pt;
				line-height:110%;
				font-size:8.0pt;
				font-family:Tahoma;
				letter-spacing:.2pt;}
			p.Companyname, li.Companyname, div.Companyname
				{margin-top:7.0pt;
				margin-right:0in;
				margin-bottom:0in;
				margin-left:0in;
				margin-bottom:.0001pt;
				line-height:110%;
				font-size:12.0pt;
				font-family:Tahoma;
				letter-spacing:.2pt;
				font-weight:bold;}
			p.Columnheading, li.Columnheading, div.Columnheading
				{margin:0in;
				margin-bottom:.0001pt;
				text-align:center;
				line-height:110%;
				font-size:8.0pt;
				font-family:Tahoma;
				letter-spacing:.2pt;
				font-weight:bold;}
			p.RightAligned, li.RightAligned, div.RightAligned
				{margin:0in;
				margin-bottom:.0001pt;
				text-align:right;
				line-height:110%;
				font-size:8.0pt;
				font-family:Tahoma;
				text-transform:uppercase;
				letter-spacing:.2pt;}
			p.Thankyou, li.Thankyou, div.Thankyou
				{margin:0in;
				margin-bottom:.0001pt;
				text-align:center;
				line-height:110%;
				font-size:10.0pt;
				font-family:Tahoma;
				letter-spacing:.2pt;
				font-weight:bold;}
			p.Amount, li.Amount, div.Amount
				{margin:0in;
				margin-bottom:.0001pt;
				text-align:right;
				line-height:110%;
				font-size:8.5pt;
				font-family:Tahoma;
				letter-spacing:.2pt;}
			@page Section1
				{size:8.5in 11.0in;
				margin:.5in .5in 36.7pt .5in;}
			div.Section1
				{page:Section1;}
			 /* List Definitions */
			 ol
				{margin-bottom:0in;}
			ul
				{margin-bottom:0in;}
			-->
			</style>
			<body>
			'."\n";
			$strc=$row['ts_client'];
			$fl=$strc[0];
			//begin actual page
			$str .= '
			<div align=center>
				<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=720 style="width:7.5in;border-collapse:collapse">
				 <tr style="height:39.75pt">
				  <td width=361 rowspan=2 valign=top style="width:270.6pt;padding:0in 5.4pt 0in 5.4pt;  height:39.75pt">
				  <p class=Companyname>Andrew T Adcock</p>
				  <h3>Web work</h3>
				  <p class=MsoNormal> </p>
				  <p class=MsoNormal>233 Hamel Ave</p>
				  <p class=MsoNormal>Glenside, PA 19038</p>
				  <p class=MsoNormal>Phone (267)943-1097  </p>
				  </td>
				  <td width=359 valign=top style="width:269.4pt;padding:0in 5.4pt 0in 5.4pt;  height:39.75pt">
				  <h1>INVOICE</h1>
				  </td>
				 </tr>
				 <tr style="height:39.75pt">
				  <td width=359 valign=bottom style="width:269.4pt;padding:0in 5.4pt 0in 5.4pt; height:39.75pt">
				  <p class=RightAligned>Invoice #'.$c.'</p>
				  <p class=RightAligned>Date: '.date('F jS, Y').'</p>
				  </td>
				 </tr>
				</table>
			</div>
			<p class=MsoNormal> </p>
			<div align=center>
				<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=720 style="width:7.5in;border-collapse:collapse">
				 <tr style="height:1.0in">
				  <td width=360 valign=top style="width:3.75in;padding:0in 5.4pt 0in 5.4pt;  height:1.0in">
				  <h2>To:</h2>
				  <p class=MsoNormal>Irene Galvan </p>
				  <p class=MsoNormal>TNTmax, LLC</p>
				  <p class=MsoNormal>491 Sicomac Avenue</p>
				  <p class=MsoNormal>Wyckoff, NJ 07481-1136</p>
				  <p class=MsoNormal></p>
				  </td>
				  <td width=360 valign=top style="width:3.75in;padding:0in 5.4pt 0in 5.4pt;  height:1.0in">
				  <h2>For:</h2>
				  <p class=MsoNormal>'.$row['ts_client'].'</p>
				  <p class=MsoNormal>#'.$fl.date('mdy').rand(31,69).'</p>
				  </td>
				 </tr>
				</table>
			</div>
			<p class=MsoNormal> </p>
			<p class=MsoNormal> </p>';
			$str .=  '
			<div align=center>	
				<table class=MsoNormalTable border=1 cellspacing=0 cellpadding=0 width=720 style="width:7.5in;border-collapse:collapse;border:none">
					<tr height=20 class="headrow">
						<td width="66%"><p class=Columnheading>Description:</p></td>
						<td width="12%"><p class=Columnheading>Hours:</p></td>
						<td width="12%"><p class=Columnheading>Rate:</p></td>
						<td width="12%"><p class=Columnheading>Amount:</p></td>
					</tr>';
			$prevclient = $row['ts_client'];
		}
		$ts=$row['totalsecs']/3600;
		$str .=  '
			<tr>
				<td><p class=MsoNormal>'.$row['ts_dscr'].'</p></td>
				<td><p class=MsoNormal>'.round($ts,2) .'</p></td>
				<td><p class=Amount>$37.75</p></td>
				<td><p class=Amount>'.round($ts * 37.75, 2) .'</p></td>
			</tr>';
		$gt += $row['totalsecs'];
		$gtt += $row['totalsecs'];
		$c++;
		$t++;
	}
	for($w=0; $w < 17 - $t; $w++){
		$str .=  '
		<tr>
			<td> </td>
			<td> </td>
			<td> </td>
			<td> </td>
		</tr>';
	}
	$n=$gt/3600;
	$str .=  '
					<tr style="page-break-inside:avoid;height:.2in">
					  <td width=414 valign=top style="width:310.5pt;border:none;padding:2.15pt 5.75pt 2.15pt 5.75pt;  height:.2in">
					  <p class=MsoNormal> </p>
					  </td>
					  <td width=204 colspan=2 style="width:153.0pt;border:none;border-right:solid windowtext 1.0pt;  padding:2.15pt .15in 2.15pt .15in;height:.2in">
					  <p class=RightAligned>TOTAL</p>
					  </td>
					  <td width=102 style="width:76.5pt;border-top:none;border-left:none;  border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;  padding:2.15pt .15in 2.15pt .15in;height:.2in">
					  <p class=Amount>$'.round($n * 37.75, 2) .'</p>
					  </td>
					</tr>
				</table>
			</div>
			<p class=MsoNormal> </p>
			<div align=center>
				<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0 width=720 style="width:7.5in;border-collapse:collapse">
				 <tr style="height:109.9pt">
				  <td width=720 valign=bottom style="width:7.5in;padding:5.75pt 5.75pt 5.75pt 5.75pt;  height:109.9pt">
				  <p class=MsoNormal>Make all checks payable to Andrew Adcock</p>
				  <p class=MsoNormal>Total due in 15 days. Overdue accounts subject to a  service charge of 1% per month.</p>
				  <p class=MsoNormal> </p>
				  </td>
				 </tr>
				 <tr style="height:.3in">
				  <td width=720 style="width:7.5in;padding:0in 5.4pt 0in 5.4pt;height:.3in">
				  <p class=Thankyou>Thank you for your business!</p>
				  </td>
				 </tr>
				</table>
			</div>
			<p class=MsoNormal> </p>
		</body>
	</html>	'."\n";
		fwrite($fp, $str);
		fclose($fp); 

?>
</div>
<?php } ?>
<?php 
if ( $edit ) { ?> 
<h3>TNTmax Invoice FORM</h3>
<div  class="form_item">
	<div class="form_element cf_datetimepicker">
	<label class="cf_label">Start Time:</label>
	<input onclick="new Calendar(this);" class="cf_datetime" size="20" id="date_0" name="date_0" type="text">
	</div>
	<div class="clear"> </div>
</div>
<div  class="form_item">
	<div class="form_element cf_datetimepicker">
	<label class="cf_label">End Time:</label>
	<input onclick="new Calendar(this);" class="cf_datetime" size="20" id="date_1" name="date_1" type="text">
	</div>
	<div class="clear"> </div>
</div>
<?php } ?>
<div  class="form_item">
		<?php
		if ( $edit ) { 
		?> 
	<div class="form_element cf_button">
		<input value="Submit" name="submit" type="submit"> 
		<input value="Reset" type="reset">
	</div>
		<?php
		} else { 
		?> 
	<div class="form_element cf_button"> 
		<input type="submit" name="submit" value="Send">  
		<input type="submit" name="submit" value="Edit"> 
	</div>  
		<?php 
		}?>		
	<div class="clear"> </div>
</div>


Then in my email template I have the code to produce the email that I want. So I assume that I'll need to put the code for collecting the created WORD docs in the email template as well. The directory is at this point - the same directory that the form is run from (which I assume is the root directory).
samoht 30 Oct, 2008
ok so I found a way to grab all of my attachments

here is my code:

$f=1;
$fdate = "*-invoice_".date('m-d-Y').".doc";
foreach (glob("$fdate") as $filename) {
    echo '<input type="hidden" id="att'.$f.'" name="att'.$f.'" value="'.$filename.'"> '. "\n";
	$f++;
}

This will return all the files that I need to attache as hidden inputs with a proper name and id - So I should be able add one step to my form:
Step 1 => create files
Step 2 => grab files
Step 3 => send email with files as attachments using the email template.
Max_admin 30 Oct, 2008
Ok great, at the on submit before email, loop all your files and do this :

$attachments['file_name'] = 'file_path_on_server';


this will do the trick!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
samoht 30 Oct, 2008
Hi Max,

Sorry I dont quite understand,

would this work:

$fdate = "*-invoice_".date('m-d-Y').".doc";
foreach (glob("$fdate") as $filename) {
    $attachments['$filename'] = 'www.myserver.com/';    
}



well obviously it wont work because I tried it. Why wont it work?
What part am I miss understanding?

thanks so much for your help!!
Max_admin 30 Oct, 2008
Hi samoht,

assuming you have a file field called file1 at the path : c:/server/path/at/linux/or/windows/www/domain.com/images/ourimages/image.png

then to attach it:
$attachments['file1'] = 'c:/server/path/at/linux/or/windows/www/domain.com/images/ourimages/image.png'; 
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
samoht 31 Oct, 2008
thanks so much Max,

It turns out that I only needed a relative path - and that the glob function returns an array so it works just fine to set it up like this:

$fdate = "invoices/*-invoice_".date('m-d-Y').".doc";
$attachments = glob($fdate);


Very Cool! - Chronoforms rules!
This topic is locked and no more replies can be posted.