Hidy Ho Neighbors,
I'm forcing myself to learn oop/classes for php5. It seems like a good idea for repetitious coding such as with forms. I've been through the oop tutorials here and elswhere in books.-if i see another Pet example..uhhg lol - and they do make sense but when trying to implement my own stuff it all falls apart.
My pathetic, broken example below attempts at creating form text inputs and checking the inputs when submitted. And if submitted the "value=" attribute of the form is updated with the posted value thereby making the form "sticky".
With procedural methods I have no problems creating vars dynamically from loops, checking and manipulating forms etc...but this object/class stuff has me stumped.
Code: [Select]<?php
ini_set ("display_errors", "1");
error_reporting(E_ALL);
class Form {
private $inp;
private $flag;
private $count;
private $maxChar;
public function Check_form(){
if (isset($_POST['form'])){
$d = array_pop($_POST);//remove "submit" value from $_POST array
foreach($_POST as $key=>$value){
static $i=1;
$inp = 'inp'.$i;
$this->$inp = $value;
$i++;
}
$this->count = count($_POST);
return true;
}else{
return false;
}
}
function text_input($text='enter',$maxChar = '10') {
if($this->Check_form()){ //make forms sticky (replace input values if filled out)
echo 'form is set<br />';//test
for($i=1; $i<=$this->count; $i++) {
$text = $inp . $i;
}
}
$this->maxChar = 'maxlength = ' .'"'.$maxChar.'"';
$maxChar = $this->maxChar;
static $i=1;
echo "<p><input type="text" name="text_$i" value="$text" $maxChar /></p>";
$i++;
}
}// End of Form class.
echo '<form action="oopForm2.php" method="post" enctype="multipart/form-data" name="theForm">';
$myForm = new Form();
$input_box1 = $myForm->text_input('enter text',20);
$input_box2 = $myForm->text_input('enter more',20);
echo '<input type="submit" name="form" value="submit" />';
echo '</form>';
unset($myForm);
?>
It's terrible I know, some advice would be greatly appretiated..sample code? even better. Thanks
distinct rows
Hi
Convert .fdf to .pdf
I currently have a web form that uploads the form data to an .fdf file and emails it.However, I just realized that most people I email it to cannot open an .fdf and it needs to be in pdf.Is there any
send message to the java application
Oracle 10g with Windows platform.
Standard DES encryption script?
Can anybody point me to a tutorial or a short script that shows how to encrypt some text with salt into standard DES?I know about the crypt()-function, but I'm currently writing a PHP script that
How to add functionality to a simple php calender?
Hello everyone, I have just finished creating a simple php calander. Can someone point me into the right direction as to what I need to do to begin to give the calender functionality?For exampleI
PHP Include not working
The website is http://www.grlistingservices.comThe code block is as follows:<?phpif (!isset($id)){include 'home.php';}else{include "$id.php";}?>All files are in the same
ECC6 - Single sign-on
We are in the process of upgrading to ECC 6 which will support single sign on with user passwords aligned by our active directory to the same as those used to access the Network. My query is that we
RFQ Configuration - can you make PLANT field an optional field in ME42
Is there a way to make the plant field on an RFQ optional in change mode (ME42)?
a function to check directory depth
I'm working on a php script to upload files in to a set directory.the user can select to upload into the "upload" directory or any of its subdirectories.at the moment the user is able to
this code is strange !
Hi i got this code from the web.. It checks for live and dead socksIt is working perfectly on my localhost. but does not work in any webserver ! any ideas ?<?php$filename =