Web Hosting Talk







View Full Version : Now what's wrong with THIS code??


MeAmRussian
03-19-2006, 11:09 PM
Looks like I need help again :blush: I'm trying to make input fields which write the input to a file.

Here is what I have:
index.php
<form action="submit.php" method="POST">
<input type="text" name="question" size="20">
<input type="text" name="option1" size="20">
<input type="text" name="option2" size="20">
<input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></form>

submit.php
$outputstring = "Question: ".$question."<br>Options: ".$option1.", ".$option2."<br>=================================<br>";

$open = fopen("requests.htm", "a");
fwrite($open, $outputstring);
fclose($open);
?>
After trying out the script, the variables don't work for some reason. I get this for every input:
Question:
Options: ,
=================================
Why is the input not showing?

Also, every so often I have questions like these, but I really don't want to make a new thread each time. What should I do :confused:

Thanks for the help.

qwerty1891
03-20-2006, 01:09 AM
try adding the following code at the very top of the submit.php file:


$option1 = $_POST['option1'];
$option2 = $_POST['option2'];
$question = $_POST['question'];

zoid
03-20-2006, 06:49 AM
Your code relies on enabled register_globals (http://www.php.net/manual/en/ini.core.php#ini.register-globals) but they seem to be - as it should be - disabled. Use, as qwerty1891 said, the $_POST array to access your values.