I received assistance from this forum just yesterday and so I thought I would try here again. This is my code for the php file that is supposed to receive data from an external html file and manipulate it but it is not receiving anything and I do not see why.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title>Word Jumble</title>
<body>
<?php 
   error_reporting(E_ALL & ~E_NOTICE);
   function DisplayError($fieldName, $errorMsg) {
    echo "Error for \ "$fieldName\": $errorMsg<br \>\n";
    ++$errorCount;  }
    function wordCheck($data, $fieldName) {

        global $errorCount;
         if (empty($data)) {
            displayError($fieldName, "You must enter a word here between 4 and 7 chracters");
            $retval = "";
          else {
            $retval = trim($data);
            $retval = striplashes($retval);
            if ((strlen(($retval)<4))|| (strlen($retval)>7)) { 
            displayError($fieldName, Must be between 4 ans 7 characters in length");          }  
            if (preg_match("/^[a-z]+$/i", $retval)==0){
                displayError($fieldName, Words must be letters only");
            }
            }
            $retval = strtoupper($retval);
            $retval = str_shuffle($retval);
            return($retval);
            }
            $words[] = wordCheck($_POST["word 1"], "word 1");
            $words[] = wordCheck($_POST["word 2"], "word 2");
            $words[] = wordCheck($_POST["word 3"], "word 3");
            $words[] = wordCheck($_POST["word 4"], "word 4");
            if ($errorCount>0)
               echo "Please re-enter data.<br />\n";
            else {
                $wordnum = 0;
                foreach ($words as $Word)
                   echo "Word ", ++$wordnum.": $Word<br />\n";
                            }   
?>
</body> 
</html>

This is the code from the html file that is supposed to collect inputted data from the user and send it to the php file above but is not working correctly.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Words for Jumble</title>
</head>
<body>
<?php
<h3>Please enter 4 words between 4 and 7 characters long</h3>
<p>word 1: <input type="text" name="word 1"></p>
<p>word 2: <input type="text" name="word 2"></p>
<p>word 3: <input type="text" name="word 3"</p>
<p>word 4: <input type="text" name="word 4"</p>
$word 1 = word 1
$word 2 = word 2
$word 3 = word 3
$word 4 = word 4
<input type="reset" value="Clear Form" />&nbsp;
&nbsp;<input type="submit" name="submit" value="send form" />
echo $word 1
echo $word 2
echo $word 3
echo $word 4
?>
</body>
</html>

If you can see what is wrong please tell me!!
Thanks!!:)

Could you please, please post your code in (CODE) tags in future. In your second script, your input fields aren't enclosed in <form> tags. Here, you need to define the form action (post the form to the name of the file you want to process the information) and secondly define the form method (either 'get' or 'post'). You should probably read up on html forms and get vs post

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Words for Jumble</title>
</head>
<body>
<h3>Please enter 4 words between 4 and 7 characters long</h3>
<form action="name-of-file-to-pass-these-fields.php" method="post">
<p>word 1: <input type="text" name="word 1"></p>
<p>word 2: <input type="text" name="word 2"></p>
<p>word 3: <input type="text" name="word 3"</p>
<p>word 4: <input type="text" name="word 4"</p>
<?php
   $word 1 = word 1; //You don't need these here. The form values can only be retrieved and printed on the page your passing these values to 
   $word 2 = word 2;
   $word 3 = word 3;
   $word 4 = word 4;
?>
<input type="reset" value="Clear Form" />&nbsp;
&nbsp;<input type="submit" name="submit" value="send form" />
</form>
<?php
   echo $word 1;             //also you don't need these here
   echo $word 2;
   echo $word 3;
   echo $word 4;
?>
</body>
</html>

Your also mixing up HTML with PHP code. Remember to enclose PHP code in <?php ?> tags (html should be outside of these tags), and also finish all php lines with a semi-colon!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.