Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="page2.php" method="post">
- Question 2: Your age ?<br> <input type = "radio" name="q2" value="a"> 15-<br>
- <input type = "radio" name="q2" value ="b"> 15-25<br>
- <input type = "radio" name="q2" value ="c"> 25-35<br>
- <input type = "radio" name="q2" value ="d"> 35+<br>
- </form>
- <a href="page2.php">Submit</a>
- <?php
- $q2 = $_POST['q2'];
- Echo $q2;
- ?>
- Notice: Undefined index: q2 in D:XAMPPhtdocspage2.php
- <form action="page2.php" method="post">
- Question 2: Your age ?<br> <input type = "radio" name="q2" value="a"> 15-<br>
- <input type = "radio" name="q2" value ="b"> 15-25<br>
- <input type = "radio" name="q2" value ="c"> 25-35<br>
- <input type = "radio" name="q2" value ="d"> 35+<br>
- <input type='submit' value='Submit' />
- </form>
- <input type = "radio" name="q2" value ="d"> 35+<br>
- <!-- add the submit button inside the form -->
- <input type="submit" name="submit">
- </form>
- <?php
- //always use isset before checking for POST variables
- if(isset($_POST['submit']){
- $q2 = $_POST['q2'];
- echo $q2;
- }
- ?>
- You have already written in form action
- no need of this <a href="page2.php">Submit</a>
- <input type="button" id="submit" name="submit" value="Submit"/>
- write this line before </form> tag close instead of this line
- <a href="page2.php">Submit</a>
- <form action="page2.php" method="post">
- Question 2: Your age ?<br>
- <input type = "radio" name="q2" value="a"> 15-<br>
- <input type = "radio" name="q2" value ="b"> 15-25<br>
- <input type = "radio" name="q2" value ="c"> 25-35<br>
- <input type = "radio" name="q2" value ="d"> 35+<br>
- </form>
- <a href="page2.php">Submit</a>
- <?php
- $q2 = $_POST['q2'];
- var_dump($q2);
- echo $q2;
- ?>
- <form action="page2.php" method="post">
- Question 2: Your age ?<br>
- <input type = "radio" name="q2" value="a"> 15-<br>
- <input type = "radio" name="q2" value ="b"> 15-25<br>
- <input type = "radio" name="q2" value ="c"> 25-35<br>
- <input type = "radio" name="q2" value ="d"> 35+<br>
- <input type='submit' value='Submit' />
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement