Jump to content

dink87522

Members
  • Posts

    142
  • Joined

  • Last visited

    Never

Everything posted by dink87522

  1. Thanks, I feel stupid now lol. I just couldn't see that.
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Random name generator</title> </head> <body> <?php $first_name[1] = "Mark"; $first_name[2] = "David"; $first_name[3] = "Connor"; $first_name[4] = "John"; $first_name[5] = "Michae;l" $last_name[1] = "Barnes"; $last_name[2] = "Smith"; $last_name[3] = "Potts"; $last_name[4] = "White"; $last_name[5] = "Menitt"; echo("<h4>Random name generator</h4><p>"); $random_first = rand(1, 5); $random_last = rand(1, 5); name$ = $first_name[$random_first]." ".$last_name[$random_last]; echo("<h4>Random name: name$</h4>") ?> </body> </html> Parse error: syntax error, unexpected T_VARIABLE in /home/dinksoft/public_html/randomNameGenerator.php on line 13 however I cannot see anything wrong with it (first time with this error before also).
  3. Thanks
  4. What I had was the user clicking the submit button and it would be processed by another PHP file. If I wish to process it on the same page I understand that you use the isset function. However this will not work for me and with the submit button's action, what does that then become? <form action="check.php" method="post"> <input type="hidden" name="country" value="<?php echo("$rnd") ?>"/> <input type="text" size="55" name="answer" value="" /> <input type="submit" name="submit" value="Submit" /> </form> <?php if (isset($_POST['submit']){ $userAnswer = $_POST['answer']; $rnd = $_POST['country']; $answer = $capitals[$rnd]; $userAnswerLower = strtolower($userAnswer); $answerLower = strtolower($answer); //echo("userAnswerLower: $userAnswerLower <br />"); if ($userAnswerLower == $answerLower) { echo("<h3>CORRECT, $answer is indeed the capital of $countries[$rnd]!</h3>"); } else { echo("<h3>INCORRECT, the capital of $countries[$rnd] is $capitals[$rnd]! </h3>"); } } ?>
  5. Thanks Grunshaw, that worked exactly like I wanted. I wasn't using PHP to echo the variable.
  6. <input type="hidden" name="result" value="$rnd"/>
  7. A user fills out a couple of text fields and the form is submitted and I use $_POST to get those answer's. What I want to do is to send a variable (i.e. $dummy) from that form page to the page which will process the form (both are php). How would I go about this? I tried using a hidden text field although this did not work.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.