Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

add in php code to functions.php page

Posted on 2011-09-06
11
378 Views
Last Modified: 2012-05-12
Hi there.  I need to add the following code to the script below (where that TD is located).

if ( is_user_logged_in() ) {
    <TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right2.png\' border=\'0\' width=\'340\' height=\'40\'></a></TD>
} else {
    <TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right.png\' border=\'0\' width=\'340\' height=\'40\'></a></TD>
}

Any ideas experts?
functions.php file...

<?php
//customize header
remove_action('genesis_header', 'genesis_do_header');
add_action('genesis_header', 'child_do_header');
function child_do_header() { 
echo '<style type=\'text/css\'>
.headertext_b {
color: #FFFFFF;
font-weight: bold;
font-style: italic;
font-size: 16px;
font-family: Arial, Tahoma, Verdana;
text-shadow: #002838 1px 1px;
}
table.header_bkg {
border-spacing:0;
padding: 0;
color: #FFFFFF;
}
.inputtext {
width: 128px;
height: 18px;
text-align: left;
margin: 0;
border: 0px;
background:#fff;
}
.formsubmit {
width: 46px;
height: 20px;
cursor:pointer;
margin: 0;
border: 0;
}
td.bkg {
background: url(\'/images/logo/bottom-right.png\') no-repeat left top;
border-spacing:0;
padding: 0;
color: #FFFFFF;
height: 110px;
width: 340px;
}
</style>
</head>
<body>
<TABLE border=\'0\' cellpadding=\'0\' cellspacing=\'0\' align=\'center\'>
<tbody>
<form name=\'loginform\' id=\'loginform\' action=\'wp-login.php\' method=\'post\'>
<input type=\'hidden\' name=\'testcookie\' value=\'1\' />
<TR>
<TD rowspan=2><a href=\'/\' title=\'Members Mix\'><img src=\'/images/logo/left.png\' border=\'0\' width=\'620\' height=\'150\'></a></TD>
<TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right.png\' border=\'0\' width=\'340\' height=\'40\'></a></TD>
</TR>
<TR>
<TD class=\'bkg\'>
	<TABLE border=\'0\' cellpadding=\'0\' cellspacing=\'0\' align=\'left\'>
	<tbody>
	<TR>
	<TD><div style=\'padding-top:42px;\'><input type=\'text\' name=\'log\' id=\'user_login\' class=\'inputtext\' value=\'\' tabindex=\'1\' /></div></TD>
	<TD><img src=\'/images/spacer.gif\' border=\'0\' width=\'15\'></TD>
	<TD><div style=\'padding-top:65px;padding-bottom:10px;\'><input type=\'password\' name=\'pwd\' id=\'user_pass\' class=\'inputtext\' value=\'\' tabindex=\'2\' /></div><a href=\'wp-login.php?action=lostpassword\' title=\'forgot your password? click here\'><img src=\'/images/spacer.gif\' border=\'0\' width=\'130\' height=\'16\'></a></TD>
	<TD><div style=\'padding-top:42px;\'><input type=\'submit\' value=\'Log In\' name=\'wp-submit\' tabindex=\'3\' id=\'1\' /></div></TD>
	</TR>
	<tbody>
	</TABLE>
</TD>
</tr>
</form>
</TABLE>';
}
%>

Open in new window

0
Comment
Question by:COwebmaster
11 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 36490507
Not sure what your question is...
0
 

Accepted Solution

by:
COwebmaster earned 0 total points
ID: 36490562
If I add in that code into the script, but the graphics don't look right so I must be doing something wrong. I have it like this:
//customize header
remove_action('genesis_header', 'genesis_do_header');
add_action('genesis_header', 'child_do_header');
function child_do_header() { 
echo '<style type=\'text/css\'>
.headertext_b {
color: #FFFFFF;
font-weight: bold;
font-style: italic;
font-size: 16px;
font-family: Arial, Tahoma, Verdana;
text-shadow: #002838 1px 1px;
}
table.header_bkg {
border-spacing:0;
padding: 0;
color: #FFFFFF;
}
.inputtext {
width: 128px;
height: 18px;
text-align: left;
margin: 0;
border: 0px;
background:#fff;
}
.formsubmit {
width: 46px;
height: 20px;
cursor:pointer;
margin: 0;
border: 0;
}
td.bkg {
background: url(\'/images/logo/bottom-right.png\') no-repeat left top;
border-spacing:0;
padding: 0;
color: #FFFFFF;
height: 110px;
width: 340px;
}
</style>
</head>
<body>
<TABLE border=\'0\' cellpadding=\'0\' cellspacing=\'0\' align=\'center\'>
<tbody>
<form name=\'loginform\' id=\'loginform\' action=\'wp-login.php\' method=\'post\'>
<input type=\'hidden\' name=\'testcookie\' value=\'1\' />
<TR>
<TD rowspan=2><a href=\'/\' title=\'Members Mix\'><img src=\'/images/logo/left.png\' border=\'0\' width=\'620\' height=\'150\'></a></TD>
if ( is_user_logged_in() ) {
    <TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right2.png\' border=\'0\' width=\'340\' height=\'40\'></a></TD>
} else {
    <TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right.png\' border=\'0\' width=\'340\' height=\'40\'></a></TD>
}
</TR>
<TR>
<TD class=\'bkg\'>
	<TABLE border=\'0\' cellpadding=\'0\' cellspacing=\'0\' align=\'left\'>
	<tbody>
	<TR>
	<TD><div style=\'padding-top:42px;\'><input type=\'text\' name=\'log\' id=\'user_login\' class=\'inputtext\' value=\'\' tabindex=\'1\' /></div></TD>
	<TD><img src=\'/images/spacer.gif\' border=\'0\' width=\'15\'></TD>
	<TD><div style=\'padding-top:65px;padding-bottom:10px;\'><input type=\'password\' name=\'pwd\' id=\'user_pass\' class=\'inputtext\' value=\'\' tabindex=\'2\' /></div><a href=\'wp-login.php?action=lostpassword\' title=\'forgot your password? click here\'><img src=\'/images/spacer.gif\' border=\'0\' width=\'130\' height=\'16\'></a></TD>
	<TD><div style=\'padding-top:42px;\'><input type=\'submit\' value=\'Log In\' name=\'wp-submit\' tabindex=\'3\' id=\'1\' /></div></TD>
	</TR>
	<tbody>
	</TABLE>
</TD>
</tr>
</form>
</TABLE>';
}

Open in new window

0
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 36490675
There were no php tags
//customize header
remove_action('genesis_header', 'genesis_do_header');
add_action('genesis_header', 'child_do_header');
function child_do_header() { 
echo '<style type=\'text/css\'>
.headertext_b {
color: #FFFFFF;
font-weight: bold;
font-style: italic;
font-size: 16px;
font-family: Arial, Tahoma, Verdana;
text-shadow: #002838 1px 1px;
}
table.header_bkg {
border-spacing:0;
padding: 0;
color: #FFFFFF;
}
.inputtext {
width: 128px;
height: 18px;
text-align: left;
margin: 0;
border: 0px;
background:#fff;
}
.formsubmit {
width: 46px;
height: 20px;
cursor:pointer;
margin: 0;
border: 0;
}
td.bkg {
background: url(\'/images/logo/bottom-right.png\') no-repeat left top;
border-spacing:0;
padding: 0;
color: #FFFFFF;
height: 110px;
width: 340px;
}
</style>
</head>
<body>
<TABLE border=\'0\' cellpadding=\'0\' cellspacing=\'0\' align=\'center\'>
<tbody>
<form name=\'loginform\' id=\'loginform\' action=\'wp-login.php\' method=\'post\'>
<input type=\'hidden\' name=\'testcookie\' value=\'1\' />
<TR>
<TD rowspan=2><a href=\'/\' title=\'Members Mix\'><img src=\'/images/logo/left.png\' border=\'0\' width=\'620\' height=\'150\'></a></TD>
<?php
if ( is_user_logged_in() ) {
?>
    <TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right2.png\' border=\'0\' width=\'340\' height=\'40\'></a></TD>
<?php
} else {
?>
    <TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right.png\' border=\'0\' width=\'340\' height=\'40\'></a></TD>
<?php
}
?>
</TR>
<TR>
<TD class=\'bkg\'>
	<TABLE border=\'0\' cellpadding=\'0\' cellspacing=\'0\' align=\'left\'>
	<tbody>
	<TR>
	<TD><div style=\'padding-top:42px;\'><input type=\'text\' name=\'log\' id=\'user_login\' class=\'inputtext\' value=\'\' tabindex=\'1\' /></div></TD>
	<TD><img src=\'/images/spacer.gif\' border=\'0\' width=\'15\'></TD>
	<TD><div style=\'padding-top:65px;padding-bottom:10px;\'><input type=\'password\' name=\'pwd\' id=\'user_pass\' class=\'inputtext\' value=\'\' tabindex=\'2\' /></div><a href=\'wp-login.php?action=lostpassword\' title=\'forgot your password? click here\'><img src=\'/images/spacer.gif\' border=\'0\' width=\'130\' height=\'16\'></a></TD>
	<TD><div style=\'padding-top:42px;\'><input type=\'submit\' value=\'Log In\' name=\'wp-submit\' tabindex=\'3\' id=\'1\' /></div></TD>
	</TR>
	<tbody>
	</TABLE>
</TD>
</tr>
</form>
</TABLE>';
}

Open in new window

0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:COwebmaster
ID: 36490743
okay, I tried that but it appears that both images get displayed
0
 
LVL 23

Expert Comment

by:jeremyjared74
ID: 36490782
If you're interested in learning how to use styles inside of your php, there is a very good theme that is meant to show people that want to learn to develop themes. The theme is named Oenology by Chip Bennett. It is very well documented and should give you a much better understanding or how it all works. Here is a link to his tutorial:
http://make.wordpress.org/themes/2011/01/05/themes-and-the-wp-settings-api/

If you just want to use it once and don't need to learn, just use some code provided by the experts here.
0
 
LVL 23

Expert Comment

by:jeremyjared74
ID: 36490830
0
 

Author Comment

by:COwebmaster
ID: 36491049
thanks jeremyjared74.  Unfortunately, I'm not familiar enough yet with php but still learning :)

So, any tips on why the following script adds both images into the table?

<?php
if ( is_user_logged_in() ) {
?>
    <TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right2.png\' border=\'0\' width=\'340\' height=\'40\'></a></TD>
<?php
} else {
?>
    <TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right.png\' border=\'0\' width=\'340\' height=\'40\'></a></TD>
<?php
}
?>
0
 

Author Comment

by:COwebmaster
ID: 36491386
nevermind, I figured it out on my own.
//customize header
remove_action('genesis_header', 'genesis_do_header');
add_action('genesis_header', 'child_do_header');
function child_do_header() { 
    
if ( is_user_logged_in() ) {
    echo '<style type=\'text/css\'>
.headertext_b {
color: #FFFFFF;
font-weight: bold;
font-style: italic;
font-size: 16px;
font-family: Arial, Tahoma, Verdana;
text-shadow: #002838 1px 1px;
}
table.header_bkg {
border-spacing:0;
padding: 0;
color: #FFFFFF;
}
.inputtext {
width: 128px;
height: 18px;
text-align: left;
margin: 0;
border: 0px;
background:#fff;
}
.formsubmit {
width: 46px;
height: 20px;
cursor:pointer;
margin: 0;
border: 0;
}
td.bkg {
background: url(\'/images/logo/bottom-right.png\') no-repeat left top;
border-spacing:0;
padding: 0;
color: #FFFFFF;
height: 110px;
width: 340px;
}
</style>
</head>
<body>
<TABLE border=\'0\' cellpadding=\'0\' cellspacing=\'0\' align=\'center\'>
<tbody>
<form name=\'loginform\' id=\'loginform\' action=\'wp-login.php\' method=\'post\'>
<input type=\'hidden\' name=\'testcookie\' value=\'1\' />
<TR>
<TD rowspan=2><a href=\'/\' title=\'Members Mix\'><img src=\'/images/logo/left.png\' border=\'0\' width=\'620\' height=\'150\'></a></TD>
<TD><a href=\'/join\' title=\'Logout\'><img src=\'/images/logo/top-right2.png\' border=\'0\' width=\'340\' height=\'40\'></a></TD>
</TR>
<TR>
<TD class=\'bkg\'>
	<TABLE border=\'0\' cellpadding=\'0\' cellspacing=\'0\' align=\'left\'>
	<tbody>
	<TR>
	<TD><div style=\'padding-top:42px;\'><input type=\'text\' name=\'log\' id=\'user_login\' class=\'inputtext\' value=\'\' tabindex=\'1\' /></div></TD>
	<TD><img src=\'/images/spacer.gif\' border=\'0\' width=\'15\'></TD>
	<TD><div style=\'padding-top:65px;padding-bottom:10px;\'><input type=\'password\' name=\'pwd\' id=\'user_pass\' class=\'inputtext\' value=\'\' tabindex=\'2\' /></div><a href=\'wp-login.php?action=lostpassword\' title=\'forgot your password? click here\'><img src=\'/images/spacer.gif\' border=\'0\' width=\'130\' height=\'16\'></a></TD>
	<TD><div style=\'padding-top:42px;\'><input type=\'submit\' value=\'Log In\' name=\'wp-submit\' tabindex=\'3\' id=\'1\' /></div></TD>
	</TR>
	<tbody>
	</TABLE>
</TD>
</tr>
</form>
</TABLE>';
} else {
    echo '<style type=\'text/css\'>
.headertext_b {
color: #FFFFFF;
font-weight: bold;
font-style: italic;
font-size: 16px;
font-family: Arial, Tahoma, Verdana;
text-shadow: #002838 1px 1px;
}
table.header_bkg {
border-spacing:0;
padding: 0;
color: #FFFFFF;
}
.inputtext {
width: 128px;
height: 18px;
text-align: left;
margin: 0;
border: 0px;
background:#fff;
}
.formsubmit {
width: 46px;
height: 20px;
cursor:pointer;
margin: 0;
border: 0;
}
td.bkg {
background: url(\'/images/logo/bottom-right.png\') no-repeat left top;
border-spacing:0;
padding: 0;
color: #FFFFFF;
height: 110px;
width: 340px;
}
</style>
</head>
<body>
<TABLE border=\'0\' cellpadding=\'0\' cellspacing=\'0\' align=\'center\'>
<tbody>
<form name=\'loginform\' id=\'loginform\' action=\'wp-login.php\' method=\'post\'>
<input type=\'hidden\' name=\'testcookie\' value=\'1\' />
<TR>
<TD rowspan=2><a href=\'/\' title=\'Members Mix\'><img src=\'/images/logo/left.png\' border=\'0\' width=\'620\' height=\'150\'></a></TD>
<TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right.png\' border=\'0\' width=\'340\' height=\'40\'></a></TD>
</TR>
<TR>
<TD class=\'bkg\'>
	<TABLE border=\'0\' cellpadding=\'0\' cellspacing=\'0\' align=\'left\'>
	<tbody>
	<TR>
	<TD><div style=\'padding-top:42px;\'><input type=\'text\' name=\'log\' id=\'user_login\' class=\'inputtext\' value=\'\' tabindex=\'1\' /></div></TD>
	<TD><img src=\'/images/spacer.gif\' border=\'0\' width=\'15\'></TD>
	<TD><div style=\'padding-top:65px;padding-bottom:10px;\'><input type=\'password\' name=\'pwd\' id=\'user_pass\' class=\'inputtext\' value=\'\' tabindex=\'2\' /></div><a href=\'wp-login.php?action=lostpassword\' title=\'forgot your password? click here\'><img src=\'/images/spacer.gif\' border=\'0\' width=\'130\' height=\'16\'></a></TD>
	<TD><div style=\'padding-top:42px;\'><input type=\'submit\' value=\'Log In\' name=\'wp-submit\' tabindex=\'3\' id=\'1\' /></div></TD>
	</TR>
	<tbody>
	</TABLE>
</TD>
</tr>
</form>
</TABLE>';
}
}

Open in new window

0
 

Author Closing Comment

by:COwebmaster
ID: 36518412
mine version worked
0
 
LVL 23

Expert Comment

by:jeremyjared74
ID: 36491885
I guess I didn't make it in time.

Here is a little bit of advice for you if your using php with WordPress, or any php site. It's best to use dynamic links when possible. For instance, with WordPress you can call for your images and link to text like this:
<a href="<?php echo get_permalink(1); ?>">join<img src="<?php bloginfo('template_url'); ?>/images/logo.jpg"/></a>

Open in new window

0
 

Author Comment

by:COwebmaster
ID: 36491903
Okay, thank you.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP Echo with auto submit 8 28
selector:validator cookies 4 29
Accessing specific element - DOM PHP HTML 8 34
Inserting data into database 10 34
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question