Jump to content
Larry Ullman's Book Forums

Chapter 6 Issue


Recommended Posts

After a long absense, I've decided to try to once again get my head around php.  I have made to chapter 6 but seem to have an issue that I cannot debug.  Was wondering if someone could have a look at my code to see what I am missing or doing wrong?

register.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTDxhtml1-transitional.dtd"><html xmlns="http:///www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv-"content-type" content="text/html; charset=utf-8"/>
<title>Registration Form</title>
</head>
<body>
<!-- register.html -->
<div><p style="font-size:20px"><strong>Please fill out this form to register:</strong></p>
<form action="handle_reg.php" method="post">
<p>Email Address: <input type="text" name="email" size="30" /></p>
<p>Password: <input type="password" name="password" size="20" /></p>
<p>Confirm Password: <input type="password" name="confirm" size="20" /></p>
<p>Year You Were Born: <input type="text" name="year" value="YYYY" size="4" /></p>
<p>Favorite Color: <select name="color"><option value="">Pick One</option><option value="red">Red</option><option value="yellow">Yellow</option>
<option value="green">Green</option><option value="blue">Blue</option></select></p>
<p><input type="checkbox" name="terms" value="yes" /> I agree to the terms (whatever they may be).</p>

<input type="submit" name="submit" value="Register" />
</form>
</div>
</body>
</html>

handle_reg.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title>Registration</title>
</head>
<body>
<h1>Registration Results</h1>
<?php // Script 6.2 - handle_reg.php
/* This script receives seven values from register.html:
email, password, confirm, year, terms, color, submit */

// Address error management, if you want.

// Flag variable to track success:
$okay = TRUE;

// If there were no errors, print a success message:
if ($okay) {
	print '<p>You have been successfully registered (but not really).</p>';
}
?>
</body>
</html>

Here is what I see when filling out the form:

 

script6.2.png

I am using wamp with apache 2.4.33, php 7.2.4 and mysql 5.7.21

Edited by nootkan
added server details
Link to comment
Share on other sites

Okay I was able to figure out what I did wrong. It seems that somehow I managed to call the scripts in the browers with c:/ instead of http://localhost.  Not sure when or how that happened as I usually just reopen the browser from my last session.  In any case, I'm good to go on. 

Link to comment
Share on other sites

 Share

×
×
  • Create New...