Jump to content

2 forms


alin19

Recommended Posts

i have a page that has a form, with one select buton, and on sumbit generates a pdf document.

 

 

 

 

The problem is that i have a  have a select buton on wich i select my client, but every client has several  acounts,

i would like after i select the client to chose from his acounts, all of this data are stored in a mysql database,

 

I was thinking to make 2 submit buttons, one to take all his acounts and let me chose from them and the secont to have the action to create a pdf,

 

 

but the form is defined like this : <form method="POST" action="pdf/port.php" >

 

 

how can i make that one submit buton to have the action="" and the other action="pdf/port.php" ?

 

Link to comment
https://forums.phpfreaks.com/topic/99130-2-forms/
Share on other sites

recap my understanding of your question:

- you have a form with 2 drop down boxes

- second drop down box (ie/ the accounts) must be selected in order to proceed to 'pdf/port.php'

- you use the first drop down box (ie/ the users) to narrow down selection in 2nd drop down box

 

assume your page is form.php

 

Have the first drop down box submit to this page (ie/ form.php)

and whenever you visit this page check if there's any argument been passed to it..

a pseudo code to demostrate:


if(_$REQUEST['username'])
{
  -- set the first drop down box to this username
  -- display 2nd drop down box with appropriate values
}
else //no argument 'username' found
{
  -- only display first drop down box
}

-- your form

Link to comment
https://forums.phpfreaks.com/topic/99130-2-forms/#findComment-507188
Share on other sites

here is my form code

<?php
$hostname="localhost";
$username="root";
$password="*****";
$database="apelmarja";


$conexiune=mysql_connect($hostname,$username,$password)
or die ("Nu ma pot conecta la baza de date");

$bazadate=mysql_select_db($database,$conexiune)
or die ("Nu gasesc baza de date");

?>
<html>
<head>
</head>
<body bgcolor="#C0C0C0" >
<form method="POST" action="pdf/port.php">
<table>
<tr>
	<td><input type="text" value="<?php echo date ('Y-m-d');?>" name="data" readonly></td>
	<td><select name="id_bo"><?php $queryS="SELECT `Id_bo` FROM `conturi` where `activ`='Da'";  
	if ($r=mysql_query($queryS))
		{
			while ($row = mysql_fetch_array($r))
			{
			echo "<option value=$row[0]> $row[0] </option>";
			}
		}
		?>
	</td>
<tr>
	<td><input type="submit" value="Vizualizare Port" name="vizualizare_date"></td>
</tr>


</table>

</body>
</html>

 

 

and i would like to have something like this:

 

 

<?php
$hostname="localhost";
$username="root";
$password="tractor";
$database="apelmarja";


$conexiune=mysql_connect($hostname,$username,$password)
or die ("Nu ma pot conecta la baza de date");

$bazadate=mysql_select_db($database,$conexiune)
or die ("Nu gasesc baza de date");
///
if(isset($_POST['preluare_date']))
{
$id_bo=$_POST['id_bo'];
$query="SELECT * from conturi where `id_bo`='$id_bo'
$x=mysql_query($query);
while ($y=mysql_fetch_array($x))
$nr_cont[]=$y['cont'];

}
//
?>
<html>
<head>
</head>
<body bgcolor="#C0C0C0" >
<form method="POST" action="pdf/port.php">
<table>
<tr>
	<td><input type="text" value="<?php echo date ('Y-m-d');?>" name="data" readonly></td>
	<td><select name="id_bo"><?php $queryS="SELECT `Id_bo` FROM `conturi` where `activ`='Da'";  
	if ($r=mysql_query($queryS))
		{
			while ($row = mysql_fetch_array($r))
			{
			echo "<option value=$row[0]> $row[0] </option>";
			}
		}
		?>
	</td>
</tr>
//<?php   if(isset($nr_cont)) echo "<tr> <td> <select name="select_conturi">;foreach echo "<option value=$nr_cont">$nr_cont</option>";echo  "</select>";
echo  "</td></tr>; ?>


<tr>
	<td><input type="submit" value="Vizualizare Port" name="vizualizare_date" action="pdf/port.php"></td>  //sending to pdf/port.php
      <td><input type="submit" value="Preluare Date" name="preluare_date" action="local page"></td> //taking data
</tr>


</table>

</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/99130-2-forms/#findComment-507200
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.