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
Solved

Verifying something is in SESSION or POST

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

856 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