Jump to content

annoying php error with login forms


GroundZeroStudio

Recommended Posts

I keep getting a stupid parse error and it is really annoying

See the error at :http://groundzero.1111mb.com/login.php

 

Code is as following: (note: Is not all of the code, i have to much:

else

{

$today = date("Y-m-d");

$sql = "INSERT INTO ClientData (LoginName, CreateDate, Password,FirstName,Lastname,Street,City,State,Zip,Phone,Fax,Email) VALUES

('$newname','$today',password('$newpass'),'$firstname','$lastname','$street','$city','$state','$zip','$phone',

'$fax','$email')";

mysql_quey($sql);

$_SESSION['auth']="yes";

$_SESSION['logname'] = $newname;

$emess= "You have just signed up as a client with Ground Zero Studios. Our team will begin working with you to finish";

$emess="your service, so expect some emails from us soon. To check the status of your service, login to GZS with your";

$emess=" user name and password";

$ehead="From groundzerostudios@gmail.com   ";

$subj = "Your client account with Ground Zero Studios";

$mailsend=mail("$email","$subj","$emess","ehead");

header("Location: index.php");

}

break;

 

default: (HERE IS WHERE ERROR OCCURS:

{

include("login_form.html");

exit();

}

?>

 

All of my PHP editors/debuggers say there is NO errors, so I can not figure out the problem. All help is appreciated.

Link to comment
Share on other sites

I also noticed that for $emess, you're not adding to the string.  You just keep replacing the text each time, so that by the time it ends, $emess = " username and password".  You want to be using .= not just =

 

Otherwise, the only error I see is what someone pointed out ... default only applies to a switch statement, not an if/else series ... if you have a full switch statement, post the entire statement.  Otherwise, that's your issue.

Link to comment
Share on other sites

<?php
/* Program: Register.php
* Desc:       Register program for the Clients only section of Ground Zero Studios
* Version:  1.00.00
*/
  session_start();
  include("rebound.php"); 
  switch (@$_GET['do'])
  {
case "login";
	$connection = mysql_connect($host, $user,$password)
	or die("Couldn't connect to a valid server.");
	$db = mysql_select_db($database, $connection)
	or die("Couldn't select a valid database");

	$sql = "SELECT LoginName FROM $database
              WHERE LoginName='$_POST[fusername]'"; 
	$result = mysql_query($sql)
	or die("Unable to execute the specified MySQL query");
	$num = mysql_num_rows($result);
	if ($num == 1)  //login name was located
  {
	$sql = "SELECT LoginName FROM $database
	            WHERE LoginName ='$_POST[fusername]'
	            AND Password=password('$_POST[fpassword]')";
	$result2 = mysql_query($sql)
		or die("Unable to execute the specified MySQL query");
	$num2 = mysql_num_rows($result2); 
	if ($num2 > 0)  //the correct password was entered
	{ 
		$_SESSION['auth']="yes";
		$logname=$_POST['fusername'];
		$_SESSION['logname'] = $logname; 
		$today = date("Y-m-d h:m:s");
		$sql = "INSERT INTO Login (LoginName, LoginTime)
		            VALUES ('$logname','today')";
		mysql_query($sql)   or die("Unable to execute the specified MySQL query");
		header("Location;  Member_page.php"); 
	}
	else
	{
		unset($do); 
		$message="The Login Name, '$_POST[fusername]' 
			 exists, but you have entered the incorrect password! Please try again.<br>";
		include("loginform.inc"); 
	}
}
elseif ($num ==0)  // The login name was not located
{
	unset($do);
	$message = "The Login Name you entered is not a valid Login Name. If you wish to create this login name please feel
		    free to register it. If you have already registered please enter it again.<br>";
	include("login_form.html"); 
}
break;

case "new":
	foreach($_POST as $field => $value)
	{
		if ($field != "fax")
		{
			unset($_GET['do']); 
			$message_new = "A Required field entry is missing. Please try again.";
			include("login_form.html"); 
			exit();
		}
	}
	if (ereg("(Name)", $field))
	{
	/*if (!ereg("^[A-Za-z' -]{1,50}$",$value))
	{
		unset($_GET['do']);
		$message_new = "$field is not a valid name. Please try again."; 
		include("login_form.html");
		exit();
	}*/
	} 
	$$field = strip_tags(trim($value));
} //end foreach
if (!ereg("^[0-9]{5,5}(\-[0-9]{4,4})?$",$zip))
{
	unset($_get['do']); 
	$message_new = "$zip is not a valid zip code. Please try again."; 
	include("login_form.html");
	exit();
}	
if (!ereg("^[0-9)(xX -]{7,20}$",$phone))
{
	unset($_GET['do']);
	$message_new = "$phone is not a valid phone number. Please try again.";
	include("login_form.html");
	exit(); 
}
if ($fax != "" )
{
	if (!ereg("^[0-9)(xX -]{7,20}$",$fax))
	{
		unset($_GET['do']);
		$message_new = "$fax is not a valid fax machine number. Please try again.";
		include("login_form.html") ;
		exit();
	}
}
if (!ereg("^.+@.+\\..+$",$email))
{
	unset($_GET['do']); 
	$message_new  = "$email is not a valid email address. Please re-enter it.";
	include("login_form.html");
	exit(); 
}
/* check to see if login name already exists in the database */
$connection =mysql_connect($host,$user,$password)
	or die ("Unable to connect to server");
$db = mysql_select_db($database,$connection)
	or die("Unable to select a valid database");
$sql = "SELECT LoginName FROM ClientData
	WHERE LoginName='newname'"; 
$result = mysql_query($sql)
	or die("Unable to execute specified MySQL query"); 
$num = mysql_numrows($result);
if ($num > 0)
{
	unset($_GET['do']);
	$message_new = "$newname already registered. Please select another Member ID.";
	include("login_form.html");
	exit();
}
else
{
	$today = date("Y-m-d");
	$sql = "INSERT INTO ClientData (LoginName, CreateDate, 			Password,FirstName,Lastname,Street,City,State,Zip,Phone,Fax,Email) VALUES
		('$newname','$today',password('$newpass'),'$firstname','$lastname','$street','$city','$state','$zip','$phone',
		 '$fax','$email')"; 
	mysql_quey($sql); 
	$_SESSION['auth']="yes";
	$_SESSION['logname'] = $newname; 
	$emess= "You have just signed up as a client with Ground Zero Studios. Our team will begin working with you to finish";
	$emess="your service, so expect some emails from us soon. To check the status of your service, login to GZS with your";
	$emess=" user name and password";
	$ehead="From groundzerostudios@gmail.com	   ";
	$subj = "Your client account with Ground Zero Studios";
	$mailsend=mail("$email","$subj","$emess","ehead");
	header("Location: index.php");
}
break;

default:
	{
	include("login_form.html");
	exit();
	}
?>

Link to comment
Share on other sites

STILL WONT WORK!!!! Annoying me now. :'(

 

<?php
/* Program: Register.php
* Desc:       Register program for the Clients only section of Ground Zero Studios
* Version:  1.00.00
*/
  session_start();
  include("rebound.php"); 
  switch (@$_GET['do'])
  {
case "login":
	$connection = mysql_connect($host, $user,$password)
	or die("Couldn't connect to a valid server.");
	$db = mysql_select_db($database, $connection)
	or die("Couldn't select a valid database");

	$sql = "SELECT LoginName FROM $database
              WHERE LoginName='$_POST[fusername]'"; 
	$result = mysql_query($sql)
	or die("Unable to execute the specified MySQL query");
	$num = mysql_num_rows($result);
	if ($num == 1)  //login name was located
  {
	$sql = "SELECT LoginName FROM $database
	            WHERE LoginName ='$_POST[fusername]'
	            AND Password=password('$_POST[fpassword]')";
	$result2 = mysql_query($sql)
		or die("Unable to execute the specified MySQL query");
	$num2 = mysql_num_rows($result2); 
	if ($num2 > 0)  //the correct password was entered
	{ 
		$_SESSION['auth']="yes";
		$logname=$_POST['fusername'];
		$_SESSION['logname'] = $logname; 
		$today = date("Y-m-d h:m:s");
		$sql = "INSERT INTO Login (LoginName, LoginTime)
		            VALUES ('$logname','today')";
		mysql_query($sql)   or die("Unable to execute the specified MySQL query");
		header("Location;  Member_page.php"); 
	}
	else
	{
		unset($do); 
		$message="The Login Name, '$_POST[fusername]' 
			 exists, but you have entered the incorrect password! Please try again.<br>";
		include("loginform.inc"); 
	}
}
elseif ($num ==0)  // The login name was not located
{
	unset($do);
	$message = "The Login Name you entered is not a valid Login Name. If you wish to create this login name please feel
		    free to register it. If you have already registered please enter it again.<br>";
	include("login_form.html"); 
}
break;

case "new":
	foreach($_POST as $field => $value)
	{
		if ($field != "fax")
		{
			unset($_GET['do']); 
			$message_new = "A Required field entry is missing. Please try again.";
			include("login_form.html"); 
			exit();
		}
	}
	if (ereg("(Name)", $field))
	{
	/*if (!ereg("^[A-Za-z' -]{1,50}$",$value))
	{
		unset($_GET['do']);
		$message_new = "$field is not a valid name. Please try again."; 
		include("login_form.html");
		exit();
	}*/
	} 
	$$field = strip_tags(trim($value));
} //end foreach
if (!ereg("^[0-9]{5,5}(\-[0-9]{4,4})?$",$zip))
{
	unset($_get['do']); 
	$message_new = "$zip is not a valid zip code. Please try again."; 
	include("login_form.html");
	exit();
}	
if (!ereg("^[0-9)(xX -]{7,20}$",$phone))
{
	unset($_GET['do']);
	$message_new = "$phone is not a valid phone number. Please try again.";
	include("login_form.html");
	exit(); 
}
if ($fax != "" )
{
	if (!ereg("^[0-9)(xX -]{7,20}$",$fax))
	{
		unset($_GET['do']);
		$message_new = "$fax is not a valid fax machine number. Please try again.";
		include("login_form.html") ;
		exit();
	}
}
if (!ereg("^.+@.+\\..+$",$email))
{
	unset($_GET['do']); 
	$message_new  = "$email is not a valid email address. Please re-enter it.";
	include("login_form.html");
	exit(); 
}
/* check to see if login name already exists in the database */
$connection =mysql_connect($host,$user,$password)
	or die ("Unable to connect to server");
$db = mysql_select_db($database,$connection)
	or die("Unable to select a valid database");
$sql = "SELECT LoginName FROM ClientData
	WHERE LoginName='newname'"; 
$result = mysql_query($sql)
	or die("Unable to execute specified MySQL query"); 
$num = mysql_numrows($result);
if ($num > 0)
{
	unset($_GET['do']);
	$message_new = "$newname already registered. Please select another Member ID.";
	include("login_form.html");
	exit();
}
else
{
	$today = date("Y-m-d");
	$sql = "INSERT INTO ClientData (LoginName, CreateDate, 			Password,FirstName,Lastname,Street,City,State,Zip,Phone,Fax,Email) VALUES
		('$newname','$today',password('$newpass'),'$firstname','$lastname','$street','$city','$state','$zip','$phone',
		 '$fax','$email')"; 
	mysql_quey($sql); 
	$_SESSION['auth']="yes";
	$_SESSION['logname'] = $newname; 
	$emess= "You have just signed up as a client with Ground Zero Studios. Our team will begin working with you to finish";
	$emess.="your service, so expect some emails from us soon. To check the status of your service, login to GZS with your";
	$emess.=" user name and password";
	$ehead="From groundzerostudios@gmail.com	   ";
	$subj = "Your client account with Ground Zero Studios";
	$mailsend=mail("$email","$subj","$emess","ehead");
	header("Location: index.php");
}
break;

default:
	include("login_form.html");
}
?>

Still parse error, unexpected T_DEFAULT

Link to comment
Share on other sites

You have a comment that says "end foreach". That end bracket is not the end of the foreach. The foreach was ended by a end bracket a few lines before, so PHP is taking that end bracket as the end of the switch statement and that causes the error later.

 

Ken

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.