php-windows Digest 7 Dec 2002 14:00:06 -0000 Issue 1475

Topics (messages 17337 through 17342):

Generating forms using OOP
        17337 by: Davy Obdam

Re: [PHP] mail() problems...
        17338 by: Anthony Ritter
        17341 by: DL Neil
        17342 by: Anthony Ritter

upgrading OS
        17339 by: Trystano.aol.com

Re: [PHP] Generating forms using OOP
        17340 by: Tom Rogers

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message --- Hi People,

I ve just started with some OOP programming in PHP and now i have to build a set of classes that can generate a html form.. But i have a problem with the <select><option></option></select> thing....
I hope someone can help me here or give me some pointers,... any help is apreciated. Here is a part of my code :

class selectField extends formElement {
//Constructor
function selectField($name, $value) {
formElement::setName($name);
formElement::setValue($value);
}

function generateSelectField() {
$theOutput = "<select name=\"".$this->name."\">\n";
foreach($this->value as $key=>$val) {
$theOutput .= "<option value=\"".$this->value."\">".$this->value."</option>\n";
}
$theOutput .= "</select>\n";
Return $theOutput;
}
}

This is how i call the Object:

$test[] = "Test1";
$test[] = "Test2";
$test[] = "Test3";
$test[] = "Test4";
$test[] = "Test5";
$select = new selectField("testje", $test);
echo$select->generateSelectField();

But all i get is a select box with the word Array in it 5 times...Thanks for your time...

Best regards,

Davy Obdam
mailto:[EMAIL PROTECTED]


--- End Message ---
--- Begin Message ---
To all who assisted me today.

I finally managed to get the mail () funtion to work.

Thank you and happy holidays to you all...
TR



--- End Message ---
--- Begin Message ---
OK Anthony you've got it 'working' - woo hoo!
(BTW: to double-check settings, run phpinfo() again - they're in there
(somewhere))

We've exchanged a flurry of msgs, now for the 'lecture': slow down and read
carefully; work step-by-step, learn to walk from the simplest case first,
and thereafter stride out into a run...
</lecture>

So your system appears to have transmitted a msg, but nothing much has
happened/come back.
(a) if the msg has gone out, but is malformed in some way, it may take some
hours before 'the Internet' gets around to rejecting it and tossing it back
at you, eg four hours/three days. If it's going to, that should have
happened by now.
(b) with the code below there is no way to tell if you have an immediate
error or not - and in any case you have added a few 'extras' (contrary to
the 'keep it simple' philosophy I espoused above.

Recommendations:
(1) since Julie's book was published there has been an upgrade to mail()
(and numerous to PHP as a whole). Re-read that section of the book, and make
basic notes on the technique (of using mail()), then put the book aside. Go
to the online manual (should always be your first port of call anyway) and
read the updated entry - firstly there is likely an 'extra' parameter, and
secondly you can now get a response/result feedback AND TEST IT!
(2) After reading the manual entry, compose a simple script, with no data
entry/all constant values, and chuck the minimum number of arguments at
mail(), to try to get at least 'something' back. (and thereafter start
adding flowery labels, X-headers, etc - piece by piece) MAKE copious notes
as you go - so you can 'follow the breadcrumbs' to backtrack...
(3) Julie wrote her book and populated it with examples from some *NIX
system. I don't recall any words of advice for Windows users (you're Win98
IIRC), but please re-read any such. In this case you have run foul of the
*NIX 'newline' convention of \n (newline character, ASCII=10), whereas
Windows uses a different convention (\r\n, CRLF = carriage return and line
feed, ASCII 13 + ASCII 10) - and just for fun, let me mention that Macs are
'different' again... In other words, all of those \n characters (as per the
current script, below) are going to trip up mail() and cause it to fail/fail
to form the msg properly/cause you to miss out on the exquisite excitement
of reading email you've sent to yourself...

The wave is building under you, all you have to figure out now, is which way
to stand on the board!
=dn
(sorry, that's surfing not fishing, and salt water not fresh...)



> O.K. DL...
> Thanks for the reply.
>
> And your time.  :-{}
>
> Yes. I restarted Apache - it came up the same.
>
> It would seem that Apache works along with php4 since I get the
> enviromental variables, etc. page when
>
> I go to:
>
> http://localhost/phpinfo.php
>
> which was saved as:
>
> <?
> phpinfo()
> ?>
>
> This is exactly what the lines in the [mail function] within my php.ini
file
> looks like:
>
> ...................
> [mail function]
> SMTP   = localhost   ;for win32 only
> sendmail_from = [EMAIL PROTECTED] ;for win32 only
> ;sendmail_path =      ;for unix only, may supply arguments as well
(default
> is sendmail -t)
> ....................
>
> which is what she advises on page 116 of her book.
>
> I have inserted:
>
> localhost
>
> and
>
> my e-mail address
>
> in the php.ini file.
>
> And I took the script - html and php - right off her CD and tested them on
> a Win98 / Apache / OE 5
>
> and got:
>
> ............................
> Warning: Failed to Connect in c:\program files\apache
> group\apache\htdocs\send_simpleform.php on line 19
>
>
> // This is my php.ini file in WINDOWS
>
> [mail function]
> SMTP   = localhost   ;for win32 only
> sendmail_from = [EMAIL PROTECTED] ;for win32 only
> ;sendmail_path =      ;for unix only, may supply arguments as well
(default
> is sendmail -t)
>
> ....................................
>
> //...and this is the html form:
>
> <HTML>
> <HEAD>
> <TITLE>Simple Feedback Form</TITLE>
> </HEAD>
> <BODY>
>
> <FORM METHOD="post" ACTION="send_simpleform.php">
>
>
> <P><strong>Your Name:</strong><br>
> <INPUT type="text" NAME="sender_name" SIZE=30></p>
>
> <P><strong>Your E-Mail Address:</strong><br>
> <INPUT type="text" NAME="sender_email" SIZE=30></p>
>
> <P><strong>Message:</strong><br>
> <TEXTAREA NAME="message" COLS=30 ROWS=5 WRAP=virtual></TEXTAREA></p>
>
> <P><INPUT TYPE="submit" NAME="submit" VALUE="Send This Form"></p>
>
> </FORM>
>
> </BODY>
> </HTML>
>
> ..............................
>
>
>
> //and lastly... this is the php script:
> <?
> if (($sender_name == "") && ($sender_email == "") && ($message == "")) {
>  header("Location: http://localhost/simple_form.html";);
>  exit;
> }
> $msg = "E-MAIL SENT FROM WWW SITE\n";
> $msg .= "Sender's Name:    $sender_name\n";
> $msg .= "Sender's E-Mail:  $sender_email\n";
> $msg .= "Message:          $message\n\n";
> $to = "[EMAIL PROTECTED]";
> $subject = "Web Site Feedback";
> $mailheaders = "From: My Web Site <> \n";
> $mailheaders .= "Reply-To: $sender_email\n\n";
> mail($to, $subject, $msg, $mailheaders);
> ?>
> <HTML>
> <HEAD>
> <TITLE>Simple Feedback Form Sent</TITLE>
> </HEAD>
> <BODY>
> <H1>The following e-mail has been sent:</H1>
> <P><strong>Your Name:</strong><br>
> <? echo "$sender_name"; ?>
> <P><strong>Your E-Mail Address:</strong><br>
> <? echo "$sender_email"; ?>
> <P><strong>Message:</strong><br>
> <? echo "$message"; ?>
> </BODY>
> </HTML>
> .....................................................
>
>
> ----- Original Message -----
> From: "DL Neil" :
>
> > Did you restart Apache after changing PHP.INI?
> >
> > Please post the mail() section of the script and the mail section of the
> > PHP.INI.
> > =dn
>
>
> ---
> [This E-mail scanned for viruses by gonefishingguideservice.com]
>
>

--- End Message ---
--- Begin Message ---
Dl Neil wrote: in message:
> OK Anthony you've got it...(snipped)
>
> The wave is building under you, all you have to figure out now, is which
way
> to stand on the board!
> =dn
> (sorry, that's surfing not fishing, and salt water not fresh...)
......................................

Thanks again for throwing me the life preserver.
Happy Holidays to you and yours...
TR





--- End Message ---
--- Begin Message ---
Hi, all, i'm going to upgrade my OS from XP home to XP Pro. Now at the mo i'm 
running Apache, PHP, and MySQL. If I perform the upgrade, will everything 
still run as normal?

Has anybody been in a situation like this before?

Tryst
--- End Message ---
--- Begin Message ---
Hi,

Saturday, December 7, 2002, 9:43:47 AM, you wrote:
DO> Hi People,

DO> I ve just started with some OOP programming in PHP and now i have to 
DO> build a set of classes that can generate a html form.. But i have a 
DO> problem with the <select><option></option></select> thing....
DO> I hope someone can help me here or give me some pointers,... any help is 
DO> apreciated. Here is a part of my code :

DO> class selectField extends formElement {
   
DO>     //Constructor
DO>     function selectField($name, $value) {
DO>         formElement::setName($name);
DO>         formElement::setValue($value);
DO>     }

DO>     function generateSelectField() {
DO>         $theOutput = "<select name=\"".$this->name."\">\n";
DO>         foreach($this->value as $key=>$val) {
DO>             $theOutput .= "<option 
value=\"".$this->>value."\">".$this->value."</option>\n";
DO>         }
DO>         $theOutput .= "</select>\n";
DO>         Return $theOutput;
DO>     }
DO> }

DO> This is how i call the Object:

DO> $test[] = "Test1";
DO> $test[] = "Test2";
DO> $test[] = "Test3";
DO> $test[] = "Test4";
DO> $test[] = "Test5";
DO> $select = new selectField("testje", $test);
echo$select->>generateSelectField();

DO> But all i get is a select box with the word Array in it 5 times...Thanks 
DO> for your time...

DO> Best regards,

DO> Davy Obdam
DO> mailto:[EMAIL PROTECTED]

The output function is wrong it should be

function generateSelectField() {
        $theOutput = "<select name=\"".$this->name."\">\n";
        foreach($this->value as $key=>$val) {
            $theOutput .= "<option value=\"".$val."\">".$val."</option>\n"; //this line
        }
        $theOutput .= "</select>\n";
        Return $theOutput;
    }

-- 
regards,
Tom

--- End Message ---

Reply via email to