Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Form Confirmation Parse Error
    primarykey
    data
    text
    <p>I have some very simple PHP code that I'm using to confirm input from a form.</p> <p>HTML:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Unit 7 - Homework 5&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Contact us&lt;/h1&gt; &lt;table&gt; &lt;form method="POST" action="script.php"&gt; &lt;tr&gt; &lt;td&gt;First Name:&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="First Name" id="fname"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Last Name:&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="Last Name" id="lname"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;E-mail:&lt;/td&gt; &lt;td&gt;&lt;input type="text" name="E-mail" id="email"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Comments&lt;/td&gt; &lt;td&gt;&lt;textarea rows="10" cols="40"&gt;&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="submit" value="Contact"&gt; &amp;nbsp; &lt;input type="reset"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/form&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>PHP</p> <pre><code>&lt;?php print "&lt;!DOCTYPE html&gt; &lt;html lang=\"en\"&gt; &lt;head&gt; &lt;title&gt;Form Confirmation&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Congratulations, registration done!&lt;/h1&gt;"; $message = "; foreach ($_POST as $key =&gt; $value) { $message .= $key . ":" .$value. "&lt;br&gt;\r\n"; } print $message; print "&lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;form action=\"#\"&gt; &lt;input type=\"button\" value=\"Back\" onclick=\"javascript:history.go(-1)\" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;" ?&gt; </code></pre> <p>The PHP code keeps producing an error.</p> <pre><code>Parse error: syntax error, unexpected ':' in &lt;PHP path goes here&gt; on line 10 </code></pre> <p>I'm not sure what I'm doing wrong, although I feel I might have forgotten a semicolon.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload