GroundZeroStudio Posted February 24, 2007 Share Posted February 24, 2007 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 Quote Link to comment Share on other sites More sharing options...
magic2goodil Posted February 24, 2007 Share Posted February 24, 2007 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(); } } Quote Link to comment Share on other sites More sharing options...
GroundZeroStudio Posted February 24, 2007 Author Share Posted February 24, 2007 Doesnt Work Quote Link to comment Share on other sites More sharing options...
magic2goodil Posted February 24, 2007 Share Posted February 24, 2007 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(); } } Quote Link to comment Share on other sites More sharing options...
superuser2 Posted February 25, 2007 Share Posted February 25, 2007 To say 'not equal to' as a comparator, there's 2 equals signs, just like a regular comparator. So field !== 'fax', change it on the rest. That should work. If not, let us know. Quote Link to comment Share on other sites More sharing options...
magic2goodil Posted February 25, 2007 Share Posted February 25, 2007 Last time I checked, !== is the opposite of === which checks for same type and same value. You don't want to use !== here. Your problem may be the inner if statement.. what exactly is the error you are having now? Quote Link to comment Share on other sites More sharing options...
superuser2 Posted February 25, 2007 Share Posted February 25, 2007 Oh yeah, I just checked the manual, you're right. I must've been thinking of something else. Quote Link to comment Share on other sites More sharing options...
GroundZeroStudio Posted February 25, 2007 Author Share Posted February 25, 2007 None of that works. I keep getting required field entry is missing even with all the code. I just want it so you dont have to fill in all the fields Quote Link to comment Share on other sites More sharing options...
magic2goodil Posted February 25, 2007 Share Posted February 25, 2007 Show us more code, and give as the error and the line number for the error. Quote Link to comment Share on other sites More sharing options...
btherl Posted February 25, 2007 Share Posted February 25, 2007 Can you put var_dump($_POST) or print_r($_POST) at the top of your script, and verify that only the fields you expect to be blank are actually blank? I suspect it's just that your input is not what you expect. Quote Link to comment Share on other sites More sharing options...
GroundZeroStudio Posted February 25, 2007 Author Share Posted February 25, 2007 <?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 groundzerostudios@gmail.com "; $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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.