Actually, that action should be going to a PHP page
<form action='page2_or_whatever.
etc
Main Topics
Browse All TopicsI have a function buildselect which gets the values of fields from a table, and displays the data in drop down menus which works fine. What I want to do, is get the value that the user chooses from each of the menus and post them to the next page where they are used as sessions. I'm not getting any errors, and which ever way I try, the values don't get posted across. Any ideas would be appreciated, thanks. The following is my code:
<?PHP
session_start();
require("connect.php");
function buildSelect( $field_name, $curValue, $qry ) {
$fldT = "<select field_name='$field'>\n";
$rs = @mysql_query( $qry );
if ( $rs )
while ( $rw = @mysql_fetch_array( $rs, MYSQL_NUM ) ) {
$val = $rw[0];
$sel = ( $val == $curValue ) ? " selected='selected' " : "";
$fldT .= "<option value=".$val." $sel>$val</option>\n";
}
$fldT .= "</select>\n";
return $fldT;
}
$client = ( isset($_POST['client']) ) ? $_POST['client'] : "" ;
$name = ( isset($_POST['name']) ) ? $_POST['name'] : "$name" ;
$query = "SELECT * FROM clients ORDER BY 'clients' LIMIT $offset, $rowsPerPage";
?>
<? echo buildSelect("client", $_POST['client'], "select client from Clients order by client"); ?>
<? echo buildSelect("name" , $_POST['name'], "select Name from Clients order by Name"); ?>
<? echo buildSelect("address" , $_POST['address'], "select Address from Clients order by Address"); ?>
On page 2, I simply have:
<?php
session_start();
$_SESSION['site'] = $_POST['site'];
$_SESSION['client'] = $_POST['client'];
$_SESSION['campaign'] = $_POST['campaign']
etc ....
?>
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I've got a Form set up which is using the values from the buildselect function, and which also allows the user to enter values into normal textboxes. The values from these drop down meuns don't post through to the next page but the values that the user enters into the text boxes do. Below is some of my form, integrating both the the build select and textboxes.
<form id="form1" name="form1" method="post" action="io_page2.php">
<? echo buildSelect("client", $_POST['client'], "select client from Clients order by client"); ?>
<input name="campaign" type="text" id="campaign" size="58" maxlength="70" />
<? echo buildSelect("name" , $_POST['name'], "select Name from Clients order by Name"); ?>
<input name="po_no" type="text" id="po_no" size="58" maxlength="50" />
<input name="Next Page" type="submit" id="Next Page" value="Next Page" />
</form>
I think there's something wrong with the line in the buildselect function:
$client = ( isset($_POST['client']) ) ? $_POST['client'] : "" ;
$name = ( isset($_POST['name']) ) ? $_POST['name'] : "$name" ;
or in the code in the form:
<? echo buildSelect("client", $_POST['client'], "select client from Clients order by client"); ?>
It doesn't seem to be registering the VALUE of "client" for example and posting it to page2. Like with the textboxes, the "id" uses the value that sends this across.
Here you go ..... I took out some little bits that weren't necessary.
<?PHP
session_start();
require("connect.php");
function buildSelect( $field_name, $curValue, $qry ) {
$fldT = "<select field_name='$field'>\n";
$rs = @mysql_query( $qry );
if ( $rs )
while ( $rw = @mysql_fetch_array( $rs, MYSQL_NUM ) ) {
$val = $rw[0];
$sel = ( $val == $curValue ) ? " selected='selected' " : "$val";
$fldT .= "<option value=".$val." $sel>$val</option>\n";
}
$fldT .= "</select>\n";
return $fldT;
}
$client = ( isset($_POST['client']) ) ? $_POST['client'] : "" ;
$name = ( isset($_POST['name']) ) ? $_POST['name'] : "$name" ;
$query = "SELECT * FROM clients ORDER BY 'clients' LIMIT $offset, $rowsPerPage";
?>
<html xmlns="http://www.w3.org/1
<head>
</head>
<body>
<table width="100%" border="0" align="left" cellpadding="0" cellspacing="0">
<form id="form1" name="form1" method="post" action="io_page2.php">
<tr>
<th width="2%" align="left" valign="baseline" scope="col"> </th>
<th width="40%" height="27" align="left" valign="baseline" scope="col"><div align="left">
<p><strong>Site:</strong><
</div></th>
<th height="27" colspan="2" align="left" valign="baseline" scope="col">Bebo
<input name="site" type="hidden" id="site" value="Bebo" /></th>
</tr>
<tr>
<td align="left" valign="baseline"> </
<td height="27" align="left" valign="baseline"><div align="left">
<p><strong>Client:</strong
</div></td>
<td height="27" colspan="2" align="left" valign="baseline"><div align="left">
<p><span class="style9">
<?
echo buildSelect("client", $_POST['client'], "select client from Clients order by client");
?>
</span></p>
</div></td>
</tr>
<tr>
<td align="left" valign="baseline"> </
<td height="25" align="left" valign="baseline"><div align="left">
<p><strong>Campaign:</stro
</div></td>
<td height="27" colspan="2" align="left" valign="baseline"><div align="left">
<p>
<input name="campaign" type="text" id="campaign" size="58" maxlength="70" />
</p>
</div></td>
</tr>
<tr>
<td align="left" valign="baseline"> </
<td height="5" align="left" valign="baseline"><div align="left">
<p><strong>Service Dates: </strong></p>
</div></td>
<td height="27" colspan="2" align="left" valign="baseline"><div align="left">
<p>
<input name="service_start" type="text" id="popup_container" size="26" />
-
<input name="service_end" type="text" id="popup_container_2" size="25" />
</p>
</div></td>
</tr>
<tr>
<td align="left" valign="baseline"> </
<td height="5" align="left" valign="baseline"><div align="left">
<p><strong>Contact Name: </strong></p>
</div></td>
<td height="27" colspan="2" align="left" valign="baseline"><div align="left">
<? echo buildSelect("name" , $_POST['name'], "select Name from Clients order by Name"); ?>
</div></td>
</tr>
<tr>
<td align="left" valign="baseline"> </
<td height="5" align="left" valign="baseline"><div align="left">
<p><strong>Address:</stron
</div></td>
<td height="27" colspan="2" align="left" valign="baseline"><div align="left">
<? echo buildSelect("address" , $_POST['address'], "select Address from Clients order by Address"); ?></div></td>
</tr>
<tr>
<td align="left" valign="baseline"> </
<td height="5" align="left" valign="baseline"><div align="left">
<p><strong>Telephone:</str
</div></td>
<td height="27" colspan="2" align="left" valign="baseline"><div align="left">
<? echo buildSelect("telephone" , $_POST['telephone'], "select Telephone from Clients order by Name"); ?></div></td>
</tr>
<tr>
<td align="left" valign="baseline"> </
<td height="5" align="left" valign="baseline"><div align="left">
<p><strong>Email:</strong>
</div></td>
<td height="27" colspan="2" align="left" valign="baseline"><div align="left">
<? echo buildSelect("email" , $_GET['email'], "select Email from Clients order by Email"); ?></div></td>
</tr>
<tr>
<td align="left" valign="baseline"> </
<td height="5" align="left" valign="baseline"><div align="left">
<p><strong>Purchase Order No.: </strong></p>
</div></td>
<td height="27" colspan="2" align="left" valign="baseline"><div align="left">
<input name="po_no" type="text" id="po_no" size="58" maxlength="50" />
</div></td>
</tr>
<tr>
<td align="left" valign="baseline"> </
<td height="5" align="left" valign="baseline"><div align="left">
<p><strong>Date of Receipt of Order:</strong></p>
</div></td>
<td height="27" colspan="2" align="left" valign="baseline"><div align="left">
<input name="receipt_date" type="text" id="popup_container_3" size="58" />
</div></td>
</tr>
<tr>
<td valign="baseline"> </
<td height="15" valign="baseline"> </
<td height="15" valign="baseline">
</td>
<td height="15" valign="baseline"> </
</tr>
<tr>
<td valign="baseline"> </
<td valign="baseline"><div align="left"></div></td>
<td width="24%" height="43" valign="baseline"><div align="center">
<input name="Next Page" type="submit" id="Next Page" value="Next Page" />
</div></td>
<td width="34%" height="43" valign="baseline"> </
</tr>
</form>
</table>
</body>
</html>
By changing
$fldT = "<select field_name='$field'>\n";
to
$fldT = "<select name='$field_name'>\n";
It is now sending through "some" of the value that the user selects.
If there is a "break" in a value, like for example: "Joe Bloggs" is the name,
it will only send through "Joe" to next page.
Would you know why this is?
Business Accounts
Answer for Membership
by: bportlockPosted on 2007-09-10 at 13:23:44ID: 19863961
There does not seem to be a FORM defined. Try
html' method='post'>
<?PHP
session_start();
require("connect.php");
function buildSelect( $field_name, $curValue, $qry ) {
$fldT = "<select field_name='$field'>\n";
$rs = @mysql_query( $qry );
if ( $rs )
while ( $rw = @mysql_fetch_array( $rs, MYSQL_NUM ) ) {
$val = $rw[0];
$sel = ( $val == $curValue ) ? " selected='selected' " : "";
$fldT .= "<option value=".$val." $sel>$val</option>\n";
}
$fldT .= "</select>\n";
return $fldT;
}
$client = ( isset($_POST['client']) ) ? $_POST['client'] : "" ;
$name = ( isset($_POST['name']) ) ? $_POST['name'] : "$name" ;
$query = "SELECT * FROM clients ORDER BY 'clients' LIMIT $offset, $rowsPerPage";
?>
<form action='page2_or_whatever.
<? echo buildSelect("client", $_POST['client'], "select client from Clients order by client"); ?>
<? echo buildSelect("name" , $_POST['name'], "select Name from Clients order by Name"); ?>
<? echo buildSelect("address" , $_POST['address'], "select Address from Clients order by Address"); ?>
<input name='submit' type='submit' value='press this' />
</form>