Jump to content

Parse Error


pdenlinger

Recommended Posts

Umm actually i think the error is right there... try this instead

[code]<?php
/* Display the form. */
print "<form action='register.php' method='post'><p>";

print "Username: <input type='text' name='username' size='20' value='{$_POST['username']}' />

";
?>[/code]

Before when $_POST['username'] was called i thought the first ' is where to start normal echoing, leaving just $_POST[ in php.
Link to comment
Share on other sites

I have posted more lines of code surrounding the culprit area.

---------------------------------------------------

if (!problem) {/* If there weren't any problems... */

print '<p>You are now registered!<br />Okay, you are not really registered but...</p>';

} else { /* Forgot a field. */

print '<p>Please try again!</p>;'


/* End of handle form IF. */

/* Display the form. */
print '<form action="register.php" method="post"><p>';

print 'Username: <input type="text" name="username" size="20" value="' . $_POST['username'] . ' " />
<br />';
Last name: <input type="text" name="last_name" size="20" value="' . $_POST['last_name'] . ' " />
<br />';
Email address: <input type="text" name="username" size="20" value="' . $_POST['email'] . ' " />
<br />';

print 'Password: <input type="password" name="password1" size="20" /><br />
Confirm Password: <input type="password" name="password2" size="20" /><br />
<input type="submit" name="submit" value="Register!" /></p>
</form>';
Link to comment
Share on other sites

You don't start these lines with either "print" or "echo":
[code]<?php
Last name: <input type="text"  name="last_name" size="20" value="' . $_POST['last_name'] . ' " />

';
Email address: <input type="text"  name="username" size="20" value="' . $_POST['email'] . ' " />

';
?>[/code]

Ken
Link to comment
Share on other sites

OK, here is the whole body of code with beginning and ending [code] tags.

Thank you.

-------------------------------------------------------------------------

[code]
<?php // Script 8.9 - register.php
// This page lets people register for the site (sort of).

// Address error handling.
ini_set ('display_errors', 1);
error_reporting (E_ALL & ~E_NOTICE);

// Set the page title and include the header file.
define ('TITLE', 'Register');
require ('templates/header.html');

// Basic HTML formatting stuff.
print '<div id="leftcontent">
<h1>Registration Form</h1>
<p>Register so that you can take advantage of certain features like this, that, and the other thing.</p>';

// Check if the form has been submitted.
if ( isset ($_POST['submit'])) {

$problem = FALSE; // No problems so far.

// Check for each value.
if (empty ($_POST['username'])) {
$problem = TRUE;
print '<p>Please enter a username!</p>';
}

if (empty ($_POST['first_name'])) {
$problem = TRUE;
print '<p>Please enter your first name!</p>';
}

if (empty ($_POST['last_name'])) {
$problem = TRUE;
print '<p>Please enter your last name!</p>';
}

if (empty ($_POST['email'])) {
$problem = TRUE;
print '<p>Please enter your email address!</p>';
}

if (empty ($_POST['password1'])) {
$problem = TRUE;
print '<p>Please enter a password!</p>';
}

if ($_POST['password1'] != $_POST['password2']) {
$problem = TRUE;
print '<p>Your password did not match your confirmed password!</p>';
}

if (!$problem) { // If there weren't any problems...

print '<p>You are now registered!<br />Okay, you are not really registered but...</p>';

} else { // Forgot a field.

print '<p>Please try again!</p>';

}

} // End of handle form IF.

// Display the form.
print '<form action="register.php" method="post"><p>';

print 'Username: <input type="text" name="username" size="20" value="' . $_POST['username'] . '" /><br />';

print 'First Name: <input type="text" name="first_name" size="20" value="' . $_POST['first_name'] . '" /><br />
Last Name: <input type="text" name="last_name" size="20" value="' . $_POST['last_name'] . '" /><br />
Email Address: <input type="text" name="email" size="20" value="' . $_POST['email'] . '" /><br />';

print 'Password: <input type="password" name="password1" size="20" /><br />
Confirm Password: <input type="password" name="password2" size="20" /><br />
<input type="submit" name="submit" value="Register!" /></p>
</form>';

// Complete the HTML formatting stuff.
print '</div>';

require ('templates/footer.html'); // Need the footer.
?>
[/code][/code]
Link to comment
Share on other sites

Uploaded the code to my web server and am still getting the same error message on line 63 in my editor, and on the web server. The error reads "Parse error: syntax error, unexpected T_PRINT in register.php on line 63"

Here is line 63:
[code]
print '<form action="register.php" method="post"><p>';   
[/code]
Link to comment
Share on other sites

Are you sure that the source you posted here and the code you're getting the error in are the same? I took your code, put it on my server and commented out the two requires. No errors were display and the form was displayed. Can you post the source for the two required files?

Ken
Link to comment
Share on other sites

Here is the code for the header file:
[code]
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>
<?php //Print the page title.
if (defined('TITLE')) { //Is the title defined?
print TITLE;
} else { //The title is not defined.
print 'Elliott Smith Fan Club';
}
?>
</title>
<style type="text/css">
body {
margin:0px 0px 0px 0px;
background: #9F9;
}

#leftcontent {
float:left;
width:67%;
background:#fff;
border-right:2px solid #000;
border-bottom:2px solid #000;
margin-right:15px;
padding-bottom:20px;
}

p,h1,pre {
margin:0px 30px 10px 30px;
}

h1 {
font-size:14px;
padding-top:10px;
}

#rightcontent p {
font-size:14px;
margin-left:0px;
}

.linkback {  position: absolute; width: 300px;  height: 10px;  right: 0;  top: 0;  z-index:1999; font: normal normal normal 10pt arial}.linkbacktitle {  background:#333399; cursor:move; color:white; padding: 2px; font-weight: bold}.linkbackinner {  border:1px solid #06060a;  background:#efefff;  text-align: left;  opacity:0.85; }.linkbackinner ul { list-style-type: circle ; margin-left: 1px; padding-left: 15px}.linkbackinner li { margin-top: 1px; margin-bottom: 1px; margin-left: 1px; color: gray;  }.linkbackinner a:link {  color: #0000DD;  }.linkbackinner a:visited {  color: #AF00AF;  }.linkbackinner a:hover {  background-color: #ffcc99;}


</style>
</head>
<body>
<!-- BEGIN CHANGEABLE CONTENT. -->
</body></html>
[/code]

Here is the code for the footer file:
[code]
<!-- END CHANGEABLE CONTENT. -->
<div id="rightcontent">
<h1>Navigation</h1>
<p>
<a href="index.php">Home</a><br />
<a href="albums.php">Discography</a><br />
<a href="login.php">Login</a><br />
<a href="register.php">Register</a><br />
</p>

<p><em>
<?php
print date ('g:i a l F j' );
?>
</em></p>
</div>
<!-- Script 8.7 - footer.htm  (Second version after Script 8.3-->
</body>
</html>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.