Connecting Tech Pros Worldwide Help | Site Map

How to pass form input through multiple pages.

Familiar Sight
 
Join Date: Oct 2006
Posts: 142
#1: Aug 28 '07
Hi,

I have a from where you type in your username, it then goes to my logbook.php.

In the logbook I do like Select FROM database $username.

The logbook page display only x amount of result per page and then make a link for page 2, page 3 etc. for the rest of the results.

The problem is if I click on say page to 2 my page does not display the result cause $username is no specified.

How can I keep the $username var?

Here the part of my script where I need the $username to alway be when specified.
----------------------------------
[PHP]

};

for ($k=0; $k<$pages; $k++) {
if ($k != $_REQUEST[page]) {
$lynx .= "<a href=$PHP_SELF"."?page=$k>".($k+1)."</a>";

} else {
$lynx .= " <b>--".($k+1)."--</b>";
}
}
?>
<br />
<?= $html ?>
<span class="style1">Please choose the next page you want to view</span>:
<?= $lynx ?>
[/PHP]

--------------------------------------------------

I want to example

[PHP]
};

for ($k=0; $k<$pages; $k++) {
if ($k != $_REQUEST[page]) {
$lynx .= "*******POST_$username with link this link*******<a href=$PHP_SELF"."?page=$k>".($k+1)."</a>";

} else {
$lynx .= " <b>--".($k+1)."--</b>";
}
}
?>
<br />
<?= $html ?>
<span class="style1">Please choose the next page you want to view</span>:
<?= $lynx ?>
[/PHP]

Thanks
Member
 
Join Date: Aug 2007
Posts: 35
#2: Aug 28 '07

re: How to pass form input through multiple pages.


Expand|Select|Wrap|Line Numbers
  1. <a href=$PHP_SELF"."?page=$k&username=$username>".($k+1)."</a>";
and then your username would be in $_GET['username']

It would be more appropriate to select the rowid(assuming your table has an unique id) corresponding to the username
Expand|Select|Wrap|Line Numbers
  1. SELECT id FROM your_table WHERE username=$username
and then to pass only the id to the other pages
Familiar Sight
 
Join Date: Oct 2006
Posts: 142
#3: Aug 28 '07

re: How to pass form input through multiple pages.


I still get the problem, please check my script

[PHP]
<?php
$username=$_GET['username'];
$username=$_POST['username'];
$submit = $_POST['submit'];
$self = $_SERVER['PHP_SELF'];
$table = $_POST['table'];
$self = $_SERVER['PHP_SELF'];

if (isset($_POST['table'])) {
$table = $_POST['table'];
} else {
$table = 'a';
}

if ($self)

{
$conn=mysql_connect( "asdfasdf", "asdf", "asdfsadf")
or die( "Err:Conn");

$rs= mysql_select_db ( "divereg2", $conn )
or die ( "Err:Db");

# Create the query

$sql="select dive from $username";


#execute

$rs = mysql_query( $sql, $conn );
if (!$rs) {
die("query error! query text: $sql<br />Error Message: ".mysql_error());
}

#write data

}

$perpage = 2;
$lynx = $html = "";
$startat = $_REQUEST[page] * $perpage;

$q = mysql_query("select count(dive) from $username");
$row = mysql_fetch_array($q);
$pages = ($row[0] + $perpage - 1) / $perpage;

$q = mysql_query("select * from $username order by dive desc limit $startat,$perpage");

while ($row = mysql_fetch_assoc($q)) {
$text = strip_tags($row[entry_text]);
$text = substr($text,0,300);
#table
echo("<table width=\"450\" border=\"0\" align=\"center\" cellpadding=\"2\" cellspacing=\"2\" bordercolor=\"005BB7\">
<tr>
<td width=\"227\"><strong>Businesname</strong></td>
<td width=\"16\">&nbsp;</td>
<td width=\"227\"><strong>E-mail</strong></td>
</tr>
<tr>
<td><dt>$row[dive] <a href=/mouth/$row[dive]_.html target=pix>$row[entry_title]</a></dt></td>
<td></td>
<td><dt>$row[email] <a href=/mouth/$row[email]_.html target=pix>$row[entry_title]</a></dt></td>
</tr>
<tr>
<td><strong>Postal</strong></td>
<td></td>
<td><strong>Website</strong></td>
</tr>
<tr>
<td><dt>$row[postal]<a href=/mouth/$row[postal]_.html target=pix>$row[entry_title]</a></dt></td>
<td></td>
<td><dt>$row[website] <a href=/mouth/$row[website]_.html target=pix>$row[entry_title]</a></dt></td>
</tr>
<tr>
<td><strong>Company VAT Reg. No</td>
<td></td>
<td><strong>Chairman/ President/ MD</strong></td>
</tr>
<tr>
<td><dt>$row[company_vat] <a href=/mouth/$row[company_vat]_.html target=pix>$row[entry_title]</a></dt></td>
<td></td>
<td><dt>$row[c_p_md] <a href=/mouth/$row[c_p_md]_.html target=pix>$row[entry_title]</a></dt></td>
</tr>
<tr>
<td><strong>Street Address</strong></td>
<td></td>
<td><strong>Contact Name</strong></td>
</tr>
<tr>
<td><dt>$row[street_address] <a href=/mouth/$row[street_address]_.html target=pix>$row[entry_title]</a></dt></td>
<td></td>
<td><dt>$row[contact_name] <a href=/mouth/$row[contact_name]_.html target=pix>$row[entry_title]</a></dt></td>
</tr>
<tr>
<td><strong>Tel</strong></td>
<td></td>
<td><strong>Job Title</strong></td>
</tr>
<tr>
<td><dt>$row[tel] <a href=/mouth/$row[tel]_.html target=pix>$row[entry_title]</a></dt></td>
<td></td>
<td><dt>$row[job_title] <a href=/mouth/$row[job_title]_.html target=pix>$row[entry_title]</a></dt></td>
</tr>
<tr>
<td><strong>Fax:</strong></td>
<td></td>
<td><strong>Cellphone No:</strong></td>
</tr>
<tr>
<td><dt>$row[fax] <a href=/mouth/$row[fax]_.html target=pix>$row[entry_title]</a></dt></td>
<td></td>
<td><dt>$row[cell] <a href=/mouth/$row[cell]_.html target=pix>$row[entry_title]</a></dt></td>
</tr>
<tr>
<td></td>
<td></td>
<td><strong>Main business Activity</strong><br/>
<dt>$row[business_activity] <a href=/mouth/$row[business_activity]_.html target=pix>$row[entry_title]</a></dt>
</td>
</tr>
</table><br/><hr>");


};

for ($k=0; $k<$pages; $k++) {
if ($k != $_REQUEST[page]) {
$lynx .= "<a href=$PHP_SELF"."?page=$k&username=$username>".($k +1)."</a>";

} else {
$lynx .= " <b>--".($k+1)."--</b>";
}
}
?>
<br />
<?= $html ?>
<span class="style1">Please choose the next page you want to view</span>:
<?= $lynx ?>
[/PHP]
ak1dnar's Avatar
Moderator
 
Join Date: Jan 2007
Location: Colombo
Posts: 1,439
#4: Aug 28 '07

re: How to pass form input through multiple pages.


Alternatively you can store the username in a session variable. find out how
Reply