PHP help for a newbie..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Nydark
Forum Newbie
Posts: 1
Joined: Wed May 22, 2002 12:41 pm
Location: Minden, NV
Contact:

PHP help for a newbie..

Post by Nydark »

Alright.. I am a PHP newbie. I don't know much about it. =) What im trying to do is have a form be submited by PHP when "send" is clicked. What do I need to do? How is this possible? Is it possible? Right now I use Yahoo's Web Hosting Service.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

the child-Elements of a form may have a name-property ( <input type="text" name="text1" /> ).
When the form is submitted all name/values-pairs of those elements will be sent to the webserver using the format according to the method/enctype - property of the form-element.
i.e.

Code: Select all

<form method="get">
   <input type="hidden" name="itemId" value="8765" />
   <input type="text" name="comment"  />
   <input type="radio" name="rating" value="nice" />
   <input type="radio" name="rating" value="fair" />
   <input type="radio" name="rating" value="bad" />
   <input type="submit" />
</form>
when this form is submitted,
- itemId (=8765)
- comment (=what ever the user wrote into the field)
- rating (= the value of the radio-button the user chose)
will be sent
The method of the form-action is 'get'. So in your php-script the parameters will be accessable through the superglobal array $_GET ( $_GET['itemId'], $_GET['comment'] & $_GET['rating'] )
if method would've been 'post' they had been stored in the $_POST array.
$_REQUEST contains all the parameter wether they were sent by 'get' or 'post'
You may also name the submit-button (<input type="submit" name="submit" value="itemDesc">) to identify the form-request

Code: Select all

...if (array_key_exists('submit', $_REQUEST))
   handleRequest();
else
   printForm();
...
these arrays have been introduced with php 4.1. If you're using an older version take a look at the notes in the reference
MattF
Forum Contributor
Posts: 225
Joined: Sun May 19, 2002 9:58 am
Location: Sussex, UK

Post by MattF »

I don't know if Yahoo Web Hosting supports PHP. They may only have a couple of ready made scripts. I suggest you get "proper" hosting from somewhere like tera-byte.com (not an advert) or something because they are probably cheaper and are likely to have more features.
MacDaddy
Forum Newbie
Posts: 12
Joined: Sun May 05, 2002 9:36 pm
Location: Atlanta, GA

Post by MacDaddy »

personally, I like Sevaa.com they have great support :)
Dai
Forum Newbie
Posts: 16
Joined: Wed May 15, 2002 6:12 am

Post by Dai »

if ypur looking forfree space with php and mysql try http://www.tripod.lycos.co.uk/ they now do php and mysql and they have a very similar set up to yahoo.
Post Reply