Jump to content

Getting syntax errors... How can I fix it?


NeverPool

Recommended Posts

Ok, I'm getting a syntax error on line 48 for this dummy code I wrote and I was wondering if anyone could help me out....

 

http://test.neverpool.com/band/register.php

 

<?php 
define('TITLE', 'Register');
require('templates/header.html');
	echo '<h1>Registration Form</h1>
			<p>Register so that you can take advantage of all of this sites cool features!</p>';
	echo '<style type="text/css" media="screen">
			.error [ color: red; }
		</style>';
if ( isset($_POST['submitted']) ) {
	$problem = FALSE;
		if (empty($_POST['first_name'])) {
			$problem = TRUE;
				echo '<p class="error">Please enter your first name!</p>';
			}
		if (empty($_POST['last_name'])) {
			$problem = TRUE;
				echo '<p class="error">Please enter your last name!</p>';
			}
		if (empty($_POST['email'])) {
			$problem = TRUE;
				echo '<p class="error">Please enter your email address!</p>';
			}
		if (empty($_POST['password'])) {
			$problem = TRUE;
				echo '<p class="error">Please enter a password!</p>';
			}
		if ($_POST['password'] != $_POST ['password2']) {
			$problem = TRUE;
				echo '<p class="error">Your password did not match your confirmed password!</p>';
			}
if (!$problem) {
	echo '<p>You are now registered!</p>';


		//Email
			$body = "Thank you for registering with the Taylor Middle High Band Club! Your password is '{$_POST['password1']}'.";
			mail($_POST['email'], 'Registration Confirmation' , $body, 'From: [email protected]');


			$_POST = array();

		} else { //Forgot a field
			echo '<p class="error">You did not fill in all of the required fields!</p>';
			}
}
?>
<form action="register.php" method="post">
<p>First Name: <input type="text" name="first_name" size="20" value="<?php if (isset($_POST['first_name'])) print htmlspecialchars($_POST['first_name'])); } ?>" /></p>
<p>Last Name: <input type="text" name="last_name" size="20" value="<?php if (isset($_POST['last_name'])) print htmlspecialchars($_POST['last_name'])); } ?>" /></p>
<p>Email Address: <input type="text" name="email" size="20" value="<?php if (isset($_POST['email'])) print htmlspecialchars($_POST['email'])); } ?>" /></p>
<p>Password: <input type="password" name="password1" size="20" /></p>
<p>Confirm Password: <input type="password" name="password2" size="20" /></p>
<p><input type="submit" name="submit" value="Register!" /></p>
<input type="hidden" name="submitted" value="true" /> 
</form>
<?php require('templates/footer.html'); ?>

Link to comment
https://forums.phpfreaks.com/topic/199595-getting-syntax-errors-how-can-i-fix-it/
Share on other sites

So it'd be:

 

<p>First Name: <input type="text" name="first_name" size="20" value="<?php if (isset($_POST['first_name'])) print htmlspecialchars($_POST['first_name']); } ?>" /></p>
<p>Last Name: <input type="text" name="last_name" size="20" value="<?php if (isset($_POST['last_name'])) print htmlspecialchars($_POST['last_name']); } ?>" /></p>
<p>Email Address: <input type="text" name="email" size="20" value="<?php if (isset($_POST['email'])) print htmlspecialchars($_POST['email']); } ?>" /></p>

 

 

right?

<p>First Name: <input type="text" name="first_name" size="20" value="<?php if (isset($_POST['first_name'])){ print htmlspecialchars($_POST['first_name']); } ?>" /></p>
<p>Last Name: <input type="text" name="last_name" size="20" value="<?php if (isset($_POST['last_name'])){ print htmlspecialchars($_POST['last_name']); } ?>" /></p>
<p>Email Address: <input type="text" name="email" size="20" value="<?php if (isset($_POST['email'])){ print htmlspecialchars($_POST['email']); } ?>" /></p>

Hi there,

 

Try

<p>First Name: <input type="text" name="first_name" size="20" value="<?php if (isset($_POST['first_name'])) print htmlspecialchars($_POST['first_name']);?>" /></p>
<p>Last Name: <input type="text" name="last_name" size="20" value="<?php if (isset($_POST['last_name'])) print htmlspecialchars($_POST['last_name']);?>" /></p>
<p>Email Address: <input type="text" name="email" size="20" value="<?php if (isset($_POST['email'])) print htmlspecialchars($_POST['email']);?>" /></p>

 

you have extra "}" at the end of each print statement

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.