Jump to content

trouble using php and java inside the function


ricky spires

Recommended Posts

hello.

 

i have two functions that are not working because i cant seem to input the php and java correctly.. could someone help please.

 

how do i put these lines into a function:

 

1 -

 

function applyBox() {

echo '
<div id="apply">
<h3><b><span class="arial18_GRN">Apply NOW</span> to become a<br>BusinessMobiles.com Affiliate</b></h3>
<p class="applyText">Drive quality traffic to one of our<br>partners and get paid for it.</p>
<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Apply','','image/callsToAction/applyButton2.jpg',1)">
<img src="image/callsToAction/applyButton1.jpg" class="applyButton" alt="Apply" name="Apply" width="137" height="36" border="0"></a>
</div> 
';
}

 

this part is not working: onMouseOver="MM_swapImage('Apply','','image/callsToAction/applyButton2.jpg',1)">

 

i can see that the ' is breaking it. i tried putting .'s but it didn't work : onMouseOver="MM_swapImage('.Apply.','..','.image/callsToAction/applyButton2.jpg.',1)">

 

 

 

 

 

2 - this form:

 

   <div class="form">
                   <form name="Form" method="post" action="<?PHP echo $_SERVER['PHP_SELF']; ?>">
                    <input name="submit" type="hidden" value="submit" /></input>
                    <input type="text" class="inputField" name="Uname" id="Uname"  value="'.$Uname.'" onfocus="clearUname()"></input>
                    <input type="text" class="inputField" name="PW" id="PW" value="'.$PW.'" onfocus="clearPW()"></input>
                      <input type="image" class="submit" src="image/wrapper/submit.jpg"  value="Submit" alt="login" width="36" height="20" border="0" /></input>
		</form>

 

 

this part is not working : <form name="Form" method="post" action="<?PHP echo $_SERVER['PHP_SELF']; ?>">

 

i tried:

 

<form name="Form" method="post" action="'.echo $_SERVER['PHP_SELF'].'">

 

but no luck.

 

 

any suggestions ????

 

thanks

ricky

Link to comment
Share on other sites

For the first problem you need to escape the single quotes in the HTML string using \

Here is an example:

 <?php
echo '<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage(\'Apply\',\'\',\'image/callsToAction/applyButton2.jpg\',1)">';

 

As for your second issue.. im assuming that the code block is in an echo or print statement in which case your second attempt was close, you just dont need the echo in there.

echo '<div class="form">
                   <form name="Form" method="post" action="'.$_SERVER['PHP_SELF'].'">
                    <input name="submit" type="hidden" value="submit" /></input>
                    <input type="text" class="inputField" name="Uname" id="Uname"  value="'.$Uname.'" onfocus="clearUname()"></input>
                    <input type="text" class="inputField" name="PW" id="PW" value="'.$PW.'" onfocus="clearPW()"></input>
                      <input type="image" class="submit" src="image/wrapper/submit.jpg"  value="Submit" alt="login" width="36" height="20" border="0" /></input>
         </form>';

Also, it has just been bought to my attention that using PHP_SELF isnt a good idea, you should instead leave it blank

action=""

Link to comment
Share on other sites

Should note that this is a terrible way of constructing a form. You should also not echo out the html from within the function. Instead, store the html in a variable and return the variable.

 

Personally, I would weave into php from html to echo the username and password. Instead of..

 

<input type="text" class="inputField" name="Uname" id="Uname"  value="'.$Uname.'" onfocus="clearUname()"></input>

 

I would use:

 

<input type="text" class="inputField" name="Uname" id="Uname"  value="<?php echo $Uname;?>" onfocus="clearUname()"></input>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.