Page 1 of 1

my check function is not working!

Posted: Sun Sep 21, 2008 11:08 am
by cap2cap10
:banghead: greetings php technorati, my check script is not working. no error, it just does absolutely nothing, as if it does not exist on the page. Here is the script:

Code: Select all

<?php
$userID = $_SESSIONS['js_login']['userID'];
$prof_stat = $_SESSIONS['js_profile']['prof_stat'];
$res_stat = $_SESSIONS['js_resume']['res_stat'];
$pic_stat = $_SESSIONS['js_resume']['pic_stat'];
$file_stat = $_SESSIONS['js_resume']['file_stat'];
 
if ($prof_stat == " ")
{
if ($res_stat == " ")
{
if ($pic_stat == " ")
{
if ($file_stat == " ")
{
echo "<a href=upload_profile.php><img src=images/credit-cards-logo.gif width=182 height=83 alt=Please upload your Profile! border=1></a>";
}
elseif ($prof_stat == "yes")
{
if ($res_stat == " ")
{
if ($pic_stat == " ")
{
if ($file_stat == " ")
{
echo "<a href=upload_resume_1.php><img src=images/credit-cards-logo.gif width=182 height=83 alt=Please upload your Resume! border=1></a>";
}
elseif ($prof_stat == "yes")
{
if ($res_stat == "yes")
{
if ($pic_stat == " ")
{
if ($file_stat == " ")
{
echo "<a href=upload_pic.php><img src=images/credit-cards-logo.gif width=182 height=83 alt=Please upload your Photo! border=1></a>";
}
elseif ($prof_stat == "yes")
{
if ($res_stat == "yes")
{
if ($pic_stat == "yes")
{
if ($file_stat == " ")
{
echo "<a href=upload_file.php><img src=images/credit-cards-logo.gif width=182 height=83 alt=Please upload your Files! border=1></a>";
}
elseif ($prof_stat == "yes")
{
if ($res_stat == "yes")
{
if ($pic_stat == "yes")
{
if ($file_stat == "yes")
{
echo "<img src=images/credit-cards-logo.gif width=182 height=83 alt=Please activate your Portfolio! border=1>";
}
}
}
}}}}}}}}}}}}}
 
?>
Ok what did I do wrong this time. It is probably something simple.
thanks in advance,

Batoe

Re: my check function is not working!

Posted: Sun Sep 21, 2008 4:08 pm
by yacahuma
Before even trying to understand what you are trying to do. Have you heard of "and" operator (&&).
if ($a==1 && $b==1 && $c==1)

Re: my check function is not working!

Posted: Sun Sep 21, 2008 9:33 pm
by cap2cap10
thanks; what I am trying to do is to check MySQL fields for a value (Yes or no data) using sessions and then to post a graphic depending on the values present in the MySQL fields. I was testing to see if the script will perform this task.

I added in the && and this is the new code:

Code: Select all

<?php
$userID = $_SESSIONS['js_login']['userID'];
$prof_stat = $_SESSIONS['js_profile']['prof_stat'];
$res_stat = $_SESSIONS['js_resume']['res_stat'];
$pic_stat = $_SESSIONS['js_resume']['pic_stat'];
$file_stat = $_SESSIONS['js_resume']['file_stat'];
 
if ($prof_stat == " " && $res_stat == " " && $pic_stat == " " && $file_stat == " ")
{
echo "<a href=upload_profile.php><img src=images/credit-cards-logo.gif width=182 height=83 alt=Please upload your Profile! border=1></a>";
}
elseif ($prof_stat == "yes" && $res_stat == " " && $pic_stat == " " && $file_stat == " ")
{
echo "<a href=upload_resume_1.php><img src=images/credit-cards-logo.gif width=182 height=83 alt=Please upload your Resume! border=1></a>";
}
elseif ($prof_stat == "yes" && $res_stat == "yes" && $pic_stat == " " && $file_stat == " ")
{
echo "<a href=upload_pic.php><img src=images/credit-cards-logo.gif width=182 height=83 alt=Please upload your Photo! border=1></a>";
}
elseif ($prof_stat == "yes" && $res_stat == "yes" && $pic_stat == "yes" && $file_stat == " ")
{
echo "<a href=upload_file.php><img src=images/credit-cards-logo.gif width=182 height=83 alt=Please upload your Files! border=1></a>";
}
elseif ($prof_stat == "yes" && $res_stat == "yes" && $pic_stat == "yes" && $file_stat == "yes")
{
echo "<img src=images/credit-cards-logo.gif width=182 height=83 alt=Please activate your Portfolio! border=1>";
}
 
?>
I still can't get it to post one image. Anyone know what I am doing wrong?

Batoe

Re: my check function is not working!

Posted: Mon Sep 22, 2008 9:11 am
by yacahuma
you say " mysql fields", are you getting data from mysql and put it it in sessions?
Is your data going to have blanks ? " "

When I check for empty I use strlen(trim($var))

Also, print your data, to see what you have

Code: Select all

 
echo "USER=[{$userID}]";
 

Re: my check function is not working!

Posted: Mon Sep 22, 2008 12:22 pm
by cap2cap10
How do I check for empty fields in Mysql using the userID(primary key)? Meaning If there is no userID in a table and there is one in another table, this will mean that the user has not submitted data to that table yet. If that is the case then I want to echo a link to a form for the user to upload data. This is the essence of what I am trying to accomplish.

Batoe

Re: my check function is not working!

Posted: Mon Sep 22, 2008 1:49 pm
by yacahuma
if you do a select by user id on a table, you are supposed to check if you actually go something back. At that point you know that the user does not exists. You DO NOT check for empty fields in this case.