...

View Full Version : help with error in code



sirborder
03-27-2007, 08:17 AM
OK,
I am trying to build a COMPLETE members system starting from the registration script up, and I am stumped with an error in my registration script! The error is: Parse error: parse error, unexpected T_ELSE in /homepages/0/d176381271/htdocs/kylecaleb/currentproject/register.php on line 100
All line 100 is }else{
I'm stumped on this one.

Here is the code for my page:


<?php include('header.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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>SD Computerz - Register</title>
<style type="text/css">
<!--
.style1 {color: #000000}
body,td,th {
color: #FFFFFF;
}
body {
background-color: #000000;
}
-->
</style>

</head>
<body>
<span class="style1"></span>
<center><h1>SD Computerz</h1></center><br />
<?php include('menu.html') ?>
<hr />
<center>
<?php
$user="user";
$password="pass";
$database="database";
$host="host";
mysql_connect($host,$user,$password)or die("Could not connect to database");
mysql_select_db($database) or die( "Unable to select database");

$name=$_POST['name'];
$pass=$_POST['pass'];
$pass2=$_POST['confirm_pass'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$mobile=$_POST['mobile'];
$address=$_POST['address'];
$city=$_POST['city'];
$state=$_POST['state'];
$zip=$_POST['zip'];
$package=$_POST['package'];
if($_SESSION['logged_in'] == 1)
{ echo('You are already registered. Please <a href="http://www.sdcomutrez.com/logout.php">log out</a> or go to the <a href="http://www.sdcomputerz.com">homepage</a>');
} else {
if(isset($HTTP_POST_VARS['submit']));
{
if(!$name) { die('Alert: Name field left blank!');
}
$q2 = mysql_query("SELECT * FROM `members` WHERE `name` = '".$name."'");
$q3 = mysql_fetch_object($q2);
if($q3->name == $name) {
die('Alert: The name $name is already stored in our database. Please <a href="http://www.sdcomputerz.com/contact.php">contanct an administrator</a> if you feel there is a mistake');
}
if(!$pass) { die('Alert: Password field was left blank.');
}
if(!$pass2) { die('Alert: Verify Password field was left blank.');
}
if($pass != $pass2) { die('Alert: Password fields did not match.');
}
if(!$email) { die('Alert: Email field was left blank.');
}
if(!$phone) { die('Alert: Phome field left blank.');
}
if(!$address) { die('Alert: Address field left blank.');
}
if(!$city) { die('Alert: City field left blank.');
}
if(!$state) { die('Alert: State field left blank.');
}
if(!$zip) { die('Alert: Zip field left blank.');
}

$query= "INSERT INTO `members`
VALUES('','$name','$pass','$email','$phone','$mobile','$address','$city','$state','$zip','$package')";
mysql_query($query);
echo('Thank you for signing up. You will recieve an email when your submision is reviewed. You may now <a href="http://www.surfacehawaii.com/login.php">login</a>.');
mysql_close();
}else{
?>
<table>
<form name="register" action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<tr>
<td>
<p>*Indicates required field.</p>
</td>
</tr>
<tr>
<td>
<p>Full Name*</p>
</td>
<td>
<input type="text" name="name" />
</td>
</tr>
<tr>
<td>
<p>Password*</p>
</td>
<td>
<input type="password" name="pass" />
</td>
</tr>
<tr>
<td>
<p>Confirm Password*</p>
</td>
<td>
<input type="password" name="pass2" />
</td>
</tr>
<tr>
<td>
<p>Email*</p>
</td>
<td>
<input type="text" name="email" />
</td>
</tr>
<tr>
<td>
<p>Phone*</p>
</td>
<td>
<input type="text" name="phone" />
</td>
</tr>
<tr>
<td>
<p>Mobile</p>
</td>
<td>
<input type="text" name="mobile" />
</td>
</tr>
<tr>
<td>
<p>Street Address*</p>
</td>
<td>
<input type="text" name="address" />
</td>
</tr>
<tr>
<td>
<p>City*</p>
</td>
<td>
<input type="text" name="city" />
</td>
</tr>
<tr>
<td>
<p>State*</p>
</td>
<td>
<input type="text" name="state" />
</td>
</tr>
<tr>
<td>
<p>Zip Code*</p>
</td>
<td>
<input type="text" name="zip" />
</td>
</tr>
<tr>
<td>
<p>Package</p>
</td>
<td>
<select name="package">
<option value="Personnel">Personnel</option>
<option value="Nonprofit">Non-Profit</option>
<option value="Business">Business</option>
</select>
</td>
</tr>
<tr>
<td>
</td>
<td>
<input type="submit" value="Submit" />
</td>
</tr>
</form>
</table>
<?php
}
}
?>
</center>
</body>
</html>

_Aerospace_Eng_
03-27-2007, 08:35 AM
Put your brackets on their own line for example something like this. Your error though is you have a semi-colon after

if(isset($HTTP_POST_VARS['submit']))
Something like this is more legible.

<?php include('header.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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
<title>SD Computerz - Register</title>
<style type="text/css">
<!--
.style1 {color: #000000}
body,td,th {
color: #FFFFFF;
}
body {
background-color: #000000;
}
-->
</style>
</head>
<body>
<span class="style1"></span>
<center>
<h1>SD Computerz</h1>
</center>
<br />
<?php include('menu.html') ?>
<hr />
<center>
<?php

mysql_connect($host,$user,$password)or die("Could not connect to database");
mysql_select_db($database) or die( "Unable to select database");

$name=$_POST['name'];
$pass=$_POST['pass'];
$pass2=$_POST['confirm_pass'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$mobile=$_POST['mobile'];
$address=$_POST['address'];
$city=$_POST['city'];
$state=$_POST['state'];
$zip=$_POST['zip'];
$package=$_POST['package'];
if($_SESSION['logged_in'] == 1)
{
echo('You are already registered. Please <a href="http://www.sdcomutrez.com/logout.php">log out</a> or go to the <a href="http://www.sdcomputerz.com">homepage</a>');
}
else
{
if(isset($HTTP_POST_VARS['submit']));
{
if(!$name)
{
die('Alert: Name field left blank!');
}
$q2 = mysql_query("SELECT * FROM `members` WHERE `name` = '".$name."'");
$q3 = mysql_fetch_object($q2);
if($q3->name == $name)
{
die('Alert: The name $name is already stored in our database. Please <a href="http://www.sdcomputerz.com/contact.php">contanct an administrator</a> if you feel there is a mistake');
}
if(!$pass)
{
die('Alert: Password field was left blank.');
}
if(!$pass2)
{
die('Alert: Verify Password field was left blank.');
}
if($pass != $pass2)
{
die('Alert: Password fields did not match.');
}
if(!$email)
{
die('Alert: Email field was left blank.');
}
if(!$phone)
{
die('Alert: Phome field left blank.');
}
if(!$address)
{
die('Alert: Address field left blank.');
}
if(!$city)
{
die('Alert: City field left blank.');
}
if(!$state)
{
die('Alert: State field left blank.');
}
if(!$zip)
{
die('Alert: Zip field left blank.');
}
$query= "INSERT INTO `members` VALUES('','$name','$pass','$email','$phone','$mobile','$address','$city','$state','$zip','$package')";
mysql_query($query);
echo('Thank you for signing up. You will recieve an email when your submision is reviewed. You may now <a href="http://www.surfacehawaii.com/login.php">login</a>.');
mysql_close();
}
else
{
?>
<table>
<form name="register" action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<tr>
<td><p>*Indicates required field.</p></td>
</tr>
<tr>
<td><p>Full Name*</p></td>
<td><input type="text" name="name" />
</td>
</tr>
<tr>
<td><p>Password*</p></td>
<td><input type="password" name="pass" />
</td>
</tr>
<tr>
<td><p>Confirm Password*</p></td>
<td><input type="password" name="pass2" />
</td>
</tr>
<tr>
<td><p>Email*</p></td>
<td><input type="text" name="email" />
</td>
</tr>
<tr>
<td><p>Phone*</p></td>
<td><input type="text" name="phone" />
</td>
</tr>
<tr>
<td><p>Mobile</p></td>
<td><input type="text" name="mobile" />
</td>
</tr>
<tr>
<td><p>Street Address*</p></td>
<td><input type="text" name="address" />
</td>
</tr>
<tr>
<td><p>City*</p></td>
<td><input type="text" name="city" />
</td>
</tr>
<tr>
<td><p>State*</p></td>
<td><input type="text" name="state" />
</td>
</tr>
<tr>
<td><p>Zip Code*</p></td>
<td><input type="text" name="zip" />
</td>
</tr>
<tr>
<td><p>Package</p></td>
<td><select name="package">
<option value="Personnel">Personnel</option>
<option value="Nonprofit">Non-Profit</option>
<option value="Business">Business</option>
</select>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Submit" />
</td>
</tr>
</form>
</table>
<?php
}
}
?>
</center>
</body>
</html>

Also DO NOT PUT YOUR MYSQL LOGIN INFO ON THE FORUMS.

sirborder
03-27-2007, 08:44 AM
my bad
Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum