repeating a form that is in a function.

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
deejay
Forum Contributor
Posts: 201
Joined: Wed Jan 22, 2003 3:33 am
Location: Cornwall

repeating a form that is in a function.

Post by deejay »

hi

i have a form placed inide a function (i have got this form from a book). when displaying the function in the body of the page I have to use this code

<?php


cctvSignUp()


?>
<?php


}

?>

without the extra <?php } ?> it wont work. now my problem is calling up that function again in a echo statement like this.

die ('<tr>
<td align="left"><b><font class="errorMessage">'.$cctvSignUp.'</font></b></td>
</tr><BR>

');

but need to some how include
<?php


}

?>

but dont know how. any ideas ?

Thanks for anyhelp you may be able to give.
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

First off, the reason this doesn't work without the closing ?> is becuase there is no semi colon! Try it like this:

Code: Select all

<?php
cctvSignUp();
}
?>
This is something that a lot of people with more of a design bent do. Take a look at the default index page for the b2 blog ware as an example. Eventhough the php engine let's you get away with it, it's very bad practise and just leads to confusion.

As for the other issue, $cctvSignUp is not a function. It's a variable. Try replacing it with...

Code: Select all

<? cctvSignUp(); ?>
Cheers,
BDKR
User avatar
deejay
Forum Contributor
Posts: 201
Joined: Wed Jan 22, 2003 3:33 am
Location: Cornwall

_

Post by deejay »

thanks, i ahve located where the missing } is in the include so that solves that.

as for the function as a variable, i thought i read in the manual that i could get away with doing it that. what i am trying to is insert the function in a die tag. like this

die ('
<tr>
<td align=\"left\"><b><font class=\"errorMessage\">Error: Your passwords have not matched. Please enter them again.</font></b></td>
</tr> <BR>

'. THIS IS WHERE i WANT THE FUNCTION TO GO.'');



i have tried putting .cctvSignUp. or .cctvSignUp(). and .cctvSignUp();. . any ideas. :oops: i'm sure it'll be simple but cant find solution in the manual

Thanks

Deej
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

This should work.

Code: Select all

die ('
<tr>
<td align="left"><b><font class="errorMessage">Error:  Your passwords have not matched. Please enter them again.</font></b></td>
</tr>  <BR>'. cctvSignUp());
You shouldn't need a '.' after the function call. Same goes for the semi-colon.

Cheers,
BDKR
User avatar
deejay
Forum Contributor
Posts: 201
Joined: Wed Jan 22, 2003 3:33 am
Location: Cornwall

_

Post by deejay »

thanks cant beleive i didn't try that. now the though the function displays at the top of page. So I have put the function in a table to see if that would help.

die ('
<link rel="stylesheet" href="../phpBB/templates/subSilver/subSilver.css" type="text/css">
<tr>
<td align="left"><b><font class="errorMessage">Error: Your passwords have not matched. Please enter them again.</font></b></td>
</tr> <tr>
<td align="left">'.cctvSignUp().'</td>
</tr>');

but still displays at the top. will consult the documentation for some idea why?

Thanks
Post Reply