Solved

Verifying something is in SESSION or POST

Posted on 2008-06-13
3
181 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
Comment Utility
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
Comment Utility
ok, can you tell me what the difference between == and === is?
0
 

Author Closing Comment

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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
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…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now