NeverPool Posted April 24, 2010 Share Posted April 24, 2010 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 More sharing options...
mrMarcus Posted April 24, 2010 Share Posted April 24, 2010 <?php if (isset($_POST['first_name'])) print htmlspecialchars($_POST['first_name'])); } ?> one too many ) at the end. same thing for the lines following that one. Link to comment https://forums.phpfreaks.com/topic/199595-getting-syntax-errors-how-can-i-fix-it/#findComment-1047663 Share on other sites More sharing options...
NeverPool Posted April 24, 2010 Author Share Posted April 24, 2010 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? Link to comment https://forums.phpfreaks.com/topic/199595-getting-syntax-errors-how-can-i-fix-it/#findComment-1047664 Share on other sites More sharing options...
NeverPool Posted April 24, 2010 Author Share Posted April 24, 2010 Sorry for the double post, but now I'm getting an "unexpected T_PRINT" error. Same URL as above. Link to comment https://forums.phpfreaks.com/topic/199595-getting-syntax-errors-how-can-i-fix-it/#findComment-1047667 Share on other sites More sharing options...
jamesxg1 Posted April 24, 2010 Share Posted April 24, 2010 <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> Link to comment https://forums.phpfreaks.com/topic/199595-getting-syntax-errors-how-can-i-fix-it/#findComment-1047669 Share on other sites More sharing options...
OOP Posted April 24, 2010 Share Posted April 24, 2010 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 Link to comment https://forums.phpfreaks.com/topic/199595-getting-syntax-errors-how-can-i-fix-it/#findComment-1047671 Share on other sites More sharing options...
Pikachu2000 Posted April 24, 2010 Share Posted April 24, 2010 There are no opening curly braces for your if conditionals - if( some condition ) { do something } Link to comment https://forums.phpfreaks.com/topic/199595-getting-syntax-errors-how-can-i-fix-it/#findComment-1047672 Share on other sites More sharing options...
NeverPool Posted April 25, 2010 Author Share Posted April 25, 2010 Thanks a lot you guys! Link to comment https://forums.phpfreaks.com/topic/199595-getting-syntax-errors-how-can-i-fix-it/#findComment-1047802 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.