This is my first PHP script, so please excuse my clumsiness. I have a HTML page which consists of a form and a PHP page which deals with the variables that are outputted. The HTML page functions as a small box that asks to input an email account/password, and the PHP page simply echoes the results.

My HTML page:

<html>
<form action="emailresults.php" method="post">
        <p>
                Email address:<br />
                <input type="text" name="email" size="20" maxlength="50" value="" />
        </p>
        <p>
                Password:<br />
                <input type="password" name="pswd" size="20" maxlength="15" value="" />
        </p>
        <p>
                <input type="submit" name="subscribe" value="subscribe!" />
        </p>
</form>
</html>

My "emailresults.php":

<?php
      echo "The email you entered is $_POST['email'].";
      echo "The password you entered is $_POST['pswd'].";
?>

When I arrive at my PHP page, I get the error "Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING" for line 2.

What can I do to fix this?

Thanks in advance.

Try making your php page the following:

<?php
echo 'The email you entered is '.$_POST['email'].'.';
echo 'The password you entered is '.$_POST['pswd'].'.';
?>

And other than that your code should be fine unless there is other code in the php file that may be causing the problem.

Perfect. That solved it. Thank you very much.

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.