Forums

Handling Form Input over 2 Pages

phreak 14 Feb, 2008
Hi all,

I'd like to make a newsletter registration with Chronoforms. And the thing is that i'd like my users to put in their email in a modul on the frontpage, to klick "continue" and then they will be sent to a form with more fields, where their email is already filled in.

Like that:😛

FRONTPAGE : Module with Email-Field > Continue
2nd PAGE: Component with Email-Field (alreay filled in), Name, Occupation, etc.

Does anybody know how this can theoretically be done ?

Thanx<br><br>Post edited by: phreak, at: 2008/02/13 19:05
GreyHead 14 Feb, 2008
Hi phreak,

Yes, you can do that. A bit fiddly but possible.

You need to create the first form and put it into a module. There's a workaround to do that in the FAQs.

Save the info from this form into the table for the second form (so it's all in the same place). Then use the Form URLs | Redirect URL to send them to the second form (you'll need to add a little code to include their record id).

On the second form use the record id to add in whatever info you already have and then save the extra info into the same database table.

Basically two forms, one table linked by a user id.

Bob
phreak 15 Feb, 2008
Hey Greyhead,

Wow, your return was so fast and nice i immideatly bought the ad free licence,

I created for both forms a database table. Then i went to the first form and edited the "Auto Generate" Code that way, the name of the 2nd database will be in the setQuery statement (just changed #__chronoforms_1 into #__chronoforms_2).


<?php 
 global $database;	
$database->setQuery( "INSERT INTO #__chronoforms_2 VALUES  (
'' , '". date('Y-m-d')." - ".date("H:i:«»s"«»)."', '".$_SERVER['REMOTE_ADDR']."' , '".mosGetParam($_POST,'email','')."');" );
if (!$database->query()) {
echo "<script> alert('".$database->getErrorMsg()."'); window.history.go(-1); </script>
"; } ?>


(you'll need to add a little code to include their record id). On the second form use the record id to add in whatever info you already have and then save the extra info into the same database table.



Now the hard part. How do i write the IP information into the tables in the 1rst form and how can the 2nd form retrieve that. It needs some php-help i guess.

Thanx for a hint,
phreak<br><br>Post edited by: phreak, at: 2008/02/15 23:44
GreyHead 16 Feb, 2008
Hi phreak,

I'd use the same table (#__chronoforms_2 say) for both forms. You'll need to change the Autogenerated code for both forms. Let's say that you capture 'date', 'email' & 'ip_address' on the first form and 'address' and 'occupation' on the second.

Your database table needs to have (at least) these four fields plus cf_id.

In the Autogenerated field for form one you'd use SQL like:
$sql = "
  INSERT 
    INTO #__chronoforms_2 
    SET date = date('Y-m-d')." - ".date("H:i:«»s"«»)."',
        ip_address = '".$_SERVER['REMOTE_ADDR']."',   
        email = '".$_POST['email']."'";
and in the second form you'd use SQL like:
UPDATE #__chronoforms_2 
    SET address = '".$_POST['address']."',
        occupation = '".$_POST['occupation']."'
    WHERE cf_id = $_POST['cf_id']";
Bob
phreak 19 Feb, 2008
Hey there,

Uah, thats a big jump into cold water for me. I tried to rewrite the code you gave me to make it work with the correct syntax.
But i'm already stuck with the first one, database tables do not populate with data.

<?php 
 global $database; 
 $database->setQuery( "INSERT INTO #__chronoforms_2 VALUES (
 '' , '".date('Y-m-d')." - ".date("H:i:«»s"«»)."', ipadress = '".$_SERVER['REMOTE_ADDR']."' , email = '".$_POST['email']."';
 	);"
 );
 ?>


Can somene give me a handful check ?

Thanx
Max_admin 20 Feb, 2008
Hi Phreak,

I read only the first post and I have some idea, why don't you just create the 2 different form as normal and for the first form (the one on the home page) you add this code at the on submit after email :

mosRedirect('2nd_form_url&email='.$_POST['email']);


now at the end form the email field should look like this :


<input type="text" name="email" value="<?php echo $_GET['email']; ?>">


What about this ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.