Jump to content

MesiaH

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

MesiaH's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Sorry for the late reply bro, yeah you're right! Regarding checking of $_POST var i was just looking for something that works, but your's is more more efficient, i should say! and yeah don't need another error flag, can just use the construct you used. Seems like i could reduce the number of loc even more, thanks bro! will keep asking more q? forever..
  2. Thanks bro, for the quick reply! I changed the code and initialized the '$n_err' and '$e_err' to 0 and then checked if they are 1 to echo the error. However that doesn't work either. The edited code is blelow, if($_POST){ $t_name=trim($_POST["name"]); $t_email=trim($_POST["email"]); $n_err=0; $e_err=0; if($t_name==""){ $n_err=1; //echo "Please enter a name"."</br>"; } elseif($t_email==""){ $e_err=1; //echo "Please enter an email"."</br>"; } } ?> <?php if($n_err==1)echo "Please enter correct name"."</br"; ?> <?php if($e_err==1)echo "Please enter correct email"."</br>"; ?> Regarding the $_POST checking, i was checking if the _POST var would have any value! if _POST has any value then the form has been submitted and If($_POST) would return true! ain't that right?
  3. Still new to PHP, trying to get around an error! Scenario is pretty simple, i'm trying to do a sample form validation via php, this is the code, <?php if($_POST){ $t_name=trim($_POST["name"]); $t_email=trim($_POST["email"]); if($t_name==""){ $n_err=1; } elseif($t_email==""){ $e_err=1; } } ?> then towards the form fields i do this, <?php if($n_err)echo "Please enter correct name"."</br"; ?> <?php if($e_err)echo "Please enter correct email"."</br>"; ?> But this gives an error As far i see you can use php vars defined in section on others, only var inside function are local in nature if they are not using "global" prefix. Please help me figure out why im getting this error, i know it might be something simple, so kindly help, thanks!
  4. Hoping to learn some PHP, make some friends and have some fun!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.