Solved

Verifying something is in SESSION or POST

Posted on 2008-06-13
3
182 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
  • 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
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.

773 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