Jump to content

Recommended Posts

Hi:

I wrote the following code, that is a form, that pass a result to another form that actuate depending on the result of the first... but I´ve never receive the value of the first form in to the second...

Can you help me to see what I´m doing wrong???

Please. I need help with this.

Thanks.

 

regards

 

Code Form.php ( main code ):

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>inicio</title>
</head>

<?php

include ("provmain.php");


?>

<body bgcolor="#FFFFFF">

<center>

<form METHOD="POST" action="busca.php" name=frminsertar>

<table border="1">
<tr>
<td>PROVINCIA:<br>

<select name=provincias>

<?php
$cuenta = array_count_values ($provincias);
$i = 0;
reset($provincias);


foreach ($provincias as $value )
{

echo "<option  name='".$provincias[$i]."' value='".$provincias[$i]."'>".$provincias[$i]."</option>";
$i++;
}

?>

</select>

</td>

</tr>
</table>
<br>
<br>

<input  name="submit" type="submit" value="enviar">

</center>

</form>

</body>
</html>

 

Code busca. php, where I have to receive the value of the form.php...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
</head>

<?php
include ("localidades.php");

$laprov=$_POST['provincias'];

?>


<body>

<center>

<form METHOD="POST" action="abuscar.php" name=buscadatos>

<select name=localidad>

<?php

switch ($laprov)
{
case "A coruña":
	$cuenta1 = array_count_values ($coruna);
$ix = 0;
reset($coruna);

foreach ($coruna as $value )
{
echo "<option name='".$coruna[$ix]."' value='".$coruna[$ix]."'>".$coruna[$ix]."</option>";
 $ix++;
} 
break;

case "Madrid":

$cuenta2 = array_count_values ($madrid);
$ix = 0;
reset($madrid);

foreach ($madrid as $value )
{
echo "<option name='".$madrid[$ix]."' value='".$madrid[$ix]."'>".$madrid[$ix]."</option>";
 $ix++;
} 
  break;
  
} // del switch de provincias

?>

</select>


</form>

</center>


</body>
</html>

 

The includes are only the arrays of the values for the selects of the form of the files...

Thanks.

 

When testing the basic code, it seems to work for me. What happens when you echo out $laprov in the second form; was the value passed?

 

...

<?php
include ("localidades.php");
$laprov=$_POST['provincias'];

echo $laprov;
?>

...

i'm only a nobo here and to PHP but shouldn't it be something like

 

$laprov=$_GET['provincias'];

 

this is how I post my data to the address bar.  The page this is on lists out * from the relevant table into a html table and creates a new field called update.  the code below creates a url called update using the Project_id as the unique identifier. when clicked it send the Project_id to the other form...

 

This section sends....


<td><a href="update_record.php?Project_id=<?php echo $rows['Project_id']; ?>">update</a></td>

 

this section retrieves...

//takes  value from the address bar..
$Project_id=$_GET['Project_id'];

// Retrieve data from database equal to the unique identifier

$sql="SELECT * FROM Main WHERE Project_id='$Project_id'";
$result=mysql_query($sql);

//build the array
$rows=mysql_fetch_array($result);

 

hope that helps... I think I'm right in the post. someone please correct me if i'm wrong.

Thanks

Balgrath

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.