Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Verifying something is in SESSION or POST

Posted on 2008-06-13
3
Medium Priority
?
187 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 1000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…
Suggested Courses

730 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