User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 397,784 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,429 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1515 | Replies: 0 | Solved
Reply
Join Date: Oct 2006
Posts: 71
Reputation: assgar is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
assgar assgar is offline Offline
Junior Poster in Training

Help Multi-page form that preloads

  #1  
Dec 17th, 2006
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]
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 5:04 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC