Skip to main content
December 5, 2012
Question

How to send selected record to another page?

  • December 5, 2012
  • 1 reply
  • 4133 views

Using DW CS6 MySQL. Win 7 with XAMPP testing server  My Skiill Level: learning DW

I have a  page that lists classes from the classdata table, using a repeat region.  There is a radio button in front of each line to select.  The user should click the radio button in front of the class they want, then click the SUBMIT button on the bottom.  How to I get that SUBMIT button to open the Registration page and hand over the correct record?  I have been trying using POST but am not sure how to pick up the data class list in the 2nd page.   Do I send data using POST or GET or is there a way to ensure I have the correct record on the Registration page? Once they register, I will need that class data for the CC transaction. I have been reading but all the examples are for input data and I am not sure how to proceed.

Thanks in advance for any help.

-CL

This topic has been closed for replies.

1 reply

Participating Frequently
December 5, 2012

>How to I get that SUBMIT button to open the

>Registration page and hand over the correct record?

When a form is submitted all the field values in the form are sent to the page that is listed in the forms action

I assume they can only register for one class which is why you are using a radio button, not a checkbox. If that's the case, then the name attribute for all radio buttons should be the same.

>Do I send data using POST or GET

You typically use POST when the data you are passing is to be used in a database insert/update action, or for other security reasons. In your case, you should be using POST. GET can be used for simple queries and when you want to have a querystring in the url.

To get the posted value

$selected_class = $_POST['class']

December 5, 2012

Thanks for your help. I am still not sure how to proceed.  The ClassID field makes more sense to work with as it is not text, so that is what I want to send from the classlist page to the registration page.

So here is the code from the ClassList.php:

<form action="registration.php" method="post" name="Glancefm" id="Glancefm">

      <br />

      <table width="855" border="2" align="center" cellpadding="8" cellspacing="10" id="Glancetb">

        <tr>

          <th width="60" scope="col"> </th>

          <th width="60" scope="col">Class ID#</th>

          <th scope="col">Class</th>

          <th width="100" scope="col">Date</th>

          <th width="64" scope="col">Register</th>

        </tr>

        <?php do { ?>

          <tr>

            <td width="60"><input <?php if (!(strcmp($row_rsNewClassfm['ClassID'],"Select Class"))) {echo "checked=\"checked\"";} ?> type="radio" name="radio" id="Select Class" value="Select Class" />

            <label for="Select Class">Select Class</label></td>

            <td width="60"><?php echo $row_rsNewClassfm['ClassID']; ?></td>

            <td><?php echo $row_rsNewClassfm['ClassName']; ?></td>

            <td width="100"><?php echo $row_rsNewClassfm['StartingDate']; ?></td>

            <td> </td>

          </tr>

          <?php } while ($row_rsNewClassfm = mysql_fetch_assoc($rsNewClassfm)); ?>

      </table>

      <p> </p>

      <p>

        <input type="submit" name="Register" id="Register" value="Submit" />

        <br />

      </p>

    </form>

So I am assuming this is all correct.  I still am not sure how to show the data in the registration.php page....here is the code from that:

<form id="registrationfm" name="registrationfm" method="post" action="">

         <$selected_ClassID = $_POST['ClassID']>

          Class ID:

          <?php echo $_POST['ClassID']; ?>

        </form>

How do I get the data to appear on the registration page?  Is this correct?  I am getting an error Undefined Index....

Participating Frequently
December 5, 2012

It's what's in the 'value' attribute that gets passed over to the script. Currently you have that hardcoded: value="Select Class

You want to set the value to the ClassID

value=<?php echo $row_rsNewClassfm['ClassID']; ?>

Before going any further, get yourself more familiar with HTML. Trying to learn SQL, scripting languages and DW without a solid understanding of HTML is going to be difficult.