dwees Posted July 4, 2006 Share Posted July 4, 2006 Hey there.Suppose I have a form like this:testing.html -[CODE]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><body><form name="input" action="test.php" method="GET">Male: <input type="radio" name="Sex" value="Male" checked="checked"><br><input type="text" name="firstname"><br>Female: <input type="radio" name="Sex" value="Female"><br><input type="text" name="lastname"><br><input type ="submit" value ="Submit"></form> <p>If you click the "Submit" button, you will send your input to a new page called html_form_action.asp.</p></body></html>[/CODE]I would like to be able to read the information from both input types. It seems to me that using the POST and GET methods isn't working. At least my very simple test function doesn't do anything (see below).test.php -[CODE]<?php$test = $_GET['input'];echo $test;?>[CODE][/code][/code] Quote Link to comment https://forums.phpfreaks.com/topic/13674-php-and-multiple-input-type-forms/ Share on other sites More sharing options...
corbin Posted July 4, 2006 Share Posted July 4, 2006 [code]<form name="input" action="test.php" method="GET">Male: <input type="radio" name="Sex" value="Male" checked="checked"><br><input type="text" name="firstname"><br>Female: <input type="radio" name="Sex" value="Female"><br><input type="text" name="lastname"><br><input type ="submit" value ="Submit"></form> [/code]try using $_GET['sex'], $_GET['firstname'], and $_GET['lastname'] Quote Link to comment https://forums.phpfreaks.com/topic/13674-php-and-multiple-input-type-forms/#findComment-53043 Share on other sites More sharing options...
dwees Posted July 4, 2006 Author Share Posted July 4, 2006 Works super. I'm going to assume it works with POST as well.Dave Quote Link to comment https://forums.phpfreaks.com/topic/13674-php-and-multiple-input-type-forms/#findComment-53047 Share on other sites More sharing options...
Eugene Posted July 4, 2006 Share Posted July 4, 2006 use $_REQUEST, it's more safer than get. Quote Link to comment https://forums.phpfreaks.com/topic/13674-php-and-multiple-input-type-forms/#findComment-53050 Share on other sites More sharing options...
SharkBait Posted July 4, 2006 Share Posted July 4, 2006 How is $_REQUEST safer than $_GET? I use $_POST though with my forms. Quote Link to comment https://forums.phpfreaks.com/topic/13674-php-and-multiple-input-type-forms/#findComment-53061 Share on other sites More sharing options...
.josh Posted July 5, 2006 Share Posted July 5, 2006 there are only 2 methods of passing variables with a form: GET and POST. GET passes the variables through the url. POST passes the variables through the body of the HTTP request to access them, you would use $_GET['varname'] and $_POST['varname'] respectively. $_POST is safer than $_GET, because the information is not being sent through the url string. $_REQUEST is an array that holds both $_POST and $_GET variables. So I can access my form information with $_REQUEST['blah'] same as $_POST['blah'] if my form method was POST, or same with the GET method, as well. $_REQUEST is not any safer than the safety levels of $_POST or $_GET. You still need to sanitize it just the same, though as mentioned, $_POST is more safer than $_GET. You should still sanitize your $_POST vars though. Quote Link to comment https://forums.phpfreaks.com/topic/13674-php-and-multiple-input-type-forms/#findComment-53155 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.