Jump to content

PHP and or should I use or


GroundZeroStudio

Recommended Posts

 

case "new":

foreach($_POST as $field => $value)

{

if ($field != "fax")

{

if ($value == "")

{

unset($_GET['do']);

$message_new = "A Required field entry is missing. Please try again.";

      include("login_form.html");

exit();

}

}

 

See the line in bold. I want it so if the field is not equal to fax, phone, or zip. how would I write it. Could you please post the entire code snippet for me.

Thanks

Link to comment
https://forums.phpfreaks.com/topic/39973-php-and-or-should-i-use-or/
Share on other sites

case "new":
	foreach($_POST as $field => $value)
	{
	if ($field != "fax" || $field != "phone" || $field != "zip")
		{
		if ($value == "")
		{
			unset($_GET['do']); 
			$message_new = "A Required field entry is missing. Please try again.";
      include("login_form.html");
			exit();
		}
	}

maybe:

case "new":
	foreach($_POST as $field => $value)
	{
	if ($field != "fax" && $field != "phone" && $field != "zip")
		{
		if ($value == "")
		{
			unset($_GET['do']); 
			$message_new = "A Required field entry is missing. Please try again.";
      include("login_form.html");
			exit();
		}
	}

<?php
/* Program: Register.php
* Desc:       Register program for the Clients only section of Ground Zero Studios
* Version:  1.00.00
*/
  session_start();
$user="****";
$host="*****";
$password="****";
$database="*****";
  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 ClientData
              WHERE LoginName='$_POST[fusername]'"; 
	$result = mysql_query($sql)
	or die("Unable to execute the specified MySQL query #1");
	$num = mysql_num_rows($result);
	if ($num == 1)  //login name was located
  {
	$sql = "SELECT LoginName FROM ClientData
	            WHERE LoginName ='$_POST[fusername]'
	            AND Password = password('$_POST[fpassword]')";
	$result2 = mysql_query($sql)
		or die("Unable to execute the specified MySQL query #2");
	$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 #3");
		header("Location: client_control_panel.php");
	}
	else
	{
		unset($do); 
		$message="Incorrect UserName/Password combination! Please try again.<br>";
		include("login_form.html");
	}
}
elseif ($num ==0)  // The login name was not located
{
	unset($do);
	$message = "Incorrect UserName/Password combination! Please try again.<br>";
	include("login_form.html"); 
}
break;

case "new":
	foreach($_POST as $field => $value)
	{
  if ($field != "fax" {RIGHT HERE I WANT IT SO IT CHECKS IF ITS NOT FAX OR PHONE OR ZIP INSTEAD OF JUST FAX} )
		{
		if ($value == "")
		{
			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-9A-Za-z]{6,6}(\-[0-9A-Za-z]{5,5})?$",$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 #4"); 
$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_query($sql);
	$sql2 = "INSERT INTO ClientData2 (LoginName, Discount,ServiceCount,Service1,Service2,Service3,Service4,Service5,CourseCount,Course1,
              Course2,Course3,Course4,Course5,Title,Reviews,Admin) VALUES
		('$newname','0%','0','none','none','none','none','none','0','none','none','none','none','none','Client','0','no')";
	$result = mysql_query($sql2);
	$_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. Your username and password are :";
	$emess.="\n\n\t$newname\n\t$newpass\n\n";
	$emess.="We strongly suggest you keep those in a safe place as your password is";
	$emess.="encrypted within our database and we cannot view it. ";
	$emess.="-See you around,";
  $emess.="The Ground Zero Studios Team";
	$ehead= "From [email protected]	   ";
	$subj = "Your client account with Ground Zero Studios";
	$mailsend=mail("$email","$subj","$emess","$ehead");
	header("Location: welcome.php");
}
break;

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

 

whatever I do it keeps returning a field is missing please try again

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.