php-general Digest 26 Dec 2003 17:08:02 -0000 Issue 2495

Topics (messages 173328 through 173336):

magic_quotes_gpc setting question.
        173328 by: Rajesh Kumar

Where and how do i use $_post etc
        173329 by: Piet
        173331 by: Al
        173332 by: Piet
        173333 by: Mike Brum

Insert into array...
        173330 by: Andras Kende

How New Is <<<HERE?
        173334 by: stiano.Optonline.net
        173335 by: Cesar Cordovez

Migrating from SSI and Perl
        173336 by: Philip Pawley

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 --- Hello,

Here I've got a few related questions, which are not stated explicitly in the manual.

1. The manual says that the magic_quotes_gpc setting cannot be set at
   runtime. Is it not possible to set this setting in an ini file, and
   parse it with the parse_ini_file() function? Also, if this was
   possible, what will PHP do to the modified variables? Run the
   stripslashes() functions on all of them?

2. On a related line, are we allowed to use ini values in our ini file
   that contradict the defined ini values in php.ini? Won't this confuse
   the parser?

3. What would I do if I didn't have access to my own custom ini file,
   but could somehow get the file either by using fopen(), file() or
   file_get_contents()? Can I parse a string (or array) like an ini
   file?

4. Does parse_ini_file() allow us to specify absolute filenames of the
   form "scheme://..." from another server, if our allow_url_fopen
   is TRUE?

Thank You.
--- End Message ---
--- Begin Message ---
Hi

I am trying to find examples of how and where to use $_POST, $_GET etc. I
searched a lot of places, but cant seem to find decent examples or a
tutorial or something.

Can someone point me in the right direction?

--- End Message ---
--- Begin Message ---
"Piet" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi
>
> I am trying to find examples of how and where to use $_POST, $_GET etc. I
> searched a lot of places, but cant seem to find decent examples or a
> tutorial or something.

$_POST and $_GET are associative arrays containing the form data sent by a
user to a page. Whether your user's submitted form data is in $_POST or
$_GET depends on what method attribute you've specified in the <form> tag in
your HTML code. Take a look at the following HTML example:

<form method="get" action="script.php">
    <input type="text" name="firstName">
    <input type="text" name="lastName">
    <input type="submit">
</form>

Now in the file script.php you can access the submitted form values in the
$_GET array, using the form field names as array keys. e.g:

<?php
    $firstName = $_GET['firstName'];
    $lastName = $_GET['lastName'];
    echo 'The user submitted the name'.$firstName.' '.$lastName;
?>

If you had set the <form method="post"> in your HTML, then you could have
accessed the form values from the $_POST array within PHP.

Hope that helps,

Al

--- End Message ---
--- Begin Message ---
Why would i do this long coding in the second page "script.php" the
variables values is already available in "script.php" when i do a post or
get, if i use $_POST or $_GET to define a variable already available, that
seems like a lot of extra coding for no reason.
"Al" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> "Piet" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Hi
> >
> > I am trying to find examples of how and where to use $_POST, $_GET etc.
I
> > searched a lot of places, but cant seem to find decent examples or a
> > tutorial or something.
>
> $_POST and $_GET are associative arrays containing the form data sent by a
> user to a page. Whether your user's submitted form data is in $_POST or
> $_GET depends on what method attribute you've specified in the <form> tag
in
> your HTML code. Take a look at the following HTML example:
>
> <form method="get" action="script.php">
>     <input type="text" name="firstName">
>     <input type="text" name="lastName">
>     <input type="submit">
> </form>
>
> Now in the file script.php you can access the submitted form values in the
> $_GET array, using the form field names as array keys. e.g:
>
> <?php
>     $firstName = $_GET['firstName'];
>     $lastName = $_GET['lastName'];
>     echo 'The user submitted the name'.$firstName.' '.$lastName;
> ?>
>
> If you had set the <form method="post"> in your HTML, then you could have
> accessed the form values from the $_POST array within PHP.
>
> Hope that helps,
>
> Al

--- End Message ---
--- Begin Message ---
Let's make some assumptions - 

1) having register_globals on is bad
2) we all like to write scripts as secure as possible

Given #1 and #2, if you stop referencing variables directly (e.g. as
$firstName in the script below) since register_globals is off, it
immediately adds a degree of security to your script if you're aware of the
difference between GET and POST requests. GET requests are quite easy to
fake (just add the variables and values to the URL) and unless you have
checks against it, a malicious user could take advantage of this. POST
requests are a bit more tricky to fake, but not "difficult" in the grand
scheme of things.

Either way, in the examples that Piet wrote, there's no "extra coding".
Writing the variable names is a bit more key strokes, but given the
advantages of having even a slightly more secure script, it's a good thing
and worth a bit more typing.

-M

-----Original Message-----
From: Piet [mailto:[EMAIL PROTECTED] 
Sent: Friday, December 26, 2003 6:41 AM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: Where and how do i use $_post etc

Why would i do this long coding in the second page "script.php" the
variables values is already available in "script.php" when i do a post or
get, if i use $_POST or $_GET to define a variable already available, that
seems like a lot of extra coding for no reason.
"Al" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> "Piet" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> > Hi
> >
> > I am trying to find examples of how and where to use $_POST, $_GET etc.
I
> > searched a lot of places, but cant seem to find decent examples or a 
> > tutorial or something.
>
> $_POST and $_GET are associative arrays containing the form data sent 
> by a user to a page. Whether your user's submitted form data is in 
> $_POST or $_GET depends on what method attribute you've specified in 
> the <form> tag
in
> your HTML code. Take a look at the following HTML example:
>
> <form method="get" action="script.php">
>     <input type="text" name="firstName">
>     <input type="text" name="lastName">
>     <input type="submit">
> </form>
>
> Now in the file script.php you can access the submitted form values in 
> the $_GET array, using the form field names as array keys. e.g:
>
> <?php
>     $firstName = $_GET['firstName'];
>     $lastName = $_GET['lastName'];
>     echo 'The user submitted the name'.$firstName.' '.$lastName; ?>
>
> If you had set the <form method="post"> in your HTML, then you could 
> have accessed the form values from the $_POST array within PHP.
>
> Hope that helps,
>
> Al

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

--- End Message ---
--- Begin Message ---
Hello All,

I would like to put 1 new field into this multidimensional array...

$orders =

1 => Array (11)
  Name => JUDY
  Order => 334455
2 => Array (11)
  Name => MARY
  Order => 12590

TO:

$orders =

1 => Array (11)
  Name => JUDY
  Order => 334455
  Newitem => someting
2 => Array (11)
  Name => MARY
  Order => 12590
  Newitem => something


I can do one at the time like:
$orders[1]['Newitem'] = "something";

But not for the whole array....

Thanks,

Andras Kende

--- End Message ---
--- Begin Message ---
Okay, for everyone took a break for Christmas, and to update Jasper and
Jeremy--who've tried big-time to help me--here's again the sitch and where
I stand as of now.

I'm on a Macintosh PowerBook running OS X.2.1 and PHP 4.3.0. I'm tryning to
run the following code:

<html>
<head>
<title>
persistence demo
</title>
</head>

<body>

<h1>Persistence Demo</h1>
<form>
<?php
//increment the counters
$txtBoxCounter++;
$hdnCounter++;

print <<<HERE

<input type = "text"
name = "txtBoxCounter"
value = "$txtBoxCounter">

<input type = "hidden"
name = "hdnCounter"
value = "$hdnCounter">
<h3>The hidden value is $hdnCounter</h3>
<input type = "submit"
value = "click to increment counters">
HERE;

?>

</form>
</body>
</html>

What that gets me is:

Parse error: parse error, unexpected $ in [my path to this file] on line 33

register_globals is, of course, off. So I add $txtBoxCounter =
$_POST['txtBoxCounter] and $hdnCounter = $_POST['hdnCounter] as separate
line right after <?php. And that gets me an unexpected TVARIABLE message.

Anyone, please?

Thank you.

Steve Tiano

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .

--- End Message ---
--- Begin Message --- Change:

$txtBoxCounter = $_POST['txtBoxCounter]
$hdnCounter = $_POST['hdnCounter]

to


$txtBoxCounter = $_POST['txtBoxCounter']; $hdnCounter = $_POST['hdnCounter'];

(Notice the ' at the end of txtBoxCounter and hdnCounter.

Merry X'mas

[EMAIL PROTECTED] wrote:
Okay, for everyone took a break for Christmas, and to update Jasper and
Jeremy--who've tried big-time to help me--here's again the sitch and where
I stand as of now.

I'm on a Macintosh PowerBook running OS X.2.1 and PHP 4.3.0. I'm tryning to
run the following code:

<html>
<head>
<title>
persistence demo
</title>
</head>

<body>

<h1>Persistence Demo</h1>
<form>
<?php
//increment the counters
$txtBoxCounter++;
$hdnCounter++;

print <<<HERE

<input type = "text"
name = "txtBoxCounter"
value = "$txtBoxCounter">

<input type = "hidden"
name = "hdnCounter"
value = "$hdnCounter">
<h3>The hidden value is $hdnCounter</h3>
<input type = "submit"
value = "click to increment counters">
HERE;

?>

</form>
</body>
</html>

What that gets me is:

Parse error: parse error, unexpected $ in [my path to this file] on line 33

register_globals is, of course, off. So I add $txtBoxCounter =
$_POST['txtBoxCounter] and $hdnCounter = $_POST['hdnCounter] as separate
line right after <?php. And that gets me an unexpected TVARIABLE message.

Anyone, please?

Thank you.

Steve Tiano

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .


--- End Message ---
--- Begin Message ---
I am new to php.

My site, at the moment, uses SSI to call a Perl browser-sniffing script.

I would like to:
1. use php to call the Perl script.
2. then save the values the Perl script outputs as php variables.

Can this be done? If so, how?

Thanks,

Philip Pawley

--- End Message ---

Reply via email to