שלום,
אני מנסה להכין מערכת הרשמה לאתר...
בכל מקרה, רציתי שאם המשתמש לא ממלא שדה מסויים זו יודיע לו איזה שדות לא מולאו.
חשבתי הרבה איך לעשות את זה (אני ממש מתחיל בזה...אז אין לי הרבה ידע)
אז עשיתי משהו כזה:
PHP קוד:
if(isset($_POST['user']) && isset($_POST['password']) && isset($_POST['confp']) && isset($_POST['email']))
{
if($_POST['user']!=NULL)
{
$u=1;
}
else
{
$u=0;
}
if($_POST['password']!=NULL)
{
$p=1;
}
else
{
$p=0;
}
if($_POST['confp']!=NULL)
{
$c=1;
}
else
{
$c=0;
}
if($_POST['email']!=NULL)
{
$e=1;
}
else
{
$e=0;
}
if(($u==0) && ($p==0) && ($c==0) && ($e==0))
{
echo "Error: Username, Password, Confirm Password and Email fields are empty";
}
if(($u==0) && ($p==0) && ($c==0) && ($e==1))
{
echo "Error: Username, Password and confirm password fields are empty";
}
if(($u==0) && ($p==0) && ($c==1) && ($e==0))
{
echo "Error: Username, password and email fields are empty";
}
if(($u==0) && ($p==0) && ($c==1) && ($e==1))
{
echo "Error: username and password fields are empty";
}
if(($u==0) && ($p==1) && ($c==0) && ($e==0))
{
echo "Error: Username, confirm password and email fields are empty";
}
if(($u==0) && ($p==1) && ($c==0) && ($e==1))
{
echo "Error: username and confirm password fields are empty";
}
if(($u==0) && ($p==1) && ($c==1) && ($e==0))
{
echo "Error: username and email fields are empty";
}
if(($u==0) && ($p==1) && ($c==1) && ($e==1))
{
echo "Error: username field is empty";
}
if(($u==1) && ($p==0) && ($c==0) && ($e==0))
{
echo "Error: Password, confirm password and email fields are empty";
}
if(($u==1) && ($p==0) && ($c==0) && ($e==1))
{
echo "Error: Please Choose Password and confirm it";
}
if(($u==1) && ($p==0) && ($c==1) && ($e==0))
{
echo "Error: password and email fields are empty";
}
if(($u==1) && ($p==0) && ($c==1) && ($e==1))
{
echo "Error: password field is empty";
}
if(($u==1) && ($p==1) && ($c==0) && ($e==0))
{
echo "Error: Confirm password and email field is empty";
}
if(($u==1) && ($p==1) && ($c==0) && ($e==1))
{
echo "Error: confirm field is empty";
}
if(($u==1) && ($p==1) && ($c==1) && ($e==0))
{
echo "Error: email field is empty";
}
if(($u==1) && ($p==1) && ($c==1) && ($e==1))
{
echo "Connect stuff goes here";
}
}
מישהו יכול להגיד לי אם הדרך הזו טובה?
או שיש משהו פשוט יותר...
תודה רבה
