Page 1 of 1

PHP help for a newbie..

Posted: Wed May 22, 2002 12:41 pm
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.

Posted: Wed May 22, 2002 1:09 pm
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

Posted: Wed May 22, 2002 1:45 pm
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.

Posted: Wed May 22, 2002 8:00 pm
by MacDaddy
personally, I like Sevaa.com they have great support :)

Posted: Thu May 23, 2002 4:37 am
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.