PHP beginner

  • psilvaj_12
  • Newbie
  • Newbie
  • psilvaj_12
  • Posts: 9

Post 3+ Months Ago

hello,

I have a form with the following fields:

$Num
$f_name
$l_name
$ent
$dist
$conc
$freg
$local


And I have researched on how to validate filling these fields and could not. Can you help me?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • steve101
  • Beginner
  • Beginner
  • steve101
  • Posts: 35

Post 3+ Months Ago

Validate them in what way?

Are you posting the form values into those variables?

e.g $Num=$_POST['num']; ?

Regards
  • psilvaj_12
  • Newbie
  • Newbie
  • psilvaj_12
  • Posts: 9

Post 3+ Months Ago

Yes, but with GET. Then I wanted the form fields must be filled.

Regards
  • steve101
  • Beginner
  • Beginner
  • steve101
  • Posts: 35

Post 3+ Months Ago

I generally always use POST, but it will be the same with GET.

Do you want to make sure that no fields are empty? That sort of thing?

PHP Code: [ Select ]
 
if($f_name=='' || $l_name=='' || $Num=='' etc etc){
//Do whatever processing you need to show an error e.g
echo 'Message';
}
 
 
  1.  
  2. if($f_name=='' || $l_name=='' || $Num=='' etc etc){
  3. //Do whatever processing you need to show an error e.g
  4. echo 'Message';
  5. }
  6.  
  7.  


Obviously, this is just a basic crude example - based on my perception of what you're trying to do. The || pipes stand for 'Or' basically.

Hope this helps
  • psilvaj_12
  • Newbie
  • Newbie
  • psilvaj_12
  • Posts: 9

Post 3+ Months Ago

Yes, this code generated a message indicating that the fields were empty and had to be fulfilled, but clicking on the button next allowed to continue even with empty fields.
  • steve101
  • Beginner
  • Beginner
  • steve101
  • Posts: 35

Post 3+ Months Ago

PHP Code: [ Select ]
if($f_name=='' || $l_name=='' || $Num=='' etc etc){
//Do whatever processing you need to show an error e.g
echo 'Message';
} else {
//continue with processing...
/* if you don't use the else part, it'll just show the error and carry on. If you do, then it'll continue only if there are no errors...
}
 
  1. if($f_name=='' || $l_name=='' || $Num=='' etc etc){
  2. //Do whatever processing you need to show an error e.g
  3. echo 'Message';
  4. } else {
  5. //continue with processing...
  6. /* if you don't use the else part, it'll just show the error and carry on. If you do, then it'll continue only if there are no errors...
  7. }
  8.  

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 91 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.