By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,659 Members | 910 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,659 IT Pros & Developers. It's quick & easy.

Multi-page form that preloads

P: 41
Hello

First sorry if there is to much code in this example.

I am new to working with multi page forms.

I have a search form that gets preloaded info from the database.
There are 3 scripts (a html page, a preload script and a process script).
There is a search button and a submit button.

The user can alter this information.
If the user alters the preloaded infomation and then does a search
I want the altered information to be displayed along with the search results.

Note: the same search page reloads with the search results.

1) Should I use the hidden input script to hold the altered information?
2) Where should I place the hidden input script, on the form or the preload
script?

Note:I tried putting the hidden input script in preload.php
so I can use an if to determine if their is hidden info to pass
or pass the info from the database. But I could could not get that to work

It would be great if you could please show your suggestion.


Hidden input
[php]
if($_POST['fname']) $fname = $_POST['fname'];
echo ("input type = 'hidden' name='fname' value ='" .$fname ."'>\n");
[/php]


Preload script
[php]
<?php
/** preload.php**/

$spec_q ="select fname, lname, service_date
from customer
where customer_num = $customer";
$result = mysqli_query ($mysqli, $spec_q);
while($row = mysqli_fetch_array($result))
{

list($fname, $lname, $service_date) = $row;
list($ser_year_c, $a_month_c, $c_day_c)= split("-",$service_date);
}
?>
[/php]

Html page
[php]
<?php
/** search_form.php **/

include("preload.php");//preload first and last name and service date
?>

<html>
<form action="search_edprocess.php" method="post">

<table>
<tr>

<!---------------------customer name--------------------->
<td colspan="2" align="left"><font face = "arial" font size = "3px"><b>

<input type="text" name="first_name" size="15" maxlength="20" value ="<?php echo $lname; ?>"/>
<input type="text" name="last_name" size="15" maxlength="20" value ="<?php echo $fname; ?>"/>

echo "$lname, $first"; //patient last name and org_patient_id

</b></font></td>

<!-------------------date of service--------------------->
<td colspan="2">

<input type="text" name="service_yr" size="4" maxlength="5" value ="<?php echo $service_yr; ?>"/>

<!-------------------service date month dropdown---------------------->
<select name="service_month">
<?php
$month_name = get_a_month_name($a_month_n);
$month_code = get_a_month_code($a_month_c);
for($n = 1; $n<= 13; $n++)
{
$month=$month_name[$n];
$mcode=$month_code[$n];
echo "<option value = '$mcode'";
if ($mcode == " ")
{
echo "selected";
}
echo ">$month \n";
}
?>
</select>

<!-------------------service date day dropdown---------------------->
<select name="service_day">
<?php
$day_name = get_c_day_name($c_day_n);
$day_code = get_c_day_code($c_day_c);
for ($n = 1; $n<= 32; $n++)
{
$day = $day_name[$n];
$dcode = $day_code[$n];
echo "<option value = '$dcode'";
if ($dcode == " ")
{
echo "selected";
}
echo ">$day \n";
}
?>
</select>
</td>
</tr>
<tr>
<td>
<!---------------------search box ------------------->
Search for:
<input type="text" name="find" />
</td>
<td ><input type="hidden" name="searching" value="yes" />
<input type="submit" name="f_button" value="Search" />
</td>
</tr>
</table>
</html>
[/php]


Process script
[php]
<?php

/**search_edprocess.php**/

$first_name = strip_tags(trim($_POST['first_name']));
$last_name = strip_tags(trim($_POST['last_name']));

//year of service
$service_yr = strip_tags(trim($_POST['service_yr']));
$service_yr = preg_replace("/[^a-zA-Z0-9\s,.]+/","",$service_yr);

$find = preg_replace("/[^a-zA-Z0-9\s,.]+/", " ", $find);

//month of service
$service_month = trim($_POST['service_month']);

//day of service
$service_day = trim($_POST['service_day']);

//year, month and day of service
$service_date = $service_yr."-".$service_month."-".$service_day;

/**** insert goes here****/
if(($_POST['f_button'])= "Submit")

/***find and submit bottons managed by switch**/
switch ($_POST['f_button'])
{

}

?>
[/php]
Dec 17 '06 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.