Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 6702 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi there,

I have a course search results page that lists found courses. Each result is clickable and takes you to a detail page that displays full information for the course. A Register button on this page opens the registration form where the student can enter their details. I am trying to get the Course Code to be automatically entered into the new registration database record and have it displayed above the blank registration form before the student enters theoir info. How do I get the Course Code which is in a database field in the Course Information DB to be transferred into the new record in the Registrations DB when the student clicks the Register button in the detail page?

Posted (edited)

How about using a Script Parameter to pass the Course Code?

Whoops! Didn't realise this was a PHP forum, I'll butt out, sorry!

Edited by Guest
Posted

Hi,

If you are using a form you can include it as a hidden field and then you can use that by reference the POSTed value.

If you are using a simple link to transfer to the form, pass the course code as a variable with the url

http://www.yoursite.com/page.php?coursecode=ABC

The important part here is firstly the ? which tells the url it is a variable and then you have the variable name, followed by the value.

On your details page, you can create a variable called $courseCode which depending on your method of passing you will then reference either $_GET['courseCode'] or $_POST['courseCode']. This is assuming your hidden field or the variable are called courseCode.

HTH

Posted

Hi Andy,

Where I get confused is combining a form with the detail page. The detail page is just the course information and has no form fields, just the register button that takes you to the registration form. Is the hidden field part of the script of the detail page or is it part of the registration form page?

Posted

brainonastick,

You would want to pass the code through your register button.

If you are using an a href then simply append a variable to it using ?courseCode=1234

Then, on your registration form page you can reference the variable either by creating a new variable first (the preferred method) such as

$courseCode = $_GET['courseCode'];

or referencing it directly using $_GET['courseCode'];

Then you can utilize this in your registration form as a hidden field.

Thus allowing you to pass the value from one page to the next and finally through to the registration part of your database.

Does this help any?

Posted

Hi Andy,

Thanks, I've almost got it but just need a bit more clarification. When you say pass the code through your register button do you mean add it to the action performed by the button?

My registration button's action is registration_form.php which opens the blank registration form.

So do I just make the action: registration_form.php?courseCode=1234 ?

The courseCode is a variable so how do I get 1234 to be the particular courseCode from the detail.php page? Do I write it registration_form.php?courseCode=' ' ?

Thanks again.

Posted

so from the results page we would have something like

Course # || Description

M1234 || Math 100

M1345 || Math 200

etc

I am guessing 'M1234' is clickable with a '$recid' to go to a 'Course_Detail.php' page.

On the Course_Detail.php page:

(use $recid to find the course)

Your form will include:

(hidden fields name=course value=<? echo $coursenumber;?>

Course #:) M1234

Description: Math 100

Click will take you to another form like 'confirm_registration.php'

In confirm_registration.php

You receive the $coursenumber = $_REQUEST['course'];

Use this number to enter into the new database.

Posted (edited)

Hey,

No worries.

I know it can be frustrating but once it clicks it is a wonderful thing. Basically when it comes to how you reference your data that is entirely upto you.

If you are going to use the information more than once on the page it is a lot easier to create a variable first and then ref that instead of retyping the result['fieldname'][repetition]; each time. However in your example below I left it as you entered.

I did however change your open php tags to the full <?php tag instead of the abbreviated

These CAN cause issues if you reference XML on a page directly, so try and get in the habit of using the full version.


<?php

include_once('FX/FX.php');

include_once('FX/server_d ata.php');



$recid = $_REQUEST['recid'];

$groupSize='1';



$show_found_course=new FX($serverIP,$webCompanio nPort,'FMPro7');

$show_found_course->Se tDBData('Course Information.fp7','Course Information',$groupSize); 

$show_found_course->Se tDBPassword('fmsadmin','f msadmin');

$show_found_course->Ad dDBParam('-recid', $recid);

$show_found_courseResult= $show_found_course->FM Find();



?>







&g t; //other course info echoed here etc...
Course Code: echo $show_found_courseData['C ourse_Code'][0]; ?>
Register& gt;




On your result page your $_GET must match what was passed as the name,





<?php

include_once('FX/FX.php');

include_once('FX/server_data.php');

$courseCode = $_GET['Course_Code'];





This SHOULD enable you to pass the Course Code through to the second page and then reference that in your form.

HTH

Edited by Guest
Posted

Hi Andy,

I'm always happy to learn the quicker more efficient way of coding so thanks for the tip re method of referencing. The confusion for me still lies with the courseCode vs Course_Code variable.

I have tested the code from the initial find to the search results to the use of -recid to display a particular course. The register button (which is really just a link at the moment) still does not pick up the course code data and pass it on to the registration form as a hidden field.

Here's everything:

//Home Page portal showing upcoming courses:

<?

$courses=$_REQUEST['Course_Portal_Status'];

if(isset($_GET['skip'])){ $skipSize=$_GET['skip'];}else{$skipSize='0';}

$groupSize='20';

$Course_Search=new FX($serverIP,$webCompanionPort,'FMPro7');

$Course_Search->SetDBData('Course Information.fp7','Course Information',$groupSize);

$Course_Search->SetDBPassword('fmsadmin','fmsadmin');

$Course_Search->AddDBParam('Course_Portal_Status','UPCOMING','eq');

$Course_Search->AddSortParam('Course_Date_First','ascend');

$Course_Search->FMSkipRecords($skipSize);

$Course_SearchResult=$Course_Search->FMFind();

$returnedCount=$Course_SearchResult['foundCount'];

$searchVariable=explode('.',$key);

$currentRecord=$searchVariable[0];

?>

//blah blah blah

<? foreach($Course_SearchResult['data'] as $key=>$Course_SearchData){ $searchVariable=explode('.',$key); $currentRecord=$searchVariable[0]; ?>

<? echo $Course_SearchData['Course_Name'][0]; ?>

<? echo $Course_SearchData['Course_Date_First'][0]; ?>

<? echo $Course_SearchData['Venue_Name'][0]; ?>

<? echo $Course_SearchData['Course_Capacity'][0]; ?>

<? } ?>

//Then the find_this_course.php code:

<?

include_once('FX/FX.php');

include_once('FX/server_data.php');

$recid = $_REQUEST['recid'];

$groupSize='1';

$show_found_course=new FX($serverIP,$webCompanionPort,'FMPro7');

$show_found_course->SetDBData('Course Information.fp7','Course Information',$groupSize);

$show_found_course->SetDBPassword('fmsadmin','fmsadmin');

$show_found_course->AddDBParam('-recid', $recid);

$show_found_courseResult=$show_found_course->FMFind();

echo $show_found_courseResult['errorCode'];

foreach($show_found_courseResult['data'] as $key=>$show_found_courseData);

?>

//with the register button as it stands:

Register;

Posted

Steven,

is the

inside the

?

For error checking - I suggest using lot's of "echo" and "print_r" to see what data is being passed.

I often use print_r($_POST) or print_r($_REQUEST) to double check what variables are being passed from page to page.

This may be the key to trouble shooting and finding out where the error lies.

Also specifically an

echo "course number = " . $coursecode1;

may be helpful.

  • 2 weeks later...
Posted

Hi Mlindal,

The fix was as follows:

1. On the detail page:

method="post" name="Register">Register

2. On the registration form page the passed serial number and course code were included as hidden fields:

and:

3. So on the form processing page it was possible to add:

$coursecode1 = $_POST['coursecode'];

$serial_number = $_POST['serial_number'];

and these fields went into the database along with the data from the web form text fields.

Cheers,

Steven

This topic is 6702 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.