05. januar 2010 - 21:38
Der er
1 løsning
Variables PHP
Hej Alle, Kan man lave et script som kan ændre var1 var2 var3 via denne POST? <?php $var1 = "100"; $var2 = "200"; $var3 = "300"; echo $var1; echo "<br>"; echo $var2; echo "<br>"; echo $var3; ?> <form method="POST" action="save.php"> <p><input type="text" name="var1" size="20" value="<?php echo $var1; ?> "> <input type="submit" value="Ændre var1" name="B1"></p> </form> <form method="POST" action="save.php"> <p><input type="text" name="var2" size="20" value="<?php echo $var2; ?> "> <input type="submit" value="Ændre var2" name="B1"></p> </form> <form method="POST" action="save.php"> <p><input type="text" name="var3" size="20" value="<?php echo $var3; ?> "> <input type="submit" value="Ændre var3" name="B1"></p> </form>
Annonceindlæg fra FPT Software
Slettet bruger
05. januar 2010 - 21:44
#1
Beenyt $_POST arrayet: <?php $var1 = "100"; if(isset($_POST['var1'])){ $var1 = $_POST['var1']; } $var2 = "200"; if(isset($_POST['var2'])){ $var2 = $_POST['var2']; } $var3 = "300"; if(isset($_POST['var3'])){ $var3 = $_POST['var3']; } echo $var1; echo "<br>"; echo $var2; echo "<br>"; echo $var3; ?> <form method="POST" action="save.php"> <p><input type="text" name="var1" size="20" value="<?php echo $var1; ?> "> <input type="submit" value="Ændre var1" name="B1"></p> </form> <form method="POST" action="save.php"> <p><input type="text" name="var2" size="20" value="<?php echo $var2; ?> "> <input type="submit" value="Ændre var2" name="B1"></p> </form> <form method="POST" action="save.php"> <p><input type="text" name="var3" size="20" value="<?php echo $var3; ?> "> <input type="submit" value="Ændre var3" name="B1"></p> </form>