Maharashtra HSC IT Commerce study materials
Maharashtra HSC IT Commerce study resources

Maharashtra HSC IT Commerce: Server Side Scripting using PHP

Maharashtra HSC IT Commerce · Work through your exam, one topic at a time.

All guide sections

Server Side Scripting using PHP

Server Side Scripting using PHP tests how a server generates HTML before sending it to the browser. Expect syntax correction, form handling, superglobal use, and the difference between client-side and server-side execution.

Core rules and concepts

  • PHP runs on the server; the browser receives only the output, never the PHP source.
  • Variables begin with $ and are loosely typed; strings concatenate with ., not +.
  • echo and print send output; each statement ends with ;.
  • Forms: method='post' sends data in the request body, read with $_POST; method='get' appends data to the URL, read with $_GET.
  • isset() checks whether a form field was submitted before you use it.
  • include gives a warning if a file is missing; require stops execution.
  • Database access commonly uses mysqli; sanitize input or use prepared statements to reduce SQL injection.

Worked example

Form: <form method='post' action='greet.php'><input name='name'><input type='submit'></form> In greet.php: <?php if(isset($_POST['name'])){ $n = htmlspecialchars($_POST['name']); echo 'Hello, ' . $n; } ?> Reasoning: isset prevents an undefined-index warning on first load. $_POST['name'] matches the input's name attribute. htmlspecialchars neutralizes HTML characters before output. The dot joins the literal text to the variable.

Traps that cost marks

  • Using $_GET to read a form sent with method='post'.
  • Forgetting the $ sigil or the terminating semicolon.
  • Concatenating with +, which gives a wrong result or numeric warning.
  • Believing users can see PHP code through 'View Source'.
  • Using include where a missing critical file must halt the script.