简体   繁体   中英

How to create submit button in PHP using HTML forms?

Without this code my web page work fine...

echo "<form name="Patient" action="patient_history_display.php" method="get">";
    echo "<input type="submit" value="Click here to view patient history">";
echo "</form>";

However, after adding this part of code, I received two errors:

ERROR 1: SCREAM: Error suppression ignored for ERROR 2: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'

You're not escaping quotes " although for echo you should start and close with single quote '

echo '<form name="Patient" action="patient_history_display.php" method="get">';
echo '<input type="submit" value="Click here to view patient history">';
echo '</form>';

and by escaping, I mean adding a backslash to the " inside the echo like so:

echo "<form name=\"Patient\" action=\"patient_history_display.php\" method=\"get\">";
echo "<input type=\"submit\" value=\"Click here to view patient history\">";
echo "</form>";

as you can see, it's a hell of a lot easier to use quotes wisely!

or for big block stuff:

    echo <<<END
This uses the "here document" syntax to output
multiple lines with $variable interpolation. Note
that the here document terminator must appear on a
line with just a semicolon. no extra whitespace!
END;

http://uk1.php.net/echo

Change the quotes from "" to ''. Try: echo '<input type="submit" value="Submit">';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM