Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Making a php script work in txp
I’m porting a static site into textpattern and it has an simple php calulation script.
I made a form to output the script and placed it in an article, but when the php form is submitted, no results are shown.
This is the form, how do I get this to work?:
<!-- Form 1 -->
<form action="<txp:php>echo $_SERVER["PHP_SELF"]; </txp:php>" method="post" name="calc1">
<table width="540" border="0" cellspacing="0" cellpadding="5">
<tr>
<td width="110"><input name="number1" type="text" id="number1" class="input" /> m</td>
<td width="110"><input name="number2" type="text" id="number2" class="input" />
Inches</td>
<td width="80"><input type="submit" name="Submit" value="Calculate" class="submit" /></td>
<td align="center" class="red">
<txp:php>
$calc1 = (3 * 2 * .5 * $number2 * $number2 * $number1) / 4;
echo number_format($calc1, 3);
</txp:php>
litres
</td>
</tr>
</table>
</form>
Offline
Re: Making a php script work in txp
Did this actually work in the first place? You should be using $_POST[‘variableName’].
Try this (removed cruft for clarity):
<form action="." method="post">
<label>Something
<input name="number1" type="text"/>
</label>
<label>Something else
<input name="number2" type="text"/>
</label>
<input name="submit" type="submit"/>
<txp:php>
if (isset($_POST['submit'])) {
$calc1 = (3 * 2 * .5 * pow($_POST['number2'], 2) * $_POST['number1'])/4;
echo number_format($calc1, 3). 'litres';
}
</txp:php>
</form>
Last edited by jm (2008-02-10 10:19:50)
Offline
Re: Making a php script work in txp
Ha Ha – it did actually work originally – but you have found me out – I am a php Dummy :) (but I’m trying)
I’ll research the new php code you have input (I find its the only way to learn) – but what does
<form action="." do?
Offline
Re: Making a php script work in txp
Ah – no worries – the “.” is the index, then I can add a section like “./name” like that – cool, Thanks mate
Offline
Pages: 1