Solved

Verifying something is in SESSION or POST

Posted on 2008-06-13
3
185 Views
Last Modified: 2010-04-21
Hello,

I am using some simple validators to make sure a variable is entered in an input field, i am also using a couple simple validations to make sure a couple fields match.  Where I'm running into an issue, in the below snip of code i feel like something is missing, it seemed to work for a minute, than when i was working with errors messages all hell broke loose, can you please tell me if this is the correct way to verify there is something typed into this field?
// is this first part the right way to check if there is an entry in this field?
 
if ($_POST['email']) {
}
  else {
      $error_msg .= "Please provide your email address" . "<br />"; 
} 
 
// on the same field i am running this later in the script
 
if ($_POST['email'] === $_POST['vemail']){ //AND check_email($_POST['email'])){
      $_SESSION['email']=$_POST['email'];
} else {
      $error_msg .= "E-mail Addresses do not match" . "<br />";      
}

Open in new window

0
Comment
Question by:vrmetro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
jml948 earned 250 total points
ID: 21781895
i use this format when checking a field for an entry


if (isset($_POST['email']) && $_POST['email'] != "") {
}
  else {
      $error_msg .= "Please provide your email address" . "<br />"; 
}
 
if ($_POST['email'] == $_POST['vemail']){ // here i would change "===" to "=="
      $_SESSION['email']=$_POST['email'];
} else {
      $error_msg .= "E-mail Addresses do not match" . "<br />";      
}

Open in new window

0
 

Author Comment

by:vrmetro
ID: 21782222
ok, can you tell me what the difference between == and === is?
0
 

Author Closing Comment

by:vrmetro
ID: 31467041
good solution, going to keep the === because more strict.
but thank you very much.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question