lmcm2008 Posted May 9, 2011 Share Posted May 9, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/235912-what-i%C2%B4m-doing-wrong-it-doesn%C2%B4t-work-and-don%C2%B4t-know-why/ Share on other sites More sharing options...
fugix Posted May 9, 2011 Share Posted May 9, 2011 firstly you need to wrap your names in quotes this <select name=provincias> should be <select name="provincias"> Quote Link to comment https://forums.phpfreaks.com/topic/235912-what-i%C2%B4m-doing-wrong-it-doesn%C2%B4t-work-and-don%C2%B4t-know-why/#findComment-1212776 Share on other sites More sharing options...
cyberRobot Posted May 9, 2011 Share Posted May 9, 2011 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; ?> ... Quote Link to comment https://forums.phpfreaks.com/topic/235912-what-i%C2%B4m-doing-wrong-it-doesn%C2%B4t-work-and-don%C2%B4t-know-why/#findComment-1212782 Share on other sites More sharing options...
balgrath Posted May 9, 2011 Share Posted May 9, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/235912-what-i%C2%B4m-doing-wrong-it-doesn%C2%B4t-work-and-don%C2%B4t-know-why/#findComment-1212814 Share on other sites More sharing options...
cyberRobot Posted May 9, 2011 Share Posted May 9, 2011 i'm only a nobo here and to PHP but shouldn't it be something like $laprov=$_GET['provincias']; Since "provincias" is coming from a form set to method="post", you would use $_POST. Quote Link to comment https://forums.phpfreaks.com/topic/235912-what-i%C2%B4m-doing-wrong-it-doesn%C2%B4t-work-and-don%C2%B4t-know-why/#findComment-1212819 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.