why is the php showing

have a html doc called lesson3.html

[php]

Web Form Design and Development :: Lesson 3
<!-- Stylesheets -->
<link rel="stylesheet" href="css/normalize.css" />
<link rel="stylesheet" href="css/styles.css" />

<!--[if lt IE 9]>
	<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

Web Form Design and Development

Lesson 3: Commonly used form attributes

<div class="demo-lesson-nav">
	<a href="lesson2.html" class="demo-lesson-nav-prev">&larr; Previous Lesson</a>
	<a href="lesson4.html" class="demo-lesson-nav-next">Next Lesson &rarr;</a>
</div> <!-- end demo-lesson-nav -->

<div class="demo-container">
	<form action="C:\xampp\htdocs\webs\06-08\scripts\lesson 3/demo.php" method="post">
		<fieldset>
			<legend accesskey="l">A simple form</legend>
			<p>
				<label for="name">Name: <small><em>accesskey = n</em></small></label><br />
				<input type="text" id="name" name="name" value="e.g. John Smith"  />
			</p>

			<p>
				<label for="email">Email Address: <small><em>accesskey = e</em></small></label><br />
				<input type="text" id="email" name="email" accesskey="e" />
			</p>

			<p>
				<label for="pwd">Password: <small><em>accesskey = p</em></small></label><br />
				<input type="password" id="pwd" name="pwd" accesskey="p"  />
			</p>

			<p>
				<label for="gender">Gender:</label><br />
				<select name="gender" id="gender" multiple="multiple" size="10">
					<option value="0">Select a gender</option>
					<option value="1" selected="selected">Male</option>
					<option value="2">Female</option>
				</select>
			</p>

			<p>			
				<input type="checkbox" id="subscribe" name="subscribe" checked />
				<label for="subscribe">Subscribe to newsletter</label>
			</p>

			<p>
				<input type="submit" value="Register" name="submit"  />
			</p>
		</fieldset>
	</form>

</div> <!-- end demo-container -->

<footer class="demo-footer">
	<p><small>a <a href="https://tutsplus.com/">Tuts+</a> course by Adi Purdila</small></p>
</footer>
[/php]

and a php page that supposed to show the data called

demo.php

[php]

<?php // Check to see if the form has been submitted if ($_POST['submit']) { // Echo the name and gender echo 'Name: '.$_POST['name'].'
'; echo 'Gender: '; if ($_POST['gender'] == 1) { echo 'Male'; } else { echo 'Female'; } } ?>

[/php]

i fill out the form submit it and it just shows the php even the tags

[php]<?php
// Check to see if the form has been submitted
if ($_POST[‘submit’]) {

	// Echo the name and gender
	echo 'Name: '.$_POST['name'].'<br />';
	echo 'Gender: ';
	
	if ($_POST['gender'] == 1) {
		echo 'Male';
	} else {
		echo 'Female';
	}
}

?>[/php]

do i need a break or am i a bit dumb and dumber

pls advise what i have overlooked

thanks

You are posting to a local file so it’s handled by the browser / file system instead of the web server.

Change this
[php][/php]

to this
[php][/php]

or whatever relative path you have to your demo script
[php][/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service