Hi there,
Been away from coding for a while, but have decided to take it back up again, but also take the opportunity to jump to the OOP side of the river. However, I'm in the water already.
I'm using the following very simple class:
<?php
class LED_kit_generator {
public $ledstrip;
function __construct($led_strips) {
$this->ledstrip = $led_strips;
}
public function set_led_strip($new_strip) {
$this->ledstrip = $new_strip;
}
public function get_led_strip() {
return $this->ledstrip;
}
}
?>
On data picked up in a separate input file, like so:
<?php
if ($_POST['led_params'] === 'Process') {
$clean_led_strip = strip_tags(trim($_POST['led_strip']));
//
// Invoke an instance of the LED_kit_generator class.
//
$led_kit = new LED_kit_generator();
//
// Pull the result from the get methods of the class
//
echo $led_kit->get_led_strip();
//
// The pick-up form
//
}
echo sprintf("<div class='applicationarea'>
<div class='centertext'><h2 class='hlook1'>LED custom kit generator</h2></div><br />");
$token = md5(uniqid(rand(), TRUE));
$_SESSION['token'] = $token;
echo sprintf("<form class='form' action={$safeself} method='post'>
<fieldset>
<legend>LED CUSTOM KIT BUILDER</legend>
<select name='led_type'>
<option>Steam proof</option>
<option>Dry room</option>
</select><br />
<label>Meters of LED strip: </label><input class='inputfield_colors' type='text' maxlength='3' name='led_strip' size='3' />
<label>Number of LED sections: </label><input class='inputfield_colors' type='text' maxlength='3' name='led_sections' size='3' />
<input type='hidden' name='formtoken' value='%s'>
<span><input name='led_params' type='submit' value='Process' /></span>
</fieldset>
</form>", $token);
//
?>
-and I simply cannot get echo $led_kit->get_led_strip(); to produce the integer.
I get the following message, when I hit the form button.
Warning: Missing argument 1 for LED_kit_generator::__construct(), called in /home/jacques/public_html/consultant.php on line 48 and defined in /home/jacques/public_html/classes/LED_kit_generator_test.php on line 6 Notice: Undefined variable: led_strips in /home/jacques/public_html/classes/LED_kit_generator_test.php on line 7
I have strict error reporting on as you can propably tell.
Where does the chain break? Hope you can help get up and running in the OOP world.
Thx.