Strange POST problem<

liunx

Guest
Hi all,

I created an e-mail with a form on it, like:


<html>
<form action="results.php" method="post">
<input type="radio" name="question1" value="yes"> Yes<br>
<input type="radio" name="question1" value="no"> No<br>
</form>
</html>


When I post this to my php script, and I want to get the var like this:
$question1 = $_POST['question1'];

the $question1 is empty. When I do not use POST, but GET is works!

Why can't I use post, but only get???

btw. if I mean GET, I delete
method="post" in my codefirst off, your inputs are are incorrect - they should be closed:

<input type="radio" name="question1" value="yes">Yes</input><br>


second, how do you submit the form? There is no submit button here.


try putting the following line in your results.php:

print_r($_POST);


to see if any values are being posted in your form.sorry, forgot the button :(

In real, the form is much bigger, but I recreated a little form to just show the problem...

<input type="submit" value="Send data">

But my forms always worked without closing the inputs with </input>

I thought that was optional...btw. I put </input> everywhere, but it makes no different :(

Do you know what to problem is???

I create this mail form with php, but that should not be a problem...



$body='
<html>
<body>
<form method="post" action="http://www.???.com/results.php">

<input type="radio" name="question1" value="yes"> Yes</input><br>
<input type="radio" name="question1" value="no"> No</input><br>

<input type="submit" value="Send data"></input>
</form>
</body>
</html>';

/* To send HTML mail, you can set the Content-type header. */
$headers = "Content-type: text/html; charset=iso-8859-1\r\n";

/* additional headers */
$headers .= "From: <?@?.?>\r\n";
$headers .= "To: $name <$mailadress>\r\n";

if(mail($mailadress, "Subject", $body, $headers))
return true;
else
return false;Originally posted by Horus_Kol
<input type="radio" name="question1" value="yes">Yes</input><br>

INPUT elements should be closed in XHTML. When using HTML, which I assume he does, there is no need to close them. Further more, INPUT is defined as EMPTY in the XHTML DTD, which means that the end tag must immediately follow the start tag, or you may use the empty element shorthand.
Other than that, when using XHTML, there are quite a few more changes to make to the document, before it's strictly conforming. Code validation was however not the issue here.

Your problem is a bit odd, Tischn榘恊nt榘
 
Back
Top