PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 2nd, 1999, 02:32 PM
luisf
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Is there an array in PHP that keeps all the variables that the user entered in the form, like $name, $email, etc?

The purpose is: send an email to the webmaster saying:

$name: John Richard
$email: john@richard.com

So, if I chance the name of the variables, or if I add another variable in the form.. it works..


Thanks
Luís

Reply With Quote
  #2  
Old December 8th, 1999, 09:24 AM
Hans
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I don't know what your problem is, but form data allready gets passed to the result page in subsequent variables.

So if you build a form like this

<form method="POST" action="result.php" name="mailform">
Name:<input type="text" size="30" name="frm_name"><br>
Email:<input type="text" size="30" name="frm_email"><br>
<input type="submit">
</form>

And you would submit this form with John Richard as Name and john@richard.com as email, the variables $frm_name and $frm_email contain the data entered in the form, in this case:

$frm_name="John Richard" $frm_email="john@richard.com"




[This message has been edited by Hans (edited 12-08-99).]

Reply With Quote
  #3  
Old December 8th, 1999, 10:15 AM
luisf
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I need an array that keeps all the names and values of the form.

So, I don't need to know all the variable names to send the e-mail, because I'll have all the form field values in this array..

In perl, I would get the string "?name=value&name2=value", split and put it in an array..

How can I do it in PHP??

Thanks
luis

Reply With Quote
  #4  
Old December 8th, 1999, 10:26 AM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Check the manual for $PHP_POST_VARS

Reply With Quote
  #5  
Old December 8th, 1999, 09:47 PM
Darguz
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Actually, it's $HTTP_POST_VARS if your form uses the POST method, $HTTP_GET_VARS for the GET method.


--
Alan Little
Holotech Web Design
http://www.holotech.net/

[This message has been edited by Darguz (edited 12-08-99).]

Reply With Quote
  #6  
Old December 9th, 1999, 09:51 AM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Thanks, Alan. Can blame my memory on all the cough medicine URL

Hey, I knew what I /meant/ to write....

Reply With Quote
  #7  
Old December 9th, 1999, 12:46 PM
luisf
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
So..

I put the command

<? print "$HTTP_POST_VARS - $HTTP_GET_VARS"; ?>

and it prints

Array - Array


So.. I think these stuff is not available in my ISP... or am I doing something wrong?

Reply With Quote
  #8  
Old December 9th, 1999, 01:09 PM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
No, that's what you should get :0

$HTTP_POST_VARS (and GET) are arrays. They contain in data passed by POST and GET methods respectively, with the name/value pairs as the index and data respectively.

For example, if you pass the query string ?this=that&those=these
then $HTTP_GET_VARS[this] would contain the value "that" and $HTTP_GET_VARS[those] would contain the value "these"

Alternately, if you use a form you would use $HTTP_POST_VARS instead. In your application, all you would need to do is to use EACH across the $HTTP_POST_VARS array to get the keys (since you say you want to be able to change the form.)

HTH

Rod

Reply With Quote
  #9  
Old December 9th, 1999, 07:11 PM
Darguz
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
$HTTP_POST_VARS and $HTTP_GET_VARS are associative arrays (see the documentation for a description), containing the field names and values passed from your form. Use the each() construct to walk through them:

while(list($var, $val) = each($HTTP_POST_VARS)) {
[do stuff]
}

On each iteration of the loop, $var and $val will have the name and value, respectively, of a field in your form.

------------------
Alan Little
Holotech Web Design
www.holotech.net/


[This message has been edited by Darguz (edited 12-09-99).]

[This message has been edited by Darguz (edited 12-09-99).]

Reply With Quote
  #10  
Old December 10th, 1999, 08:55 AM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Isn't that what I said URL

Reply With Quote
  #11  
Old December 15th, 1999, 07:06 AM
PAV
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
But what if you get another array inside the form from, for example, multiple checkboxes/selects within a group?
That gets a bit more complicated when only using HTTP_POST_VARS.
Why not just catch all the variables (by name) on a reload (after submit) of the page on which you then also perform a mail() function and clear up the form again.
I have good experience with that. Anyone any other ideas?

Regards, Peter

Reply With Quote
  #12  
Old December 15th, 1999, 08:03 AM
rod k
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
PAV,

You make good points. In fact, that is exactly what I do.

However, go back and read the original question. He wants to be able to add a field to the form without modifying the action script. To do that you have to have your form in an array, either one he creates or $HTTP_POST_VARS.

I don't mean this as a flame, but I've read many posts from you recently, and you give good advice except that your responses seem to not take into account special needs as defined by the person posting the question.

The way you have solved a problem is not always the BEST way for everyone.

Reply With Quote
  #13  
Old December 15th, 1999, 09:58 AM
PAV
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I'm sorry if that's the impression I made, it was surely not my intention to do so...

But isn't this still a discussion forum? URL

Reply With Quote
  #14  
Old December 15th, 1999, 10:49 AM
luisf
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Thanks guys!

Now.. that worked.. you're the best. Now, I don't know if I dedicate myself to ASP or to PHP.

But.. it's subject for another discussion..

Thanks
Luís

Reply With Quote
  #15  
Old December 15th, 1999, 12:10 PM
SneakyDave
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Maybe this won't work with what you want to do, but you could NAME all your input fields something like FIELD[], which will store all the form fields into the array FIELD, and can be accessed with a for loop like:

for($x=0;$x<$count($FIELD);$x++)
{
do stuff for each $FIELD[$x]
}

You wouldn't know what each value was for though, is the only problem.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP3 and the HTML Form

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap