Reputation: 124
BIG EDIT: I've trimmed the code as much as possible while getting the same notice.
So I'm trying to use the variable $tour
which is defined in the first if(isset...
. This if creates a second submit that when pressed should print the value $tour
but I get the following output:
Notice: Undefined variable: torneo in /home/user/public_html/edit/file.php on line 19
1
before loop
Notice: Undefined variable: torneo in /home/user/public_html/edit/file.php on line 21
The trimmed code is:
<form method="POST">
TORNEO: <select name="torneo">
<option value="DSHN ADULTO">DSHN ADULTO</option>
<option value="NFL">NFL</option>
</select>
<br />
<input type="submit" value="ELEGIR" name="input1"/>
<br />
<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
if(isset($_POST['input1'])){
$torneo = $_POST['torneo'];
echo $torneo;
echo "<br><input type='submit' name='input2' value='CREAR'/>";
}
if(isset($_POST['input2'])){
echo $torneo."1";
echo "<br>before loop<br>";
while ($torneo){
echo "Updated! ".$torneo."<br>";
}
}
?>
</form>
Thanks for the help!
Upvotes: 1
Views: 568
Reputation: 124
The answer to my problem is here:
Why do I keep losing variable values when submitting a second form on the same page
Thanks everyone who helped, Im really very thankful to all!
Upvotes: 1
Reputation: 3747
echo "</form>";
mysqli_close($db);
... mysqli_close($db);
You have an extraneous close, before the second part of your script.
Upvotes: 1