Hello Guys,
Can someone please help me to convert this procedural php script in the C.I method?
I would be immensely grateful
I'm trying, but i'm doing something wrong.
Thank you in advance.
This is the procedural script PHP:
Code:
<?php
if ($_POST["sorte"] == "N")
{
$zahlung = $_POST["liter"] * 1.35;
$text = "Normal";
}
else
{
$zahlung = $_POST["liter"] * 1.40;
$text = "Super";
}
echo $_POST["liter"] . " Liter $text kosten $zahlung €";
?>
This is the html Form:
Code:
<form action = "u_ifelse1.php" method = "post">
<p><input name = "liter"> Menge in Liter</p>
<p><input name = "sorte"> Sorte (S oder N)</p>
<p><input type = "submit">
<input type = "reset"></p>
</form>
Now there comes my try - 1° CI_Controller:
Code:
class U_ifelse1 extends CI_Controller{
function __construct()
{
parent::__construct();
// Your own constructor code
}
public function index($page = 'home_23')
$Form_data['form_fields'] = $this->input->post();
$payment = "";
$text = "";
if ($Form_data['form_fields'] == "N")
{
$payment = $Form_data['liter'] * 1.35;
$text = "Normal";
$this->load->view('pages/'.$page, $Form_data);
}
else
{
$payment = $Form_data['form_fields'] * 1.40;
$text = "Super";
$this->load->view('pages/home_24', $Form_data);
}
}
}
2° The form - home_23.php
Code:
<body>
<!-- class U_ifelse1 extends CI_Controller -->
<h3><p>Please enter quantity and type - sorte</p></h3>
<?php echo form_open('u_ifelse1/index'); ?>
<p><input name = "liter"> Menge in Liter</p>
<p><input name = "sorte"> Sorte (S oder N)</p>
<p><input type="submit" name="senden">
<input type="reset"></p>
<?php echo $form_fields["liter"] . " Liter $text kosten $payment €"; ?>
:: Ergebnis des Tankvorgangs
<!-- https://stackoverflow.com/questions/7020873/show-hide-div-if-if-statement-is-true -->
<?php echo form_close(); ?>
</body>
3° - Third file home_24.php
Code:
<body>
<!-- class U_ifelse1 extends CI_Controller -->
<?php echo $form_fields["liter"] . " Liter $text cost $payment €"; ?>
</body>