php-windows Digest 4 Feb 2005 12:27:24 -0000 Issue 2562
Topics (messages 25509 through 25515):
Frustrating File Upload Error
25509 by: Ron.Herhuth.tatumpartners.com
25510 by: Mikey
25511 by: trystano.aol.com
$subject = "form results " causing problem
25512 by: Patrick Roane
25513 by: Mike
25514 by: Patrick Roane
php exec function
25515 by: Zarouali Rachid
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 ---
I have a form that may or may not contain a file upload. When the user
uploads a file the script works as it should. The problem is that when a
user doesn't upload a file, I get an error that reads:
"PHP Notice: No file uploaded in Unknown on line 0 PHP Warning: Cannot
send session cache limiter - headers already sent in..."
I have tried everything I can think of to keep it from erroring out...the
sample logic is here:
if($_FILES)
{
if(isset($_FILES['file_upload']) && $_FILES['file_upload']['name'] !="")
{
..
but the error still occurs.
I have even went so far as to try to turn off the error reporting using:
error_reporting(0);
and that didn't work either.
I am using PHP 4.2.1 under IIS
Any ideas or suggestions?
Thanks,
Ron
{
--- End Message ---
--- Begin Message ---
> if($_FILES)
> {
> if(isset($_FILES['file_upload']) &&
> $_FILES['file_upload']['name'] !="") {
>
> ..
> Any ideas or suggestions?
>
> Thanks,
> Ron
Have you tried:
If (isset ($_FILES))
Is only a guess though.
HTH,
Mikey
--- End Message ---
--- Begin Message ---
Firstly, before evening uploading a file, you should check to see whether a
file has been selected (there is a filename in the textbox) - use JavaScript
for this. Then secondly, you should always perform some logic before actually
attempting the upload such as checking to see that it has a file extension etc
etc.
Tryst
--- End Message ---
--- Begin Message ---
I was wondering why when I insert the $subject = "form
results", I get the ...echo "Message failed to send";
error.
But when I comment this out, everything works fine.
Please see below.
<?php
} else {
error_reporting(0);
// initialize a array to
//hold any errors we encounter
$errors = array();
// test to see if the form was actually
// posted from our form
// In testing, if you get an Inavlid referer
error
// comment out or remove the next three lines
$page =
$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
if (!ereg($page, $_SERVER['HTTP_REFERER']))
$errors[] = "Invalid referer";
// check to see if a name was entered
if (!$_POST['from'])
$errors[] = "Name is required";
// check to see if email was entered
if (!$_POST['email'])
$errors[] = "a valid e-mail address is
required";
// if there are any errors, display them
if (count($errors)>0) {
foreach($errors as $err)
echo "$err<br>\n";
echo "<br>Please use your browser's Back
button to fix.";
} else {
// no errors, so we build our message
$subject = "form results";
$recipient = '[EMAIL PROTECTED]';
$phone = stripslashes($_POST['phone']);
$from = stripslashes($_POST['from']);
$mail = stripslashes($_POST['email']);
$comments = "Comments from:
$from\n\n".stripslashes($_POST['comments']);
if (mail($recipient, $comments, $phone, $mail,
$subject)){
echo nl2br("<b>Thank you! Information Sent:</b>
To: $recipient
name: $from
email: $mail
phone: $phone
content: $comments");
} else
echo "Message failed to send";
}
}
?>
=====
----------------
"forget your lust for the rich man's gold. All that you need, is in your soul.
You can do this if you try. All that I want for you my son, is to be satisfied"
~ Lynard Skynard
--- End Message ---
--- Begin Message ---
Looks like you may be using the wrong format for the mail() function.
bool mail ( string to, string subject, string message [, string
additional_headers [, string additional_parameters]] )
http://us4.php.net/manual/en/function.mail.php
Reference the form you should be passing params and notice that the subject
should be the second param.
-M
> -----Original Message-----
> From: Patrick Roane [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, February 02, 2005 6:08 PM
> To: [email protected]
> Subject: [PHP-WIN] $subject = "form results " causing problem
>
> I was wondering why when I insert the $subject = "form
> results", I get the ...echo "Message failed to send";
>
> error.
>
> But when I comment this out, everything works fine.
> Please see below.
>
> <?php
> } else {
> error_reporting(0);
> // initialize a array to
> //hold any errors we encounter
> $errors = array();
>
> // test to see if the form was actually
> // posted from our form
> // In testing, if you get an Inavlid referer error
> // comment out or remove the next three lines
> $page =
> $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
> if (!ereg($page, $_SERVER['HTTP_REFERER']))
> $errors[] = "Invalid referer";
>
> // check to see if a name was entered
> if (!$_POST['from'])
> $errors[] = "Name is required";
> // check to see if email was entered
> if (!$_POST['email'])
> $errors[] = "a valid e-mail address is required";
> // if there are any errors, display them
> if (count($errors)>0) {
> foreach($errors as $err)
> echo "$err<br>\n";
> echo "<br>Please use your browser's Back button to fix.";
> } else {
> // no errors, so we build our message
> $subject = "form results";
> $recipient = '[EMAIL PROTECTED]';
> $phone = stripslashes($_POST['phone']);
> $from = stripslashes($_POST['from']);
> $mail = stripslashes($_POST['email']);
> $comments = "Comments from:
> $from\n\n".stripslashes($_POST['comments']);
> if (mail($recipient, $comments, $phone, $mail, $subject)){
>
--- End Message ---
--- Begin Message ---
Mike,
thanks a lot! All I had to do was swich the $subject
over to the 2nd param. in my mail (). Sometimes the
answer is so easy, you don't see it!
--- Mike <[EMAIL PROTECTED]> wrote:
> Looks like you may be using the wrong format for the
> mail() function.
>
> bool mail ( string to, string subject, string
> message [, string
> additional_headers [, string additional_parameters]]
> )
>
> http://us4.php.net/manual/en/function.mail.php
>
> Reference the form you should be passing params and
> notice that the subject
> should be the second param.
>
> -M
>
> > -----Original Message-----
> > From: Patrick Roane [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, February 02, 2005 6:08 PM
> > To: [email protected]
> > Subject: [PHP-WIN] $subject = "form results "
> causing problem
> >
> > I was wondering why when I insert the $subject =
> "form
> > results", I get the ...echo "Message failed to
> send";
> >
> > error.
> >
> > But when I comment this out, everything works
> fine.
> > Please see below.
> >
> > <?php
> > } else {
> > error_reporting(0);
> > // initialize a array to
> > //hold any errors we encounter
> > $errors = array();
> >
> > // test to see if the form was actually
> > // posted from our form
> > // In testing, if you get an Inavlid referer
> error
> > // comment out or remove the next three
> lines
> > $page =
> > $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
> > if (!ereg($page, $_SERVER['HTTP_REFERER']))
> > $errors[] = "Invalid referer";
> >
> > // check to see if a name was entered
> > if (!$_POST['from'])
> > $errors[] = "Name is required";
> > // check to see if email was entered
> > if (!$_POST['email'])
> > $errors[] = "a valid e-mail address is
> required";
> > // if there are any errors, display them
> > if (count($errors)>0) {
> > foreach($errors as $err)
> > echo "$err<br>\n";
> > echo "<br>Please use your browser's Back
> button to fix.";
> > } else {
> > // no errors, so we build our message
> > $subject = "form results";
> > $recipient = '[EMAIL PROTECTED]';
> > $phone = stripslashes($_POST['phone']);
> > $from = stripslashes($_POST['from']);
> > $mail = stripslashes($_POST['email']);
> > $comments = "Comments from:
> > $from\n\n".stripslashes($_POST['comments']);
> > if (mail($recipient, $comments, $phone,
> $mail, $subject)){
> >
>
>
=====
----------------
"forget your lust for the rich man's gold. All that you need, is in your soul.
You can do this if you try. All that I want for you my son, is to be satisfied"
~ Lynard Skynard
--- End Message ---
--- Begin Message ---
hy all,
i'm searching for a way to execute using php script a local client software,
i'll explain:
i have an application written on php, and i would like to make a link or
button who can execute a software who is installed not on the php webserver
but on the local client machine who uses the php application.
anyone knows how to do this ?
thanks for your help
Rachid ZAROUALI
--- End Message ---