my check function is not working!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
cap2cap10
Forum Contributor
Posts: 158
Joined: Mon Apr 14, 2008 11:06 pm

my check function is not working!

Post 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
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: my check function is not working!

Post 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)
User avatar
cap2cap10
Forum Contributor
Posts: 158
Joined: Mon Apr 14, 2008 11:06 pm

Re: my check function is not working!

Post 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
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: my check function is not working!

Post 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}]";
 
User avatar
cap2cap10
Forum Contributor
Posts: 158
Joined: Mon Apr 14, 2008 11:06 pm

Re: my check function is not working!

Post 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
User avatar
yacahuma
Forum Regular
Posts: 870
Joined: Sun Jul 01, 2007 7:11 am

Re: my check function is not working!

Post 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.
Post Reply