[PHP] What does this mean?

2009-06-25 Thread Jason Carson
Hey all, I'm new to the list and I have a question...

What does => mean?

The book I am reading is called Programming PHP published by O'Reilly. I
haven't read the whole book yet. I was flipping through the pages and in
the book there is mention of <= (less than or equal) and >= (greater than
or equal)but it doesn't say what => is even though it is used numerous
times in the example code.

Thanks

Jason




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



[PHP] Sessions

2009-07-02 Thread Jason Carson
Hello all,

Do I have to add session_start() at the beginning of every page so that
the $_SESSION variables work on all pages or do I use session_start() on
the first page and something else on other pages?

Thanks


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



[PHP] Writing to a file

2009-07-03 Thread Jason Carson
Hello everybody,

How would I go about writing stuff to a file but in between the 
tags?

Example, say I have config.php as follows...



How would I go about adding stuff at the end of the file, but before the
?> tag?


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



Re: [PHP] Writing to a file

2009-07-03 Thread Jason Carson
> On Fri, Jul 3, 2009 at 06:01, Jason Carson wrote:
>> Hello everybody,
>>
>> How would I go about writing stuff to a file but in between the 
>> tags?
>
> The current industry standard is a combination of text editor and
> keyboard, but there are many options.
>
> More specifically, are you trying to write to a PHP file *with*
> PHP?  And if so, would this be the kind of file you're trying to write
> (such as creating an automated installer with auto-config)?
>
> --
> 
> daniel.br...@parasane.net || danbr...@php.net
> http://www.parasane.net/ || http://www.pilotpig.net/
> Check out our great hosting and dedicated server deals at
> http://twitter.com/pilotpig
>

Yes, I am trying to write stuff to a file with PHP but in between the
 tags and without deleting what is already in the file.


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



[PHP] Simple login form with cookies

2009-07-05 Thread Jason Carson
Hello everyone,

I am trying to create a PHP login script using cookies but am having some
troubles. Here is my setup

index.php -> authenticate.php -> admin.php

I want a login form on index.php that allows me to login with my username
and password and then passes $_POST['username'] and $_POST['password'] to
authenticate.php

Then authenticate.php authenticates against a database of allowed users
(Which I already have setup and it works fine), if a valid user has
entered the correct information then admin.php is loaded...

header("location:admin.php");

...the admin.php code would look something like the following..

Code: [Select]


So basically I think I need to create a cookie from index.php OR
authenticate.php and then pass the information to admin.php.
I set the cookie like this...

setcookie("Admin", $username);

Which file(index.php OR authenticate.php) do I create the cookie and how
do I access the information in the cookie on admin.php?


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



Re: [PHP] Simple login form with cookies

2009-07-05 Thread Jason Carson
> Hello everyone,
>
> I am trying to create a PHP login script using cookies but am having some
> troubles. Here is my setup
>
> index.php -> authenticate.php -> admin.php
>
> I want a login form on index.php that allows me to login with my username
> and password and then passes $_POST['username'] and $_POST['password'] to
> authenticate.php
>
> Then authenticate.php authenticates against a database of allowed users
> (Which I already have setup and it works fine), if a valid user has
> entered the correct information then admin.php is loaded...
>
> header("location:admin.php");
>
> ...the admin.php code would look something like the following..
>
> Code: [Select]
>  if (isset($_COOKIE['username'])) {
> echo "success!";
> } else {
> echo "Failure";
> }
> ?>
>
> So basically I think I need to create a cookie from index.php OR
> authenticate.php and then pass the information to admin.php.
> I set the cookie like this...
>
> setcookie("Admin", $username);
>
> Which file(index.php OR authenticate.php) do I create the cookie and how
> do I access the information in the cookie on admin.php?
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I finally got it working. I needed to setcookie() in login.php. Also, the
names of the cookies(Using setcookie()) where wrong (The names where
"Admin" when they should have been "adminuser" and "adminpass") Once I
fixed that then the following worked in admin.php...



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



Re: [PHP] Simple login form with cookies

2009-07-05 Thread Jason Carson
>> Hello everyone,
>>
>> I am trying to create a PHP login script using cookies but am having
>> some
>> troubles. Here is my setup
>>
>> index.php -> authenticate.php -> admin.php
>>
>> I want a login form on index.php that allows me to login with my
>> username
>> and password and then passes $_POST['username'] and $_POST['password']
>> to
>> authenticate.php
>>
>> Then authenticate.php authenticates against a database of allowed users
>> (Which I already have setup and it works fine), if a valid user has
>> entered the correct information then admin.php is loaded...
>>
>> header("location:admin.php");
>>
>> ...the admin.php code would look something like the following..
>>
>> Code: [Select]
>> > if (isset($_COOKIE['username'])) {
>> echo "success!";
>> } else {
>> echo "Failure";
>> }
>> ?>
>>
>> So basically I think I need to create a cookie from index.php OR
>> authenticate.php and then pass the information to admin.php.
>> I set the cookie like this...
>>
>> setcookie("Admin", $username);
>>
>> Which file(index.php OR authenticate.php) do I create the cookie and how
>> do I access the information in the cookie on admin.php?
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> I finally got it working. I needed to setcookie() in login.php. Also, the
oops, I typed login.php when I meant authenticate.php
> names of the cookies(Using setcookie()) where wrong (The names where
> "Admin" when they should have been "adminuser" and "adminpass") Once I
> fixed that then the following worked in admin.php...
>  if (isset($_COOKIE['adminuser']) && isset($_COOKIE['adminpass'])) {
> echo "Success";
> } else {
> echo "Failed";
> }
> ?>
>



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



Re: [PHP] Simple login form with cookies

2009-07-05 Thread Jason Carson
> On Mon, Jul 6, 2009 at 1:45 AM, Jason Carson wrote:
>>> Hello everyone,
>>>
>>> I am trying to create a PHP login script using cookies but am having
>>> some
>>> troubles. Here is my setup
>>>
>>>     index.php -> authenticate.php -> admin.php
>>>
>>> I want a login form on index.php that allows me to login with my
>>> username
>>> and password and then passes $_POST['username'] and $_POST['password']
>>> to
>>> authenticate.php
>>>
>>> Then authenticate.php authenticates against a database of allowed users
>>> (Which I already have setup and it works fine), if a valid user has
>>> entered the correct information then admin.php is loaded...
>>>
>>> header("location:admin.php");
>>>
>>> ...the admin.php code would look something like the following..
>>>
>>> Code: [Select]
>>> >> if (isset($_COOKIE['username'])) {
>>> echo "success!";
>>> } else {
>>> echo "Failure";
>>> }
>>> ?>
>>>
>>> So basically I think I need to create a cookie from index.php OR
>>> authenticate.php and then pass the information to admin.php.
>>> I set the cookie like this...
>>>
>>> setcookie("Admin", $username);
>>>
>>> Which file(index.php OR authenticate.php) do I create the cookie and
>>> how
>>> do I access the information in the cookie on admin.php?
>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>> I finally got it working. I needed to setcookie() in login.php. Also,
>> the
>> names of the cookies(Using setcookie()) where wrong (The names where
>> "Admin" when they should have been "adminuser" and "adminpass") Once I
>> fixed that then the following worked in admin.php...
>> > if (isset($_COOKIE['adminuser']) && isset($_COOKIE['adminpass'])) {
>> echo "Success";
>> } else {
>> echo "Failed";
>> }
>> ?>
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> You're not storing anything usable in the adminpass cookie, are you?
> It sort of sounds like you're storing a password, or even a passhash,
> in the cookie and you might want to rethink what that cookie contains
> to prevent session hijacking.
>
Yeah, I am storing an unencrypted password in the cookie. Should I encrypt
it, if so how, if not what should I do?

I am new to programming and PHP web development so I am not aware of all
the security problems that can occur.



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



Re: [PHP] Simple login form with cookies

2009-07-05 Thread Jason Carson
> On Mon, Jul 6, 2009 at 2:01 AM, Jason Carson wrote:
>>> On Mon, Jul 6, 2009 at 1:45 AM, Jason Carson
>>> wrote:
>>>>> Hello everyone,
>>>>>
>>>>> I am trying to create a PHP login script using cookies but am having
>>>>> some
>>>>> troubles. Here is my setup
>>>>>
>>>>>     index.php -> authenticate.php -> admin.php
>>>>>
>>>>> I want a login form on index.php that allows me to login with my
>>>>> username
>>>>> and password and then passes $_POST['username'] and
>>>>> $_POST['password']
>>>>> to
>>>>> authenticate.php
>>>>>
>>>>> Then authenticate.php authenticates against a database of allowed
>>>>> users
>>>>> (Which I already have setup and it works fine), if a valid user has
>>>>> entered the correct information then admin.php is loaded...
>>>>>
>>>>> header("location:admin.php");
>>>>>
>>>>> ...the admin.php code would look something like the following..
>>>>>
>>>>> Code: [Select]
>>>>> >>>> if (isset($_COOKIE['username'])) {
>>>>> echo "success!";
>>>>> } else {
>>>>> echo "Failure";
>>>>> }
>>>>> ?>
>>>>>
>>>>> So basically I think I need to create a cookie from index.php OR
>>>>> authenticate.php and then pass the information to admin.php.
>>>>> I set the cookie like this...
>>>>>
>>>>> setcookie("Admin", $username);
>>>>>
>>>>> Which file(index.php OR authenticate.php) do I create the cookie and
>>>>> how
>>>>> do I access the information in the cookie on admin.php?
>>>>>
>>>>>
>>>>> --
>>>>> PHP General Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>
>>>>>
>>>> I finally got it working. I needed to setcookie() in login.php. Also,
>>>> the
>>>> names of the cookies(Using setcookie()) where wrong (The names where
>>>> "Admin" when they should have been "adminuser" and "adminpass") Once I
>>>> fixed that then the following worked in admin.php...
>>>> >>> if (isset($_COOKIE['adminuser']) && isset($_COOKIE['adminpass'])) {
>>>> echo "Success";
>>>> } else {
>>>> echo "Failed";
>>>> }
>>>> ?>
>>>>
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>>
>>> You're not storing anything usable in the adminpass cookie, are you?
>>> It sort of sounds like you're storing a password, or even a passhash,
>>> in the cookie and you might want to rethink what that cookie contains
>>> to prevent session hijacking.
>>>
>> Yeah, I am storing an unencrypted password in the cookie. Should I
>> encrypt
>> it, if so how, if not what should I do?
>>
>> I am new to programming and PHP web development so I am not aware of all
>> the security problems that can occur.
>>
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> That's an enormous question without an easy, or even a correct answer.
>  I'd start by googling around for "session hijacking."  One of the
> things that's probably not PC to say, is don't learn to prevent
> session hijacking, learn to hijack sessions.  Once you know how to
> hijack a session, you can audit your own code and fix the security
> holes.
>
> Although the best advice would probably be to find someone else's
> session implementation and use that, seeing as there's no real reason
> to recreate such a worn-in wheel.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
ok, I have two sets of scripts here. One uses setcookie() for logging into
the admin panel and the other uses session_start(). Both are working fine,
is one more secure than the other?



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



Re: [PHP] Simple login form with cookies

2009-07-06 Thread Jason Carson
> On Mon, Jul 6, 2009 at 02:19, Jason Carson wrote:
>>>
>> ok, I have two sets of scripts here. One uses setcookie() for logging
>> into
>> the admin panel and the other uses session_start(). Both are working
>> fine,
>> is one more secure than the other?
>
> $_COOKIE data is written to a file that is readable/writeable and
> stored on the user's side of things.  $_SESSION data is written to the
> server, with a cookie stored on the user's side containing just the
> PHPSESSID (session ID) string to identify the session file on the
> server.
>
> So determining which is better and/or more secure is really a
> matter of the data held there and how it's handled.  If storing things
> like usernames or you absolutely want to store personal data in an
> active session, do so in $_SESSION.  If you're storing a password or
> credit card number in the active session, you may as well do it in
> $_COOKIE, because you're already using an insecure model.  ;-P
>
> --
> 
> daniel.br...@parasane.net || danbr...@php.net
> http://www.parasane.net/ || http://www.pilotpig.net/
> Check out our great hosting and dedicated server deals at
> http://twitter.com/pilotpig
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Well I'm a newbie when it comes to PHP and programming. I guess I need to
read up on login security. Do you know of, or recommend, any websites that
will show me how to secure my login model (Using cookies or sessions).



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



Re: [PHP] Simple login form with cookies

2009-07-06 Thread Jason Carson
> Jason Carson wrote:
>>> On Mon, Jul 6, 2009 at 02:19, Jason Carson wrote:
>>>
>>>> ok, I have two sets of scripts here. One uses setcookie() for logging
>>>> into
>>>> the admin panel and the other uses session_start(). Both are working
>>>> fine,
>>>> is one more secure than the other?
>>>>
>>> $_COOKIE data is written to a file that is readable/writeable and
>>> stored on the user's side of things.  $_SESSION data is written to the
>>> server, with a cookie stored on the user's side containing just the
>>> PHPSESSID (session ID) string to identify the session file on the
>>> server.
>>>
>>> So determining which is better and/or more secure is really a
>>> matter of the data held there and how it's handled.  If storing things
>>> like usernames or you absolutely want to store personal data in an
>>> active session, do so in $_SESSION.  If you're storing a password or
>>> credit card number in the active session, you may as well do it in
>>> $_COOKIE, because you're already using an insecure model.  ;-P
>>>
>>> --
>>> 
>>> daniel.br...@parasane.net || danbr...@php.net
>>> http://www.parasane.net/ || http://www.pilotpig.net/
>>> Check out our great hosting and dedicated server deals at
>>> http://twitter.com/pilotpig
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>>
>> Well I'm a newbie when it comes to PHP and programming. I guess I need
>> to
>> read up on login security. Do you know of, or recommend, any websites
>> that
>> will show me how to secure my login model (Using cookies or sessions).
>>
>>
> Hi Jason,
> I'm probably not any wiser than you, but I have just (today) discovered
> an interesting site that seems to have some really clear explanations
> and tutorials re php, MySsql et al.
> It's worth looking at (I'm trying to implement something like what you
> are, as well):
> http://www.brainbell.com/tutors/php/php_mysql/Authorizing_User_Access.html
> HTH,
> PJ
>
> --
> Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
> -
> Phil Jourdan --- p...@ptahhotep.com
>http://www.ptahhotep.com
>http://www.chiccantine.com/andypantry.php
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I'll check it out this evening when I have some time. Thanks for the link.


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



Re: Re: [PHP] Simple login form with cookies

2009-07-08 Thread Jason Carson
>
> The basic model for password authentication is to use one way crypt
> routines. MySql has several, PHP also has them. The basic algorithm
> would be like this:
>
> 1) read the password from the form.
> 2) read the password from you datastore that matches the user name or
> session
> 3) encrypt the password on the form.
> 4) do a string comparison between the database data and the encrypted
> password from the form.
>
> This is of course assumes that you have been encrypting your password
> when you store them (always good practice) so I think this translates to
> php as (forgive me if this is bogus, it's been a while since I've done
> any php)
>
>  $salt = 'someglobalsaltstring'; # the salt should be the same salt used
> when storing passwords to your database otherwise it won't work
> $passwd = crypt($_GET['passwd'], $salt);
> if ($passwd == $userObject->getPassword) { return 1} else {return 0}
> ?>
>
> So I've not tested this obviously but you would have to have a
> $userObject which is your interface between your software and your user
> data.
>
> Hope it helps,
> Carl.
>

I am encrypting the stored password with SHA1.

I am new to programming and PHP so I am unsure what to do with this line
$userObject->getPassword



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



[PHP] A prepared statements question

2009-07-11 Thread Jason Carson
Hello everyone,

I am having a problem getting my prepared statements working. Here is my
setup...

index.php -> authenticate.php -> admin.php

1)index.php has a login form on it so when someone enters their username
the form redirects to another page I call authenticate.php.

2)In the authenticate.php file I want to use prepared statements to
interact with the MySQL database. I want to compare the username submitted
from the form with the username in the database.

3)If the login username was legitimate then you are forwarded to admin.php

Its step 2 I am having problems with. Here is what I have but I don't
think it makes any sense and it doesn't work.


$link = mysqli_connect($hostname, $dbusername, $password, $database);
$stmt = mysqli_prepare($link, "SELECT * FROM administrators WHERE
adminusers=?");
mysqli_stmt_bind_param($stmt, 's', $username);
$result = mysqli_stmt_execute($stmt);

$count=mysqli_num_rows($result);

if($count==1){
header("location:admin.php");
} else {
echo "Failure";
}

Any help is appreciated.


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



Re: [PHP] A prepared statements question

2009-07-12 Thread Jason Carson
> Hello everyone,
>
> I am having a problem getting my prepared statements working. Here is my
> setup...
>
> index.php -> authenticate.php -> admin.php
>
> 1)index.php has a login form on it so when someone enters their username
> the form redirects to another page I call authenticate.php.
>
> 2)In the authenticate.php file I want to use prepared statements to
> interact with the MySQL database. I want to compare the username submitted
> from the form with the username in the database.
>
> 3)If the login username was legitimate then you are forwarded to admin.php
>
> Its step 2 I am having problems with. Here is what I have but I don't
> think it makes any sense and it doesn't work.
>
>
> $link = mysqli_connect($hostname, $dbusername, $password, $database);
> $stmt = mysqli_prepare($link, "SELECT * FROM administrators WHERE
> adminusers=?");
> mysqli_stmt_bind_param($stmt, 's', $username);
> $result = mysqli_stmt_execute($stmt);
>
> $count=mysqli_num_rows($result);
>
> if($count==1){
> header("location:admin.php");
> } else {
> echo "Failure";
> }
>
> Any help is appreciated.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
For anyone reading this thread, here is the final code that I used...

$link = mysqli_connect($hostname, $username, $password, $database);
$stmt = mysqli_prepare($link, "SELECT * FROM administrators WHERE
adminusers=?);
mysqli_stmt_bind_param($stmt, "s", $adminuser);
mysqli_stmt_execute($stmt);
mysqli_stmt_store_result($stmt);
$count = mysqli_stmt_num_rows($stmt);

if($count==1){
header("location:admin.php");
} else {
echo "Failure";
}


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



[PHP] A form and an array

2009-07-23 Thread Jason Carson
Hello everyone,

Lets say I have a file called form.php with the following form on it that
redirects to index.php when submitted. I would like to take the values of
the text fields in the form and put them into an array, then be able to
display the values in that array on index.php Does anyone know how I would
do that?

Here is my form...



  
Option1

  
  
Option2

  
  


  





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



Re: [PHP] Re: A form and an array

2009-07-23 Thread Jason Carson
> Jason Carson wrote:
>
>> Hello everyone,
>>
>> Lets say I have a file called form.php with the following form on it
>> that
>> redirects to index.php when submitted. I would like to take the values
>> of
>> the text fields in the form and put them into an array, then be able to
>> display the values in that array on index.php Does anyone know how I
>> would
>> do that?
>>
>> Here is my form...
>>
>> 
>> 
>>   
>> Option1
>> 
>>   
>>   
>> Option2
>> 
>>   
>>   
>> 
>> 
>>   
>> 
>> 
>
> You'll find they are already in an array which you can access as
> $_POST['option'] - from there foreach() should be the next step.
>
>
> Cheers
> --
> David Robley
>
> Polls show that 9 out of 6 schizophrenics agree.
> Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I am new to programming. How would I use foreach()to display the entries
in the array?



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



Re: [PHP] Re: A form and an array

2009-07-23 Thread Jason Carson
> Jason Carson wrote:
>
>>> Jason Carson wrote:
>>>
>>>> Hello everyone,
>>>>
>>>> Lets say I have a file called form.php with the following form on it
>>>> that
>>>> redirects to index.php when submitted. I would like to take the values
>>>> of
>>>> the text fields in the form and put them into an array, then be able
>>>> to
>>>> display the values in that array on index.php Does anyone know how I
>>>> would
>>>> do that?
>>>>
>>>> Here is my form...
>>>>
>>>> 
>>>> 
>>>>   
>>>> Option1
>>>> 
>>>>   
>>>>   
>>>> Option2
>>>> 
>>>>   
>>>>   
>>>> 
>>>> 
>>>>   
>>>> 
>>>> 
>>>
>>> You'll find they are already in an array which you can access as
>>> $_POST['option'] - from there foreach() should be the next step.
>>>
>>>
>>> Cheers
>>> --
>>> David Robley
>>>
>>> Polls show that 9 out of 6 schizophrenics agree.
>>> Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
>>>
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>> I am new to programming. How would I use foreach()to display the entries
>> in the array?
>
> You could read TFM which has an example -
> http://php.net/manual/en/control-structures.foreach.php
>
>
> Cheers
> --
> David Robley
>
> Why are you wasting time reading taglines?
> Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
What I currently have is...

foreach ($_POST['option'] as $value) {
echo "Value: $value\n";
}

...but that doesn't work. TFM didn't help me :-(


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



RE: [PHP] Re: A form and an array

2009-07-23 Thread Jason Carson
Yes

> Did you correct the missing double quote in your sending form first?
>
> Warren Vail
>
> -Original Message-
> From: Jason Carson [mailto:ja...@jasoncarson.ca]
> Sent: Thursday, July 23, 2009 9:33 PM
> To: php-general@lists.php.net
> Subject: Re: [PHP] Re: A form and an array
>
>> Jason Carson wrote:
>>
>>>> Jason Carson wrote:
>>>>
>>>>> Hello everyone,
>>>>>
>>>>> Lets say I have a file called form.php with the following form on it
>>>>> that
>>>>> redirects to index.php when submitted. I would like to take the
>>>>> values
>>>>> of
>>>>> the text fields in the form and put them into an array, then be able
>>>>> to
>>>>> display the values in that array on index.php Does anyone know how I
>>>>> would
>>>>> do that?
>>>>>
>>>>> Here is my form...
>>>>>
>>>>> 
>>>>> 
>>>>>   
>>>>> Option1
>>>>> 
>>>>>   
>>>>>   
>>>>> Option2
>>>>> 
>>>>>   
>>>>>   
>>>>> 
>>>>> 
>>>>>   
>>>>> 
>>>>> 
>>>>
>>>> You'll find they are already in an array which you can access as
>>>> $_POST['option'] - from there foreach() should be the next step.
>>>>
>>>>
>>>> Cheers
>>>> --
>>>> David Robley
>>>>
>>>> Polls show that 9 out of 6 schizophrenics agree.
>>>> Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
>>>>
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>
>>>>
>>> I am new to programming. How would I use foreach()to display the
>>> entries
>>> in the array?
>>
>> You could read TFM which has an example -
>> http://php.net/manual/en/control-structures.foreach.php
>>
>>
>> Cheers
>> --
>> David Robley
>>
>> Why are you wasting time reading taglines?
>> Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> What I currently have is...
>
> foreach ($_POST['option'] as $value) {
> echo "Value: $value\n";
> }
>
> ...but that doesn't work. TFM didn't help me :-(
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



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



Re: [PHP] Re: A form and an array

2009-07-23 Thread Jason Carson
I have it working now. I had a comma where a semicolon should have been.

Silly error on my part but thanks to everyone who tried to help me.

> In php.ini turn the "display_errors" to "on".
> If any error,warn or notice shown,copy them and paste here.
> So you can tell us what doesn't work.
>
> good luck~
>
> 2009/7/24 Jason Carson 
>
>> > Jason Carson wrote:
>> >
>> >>> Jason Carson wrote:
>> >>>
>> >>>> Hello everyone,
>> >>>>
>> >>>> Lets say I have a file called form.php with the following form on
>> it
>> >>>> that
>> >>>> redirects to index.php when submitted. I would like to take the
>> values
>> >>>> of
>> >>>> the text fields in the form and put them into an array, then be
>> able
>> >>>> to
>> >>>> display the values in that array on index.php Does anyone know how
>> I
>> >>>> would
>> >>>> do that?
>> >>>>
>> >>>> Here is my form...
>> >>>>
>> >>>> 
>> >>>> 
>> >>>>   
>> >>>> Option1
>> >>>> 
>> >>>>   
>> >>>>   
>> >>>> Option2
>> >>>> 
>> >>>>   
>> >>>>   
>> >>>> 
>> >>>> 
>> >>>>   
>> >>>> 
>> >>>> 
>> >>>
>> >>> You'll find they are already in an array which you can access as
>> >>> $_POST['option'] - from there foreach() should be the next step.
>> >>>
>> >>>
>> >>> Cheers
>> >>> --
>> >>> David Robley
>> >>>
>> >>> Polls show that 9 out of 6 schizophrenics agree.
>> >>> Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
>> >>>
>> >>>
>> >>> --
>> >>> PHP General Mailing List (http://www.php.net/)
>> >>> To unsubscribe, visit: http://www.php.net/unsub.php
>> >>>
>> >>>
>> >> I am new to programming. How would I use foreach()to display the
>> entries
>> >> in the array?
>> >
>> > You could read TFM which has an example -
>> > http://php.net/manual/en/control-structures.foreach.php
>> >
>> >
>> > Cheers
>> > --
>> > David Robley
>> >
>> > Why are you wasting time reading taglines?
>> > Today is Setting Orange, the 59th day of Confusion in the YOLD 3175.
>> >
>> >
>> > --
>> > PHP General Mailing List (http://www.php.net/)
>> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >
>> >
>> What I currently have is...
>>
>> foreach ($_POST['option'] as $value) {
>>echo "Value: $value\n";
>> }
>>
>> ...but that doesn't work. TFM didn't help me :-(
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>



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