[PHP] file selected in form changes in next php page?!

2001-01-21 Thread Chris Hayes

Dear group,

in my first page i have a form selcting a file.
The names i used were csvfile, csv_file, and my_file.

After submitting the form the filename changed to a totally different file, 
likeC:\PHP\php72C3.TMP or C:\PHP\phpD2B4.TMP
(windows, apache, php4, internet explorer 5 as well as Mozilla 6)
What is happening?
code below.

Chris

##FORM

form name="form1" enctype="multipart/form-data" method="post" ACTION=?php 
echo "$PHP_SELF";? NAME="beheerform"
 input type="hidden" name="FILE_INVOEREN" value="zoek file (op eigen 
computer)"
 input type="file" name="my_file" onChange='javascript:alert(this.value);'
 input type="submit" name="Submit" value="Invoeren"
/form

## NEXT PAGE  (in main)
if (isset($FILE_INVOEREN)):
echo $my_file;
if ($my_file==0) die ("Selecteer een file!");







--  C.Hayes  Droevendaal 35  6708 PB Wageningen  the Netherlands  --


 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] (Newbie) String within a string

2001-01-19 Thread Chris Hayes


original question jalist:
  I'm trying to grab a string from within a string based on a matching word
  or phrase. 

In the middle of the night i was thinking hey, why not use a regexp,
look for the pattern word-space-word-space-SEARCHWORD-space-word-space-word
something like 

$toshow = 
regexp ( "( [alphanum]+ [alphanum]+ [$YOURWORD] [alphanum]+ [alphanum]+ 
)", $totalstring);


I am totally bad with regexps, but that 's the idea. Might be faster than 
the array? You'll have to take care of comma's etc.




From:   "jalist" [EMAIL PROTECTED]
To: "PHP" [EMAIL PROTECTED]
Date sent:  Thu, 18 Jan 2001 16:12:31 -
Subject:RE: [PHP] (Newbie) String within a string

 Excellent, thanks a lot Chris.
 
 Steve
 (jalist)
 [EMAIL PROTECTED]
 http://ls2k.org
 
 -Original Message-
 From: Chris Hayes [mailto:[EMAIL PROTECTED]]
 Sent: 18 January 2001 15:43
 To: jalist; PHP
 Subject: Re: [PHP] (Newbie) String within a string
 
 
 
 jalist:
  I'm trying to grab a string from within a string based on a matching word
 or
  phrase. Example...
 
 You say you want the middle, not two words before and two words after.
 
 I see several ways.
 
 
  1. Explode into an word-array and use that:
  1. prepare string
a) add spaces after comma's and fullstops by some replace
 operation (replace ',' by ', ').
b) remove double spaces
  2. split to an array using explode (space as string separator)
   Now you have every word in a separate place in the array
  3. Get # of words by count($array)
 4. Divide by two and get nearest integer (hence floor and +0.5!)
   $mid= floor(count($array)/2 + 0.5)
   OH NO, correction, that's the middle, you wanted a specific word.
   I'm afraid you'll have to walk thorugh the array to find the word
   you need.
 
for (i=0;icount($array);i++)
{
if ($array[$i]==$searchword)
 {   $fragment= "...".
   $array[$mid-2] ." "
$array[$mid-1] ." "
   $array[$mid]   ." "
   $array[$mid+1] ." "
   $array[$mid+2] ."...";
   ##extra job for you: make sure  $i = 2
  ##   and $i = count-2
  ## or you'll get an error
 
 [exit the for loop somehow, maybe drop
  this in a function and RETURN;]
 }
 
}
 
 
 
 OR
 
  2. Continue with the strpos and strrpos, organize it a bit better.
  For instance find the middle of the string. Split at nearest
  space in leftstring and rightstring.
 
   Make a function chop_last_word, chop last two or three words from
   leftstring and add to resultstring in right order.
 
   Same for rightstring.
 
  I think the array way is cleaner.
 
 Chris
 
 
 --  C.Hayes  Droevendaal 35  6708 PB Wageningen  the Netherlands  --
 
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




--  C.Hayes  Droevendaal 35  6708 PB Wageningen  the Netherlands  --


 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] force page exit with submit button

2001-01-19 Thread Chris Hayes

Dear group,
i'm planning to change a javascript shoppingcart site to a PHP site.
For the javascritp shoppingcart it was convenient to have an index so i made 
it with frames, menu on the left, content on the right, data automatically 
updated to the index as soon as some field was unfocused.

I would like to keep the frame structure.

Now I'm afraid users will fill in one page, and not push the submit button 
but use the menu to change to another order page, so the orders of the first 
order page are lost. Are there other ways than a combination of unload and 
javascript?

groetjes,
Chris

 


--  C.Hayes  Droevendaal 35  6708 PB Wageningen  the Netherlands  --


 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] (Newbie) String within a string

2001-01-18 Thread Chris Hayes


jalist:
 I'm trying to grab a string from within a string based on a matching word or
 phrase. Example...

You say you want the middle, not two words before and two words after.

I see several ways.


 1. Explode into an word-array and use that:
1. prepare string 
a) add spaces after comma's and fullstops by some replace 
operation (replace ',' by ', ').
b) remove double spaces
2. split to an array using explode (space as string separator)
Now you have every word in a separate place in the array
3. Get # of words by count($array)
4. Divide by two and get nearest integer (hence floor and +0.5!)
$mid= floor(count($array)/2 + 0.5)
OH NO, correction, that's the middle, you wanted a specific word.
I'm afraid you'll have to walk thorugh the array to find the word  
 
you need. 

for (i=0;icount($array);i++)
{
if ($array[$i]==$searchword)
{   $fragment= "...".
 $array[$mid-2] ." "
 $array[$mid-1] ." "
 $array[$mid]   ." "
 $array[$mid+1] ." "
 $array[$mid+2] ."...";
##extra job for you: make sure  $i = 2 
## 
 and $i = count-2
## or you'll get an error 

[exit the for loop somehow, maybe drop 
this in a function and RETURN;]
}

}



OR

 2. Continue with the strpos and strrpos, organize it a bit better.
For instance find the middle of the string. Split at nearest
space in leftstring and rightstring.

Make a function chop_last_word, chop last two or three words from  
 
leftstring and add to resultstring in right order.

Same for rightstring.

 I think the array way is cleaner.

Chris


--  C.Hayes  Droevendaal 35  6708 PB Wageningen  the Netherlands  --


 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Can a PHP program recieve an e-mail and write it to a file???

2001-01-18 Thread Chris Hayes

Hi Jeremy,
Yes that is possible. But i'm afraid it needs some work.

There are several classes on the several dowmload sites. Look for POP3 or 
IMAP classes. Some recent links at the end of this mail. With them it is 
possible to get the headers and the body either line by line or in total. It 
is possible to check mail and delete mail. You can log in to any email 
address you like by entering the host, username and password.


Regular checking must be done by starting a .php file (which reads email of course) 
from a timescheduler like cron on unix-type servers or with some other scheduler on 
windows or whatever you use. Check the archives of this php-general list for cron 
jobs, that question returns about every week.

 I suppose that it should have some sort of authentication built in to 
 prevent people from e-mailing PHP code that could be processed and 
 do bad things.
I don't know about security of strings, i just don't see when they can be activated, 
but it is worth digging in. Maybe htmlspecialchars($text) will do?

I was looking into this too because i would like to receive emails with data, 
process them and either enter data or return an error-reporting email.
About security i am most worried how to know whether the sender is really the 
sender. I mean, if i make them give their password every time, it could be 
intercepted. If i check by email address, i know it is only too easy to fake an 
email being sent from a certain email. Any idea? 

 
 Could the e-mail be written to a mail queue say
 [EMAIL PROTECTED] and the script periodically check the mail
 queue for new e-mail print its contents to a text file somewhere in the
 serverroot and then erase the mail queue???
 
 Does this sound possibile???
Yes. But it will take quite some time making it solid bastard- and fool-proof.  
Writing to a file is normal file-processing once you have extracted the text you 
need from the email. 


Maybe we can cooperate building a class? There are pop3 classes around that could be 
extended with some functions i suppose more people can use.

What about making this:  (just brainstorming)

/* build further on an existing pop3 class :  
  function connect {connect using pop_3_class}
  function disconnect {disconnect using pop_3_class}
  function getonemail 
*/


class email {
  vars $sender, $subject, $body, $emailID_for_POP3  

function read_one_mail()
sets $header, $body, $sender
or if you like $body_lines_array
maybe even attachments?

function validate_user()
compares email to database of authorised users
for instance 1) find password and username in body, 
2) compare to database
3) accept or reject (log possible 
frauds with full headers)

function split_up_body_to_data()
because i want to chop up a data mail which may look like
[name]Chris
[password]Cookies!
[announcement_title]Come to my party!
[announcement_date]July 11 2001
[announcement_body]Be welcome to my party! I'll have cookies!
[end]
 I want to get this into an kay-val array and 
 further check in another part, maybe return a mail with error,
and on succes i can use:

function delete_mail(this_one)

}





I have some links, without having tested them all:

*   http://home.concepts.nl/~kid/phpmanual/sockets.html 

*   pop3.php Copyright (C) 1998, Manuel Lemos ([EMAIL PROTECTED])
(I think i saw Manuel on this list! :-) )
Also it looks the most structured and general.
I forgot where, maybe the px.sklar.com site.

*   pop3_connect on http://phpclub.unet.ru/samples/73.phps

* http://www.weberdev.com/get_example.php3?count=1643

* http://px.sklar.com/code-pretty.html?code_id=108
* http://px.sklar.com/code-pretty.html?code_id=139


PS there might be Perl codes around doing something similar to what you want.


Chris Hayes




--  C.Hayes  Droevendaal 35  6708 PB Wageningen  the Netherlands  --


 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How to escape from a function?

2001-01-16 Thread Chris Hayes

 say, I have a function like this


 function foo()
 {
 babababa...;
 /*at this point, I want to output a lot of html, can I use a ':' to escape
 from there?*/


echo 'html';
echo 'titlechris is great/title';
return; // would just stop the function

OR if you want to call the function from elsewhere like this : echo foo(); 
or $string=foo();

function foo(){
$html_construct='html';
$html_construct.='titlechris is great/title';
return $html_construct; 

}
 /*I know I can do this is a if construct or for... construct,
 but I can't do this at this point*/ /*is there any way for me to do the
 similar thing?*/ }

not sure about your question.  The manual will give escapes for for example 
switchs parts (break;) and others. See manual part II.11 Control structures.


 
 And I have one more question, what is the meaning of 'or'?
 e.g.
 $db=mysql_connect("localhost","root","password") or die ("could not
 connect");

In case the command before 'or; fails do what is after 'or'.

So if you connect succesfully the script continues, if something goes wrong 
(wrong password, server down etc etc) the script does 

die ('bla')

this means the script stops and the browsers shows 'bla'.
(except when you'r in the middle of building a page and the text is 
invisible due to its location in the HTML, for example when a table is 
opened before in Netscape but not closed yet.

Chris



--  C.Hayes  Droevendaal 35  6708 PB Wageningen  the Netherlands  --


 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Strings??

2001-01-16 Thread Chris Hayes

Ade asked:
 I have a form which has 10 fields, is there any way in PHP to take the values
 once submitted and create a string for each??

Absolutely. Worse; it is already done for you!
If you give the input box a name, and submit to a php page, the php page 
contains a variable with that name!
If the name is 'textbox3' the variable will be called $textbox3.

Be careful though; if the variable is not filled in in the form it may not 
exist. So better test that:

 if isset($textbox3) echo $textbox3;

There's a lot more to forms and variables. In every other tutorial i guess.

Chris






--  C.Hayes  Droevendaal 35  6708 PB Wageningen  the Netherlands  --


 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] ibase (firebird) localhost login ?

2001-01-10 Thread Chris Hayes

hi,
I know it's slightly off topic but i hope you;ll forgive me.
i'm testing interbase because someone on this list mentioned it would be  a 
good offline database.

Interbase ('firebird') wants to connect to the local server (i'm running 
WAMP - Windows, Apache, MySQL, PHP), and interbase needs a username.

But its all local, not connected. So what should i tell interbase??

Chris

PS i AM currently downloading the manual but that will take another hour (10 
MB, bad line, was interrupted several times )




--  C.Hayes  Droevendaal 35  6708 PB Wageningen  the Netherlands  --


 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




<    1   2   3   4