Sublime directory Surf the web anonymous Pagerank Monitor


Newbie to php; help with what the different fields mean

Llally
Wed 21 February 2007, 06:47 am GMT +0100
Okay, I really need quite a bit of help -- this is my first ever attempt at a form (much less a php form!)....

I read some other help topics.  I found examples of code.  I am really trying to figure out what the particular values mean.  This is what I have so far:

<?php
echo '<form method="get" action="' . $_SERVER['PHP_SELF'] . '">
<table border="0">
<tr>
<td>User name:</td>
<td><input type="text" name="User name"></td>
</tr>
</table>
<hr>
<b>Amount of sleep:</b><br>
<table border="0" cellspacing="10px">
<td><input type="radio" name="> 10 hours" value="Print_W"> >10 hours</td>
<td><input type="radio" name="8 to 10 hours" value="Web_WO"> 8 to 10 hours</td>
<td><input type="radio" name="6 to 8 hours" value="Print_W"> 6 to 8 hours</td>
<td><input type="radio" name="4 to 6 hours" value="Web_WO"> 4 to 6 hours</td>
<td><input type="radio" name="2 to 4 hours" value="Print_W"> 2 to 4 hours</td>
<td><input type="radio" name="Less than hours" value="Web_WO"> Less than 2 hours</td>
</tr>
</table>


For example, echo '<form method="get" action="' . $_SERVER['PHP_SELF'] is part of the code example I was using.  Could someone please tell me what that exactly means so I can make sure I am using the correct values?

Also, in the radio buttons coding, first you enter a name, then value, and then from what I can understand, the last field is how it will display?  What exactly does the value mean?  (again, that's from example code)  Should the name and the display text be the same?

I'm sorry I'm so clueless.  Don't be afraid to talk to me as if I were the village idiot.  I just really want to learn! Any help would be GREATLY appreciated.

Thanks a ton!

Nikolas
Wed 21 February 2007, 08:16 am GMT +0100
First of all, welcome aboard ;)

I will try to answer some of your questions :

Quote
For example, echo '<form method="get" action="' . $_SERVER['PHP_SELF'] is part of the code example I was using.  Could someone please tell me what that exactly means so I can make sure I am using the correct values?

From the manual :

The filename of the currently executing script, relative to the document root. For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar  would be /test.php/foo.bar. The __FILE__  constant contains the full path and filename of the current (i.e. included) file.

If PHP is running as a command-line processor this variable contains the script name since PHP 4.3.0. Previously it was not available.

Quote
Also, in the radio buttons coding, first you enter a name, then value, and then from what I can understand, the last field is how it will display?  What exactly does the value mean?  (again, that's from example code)  Should the name and the display text be the same?

Name is the name of the $_GET value, value is the value that this variable will get if you select this radio button, and the last is what you will display. The name and the display text can be different.

BTW check also this thread :

http://www.webdigity.com/index.php/topic,5992.0.PHP+forms+-+a+few+questions.html

Llally
Wed 21 February 2007, 08:32 am GMT +0100
Nikolas!  So nice to see someone responding so fast! 

So, I've just been blindly writing this php form flying by the seat of my pants hoping someone would respond!  Thank you for the reply.

If only you had some idea how much learning I have to do from you all!  :)

Next set of questions:  I was setting up the new table after setting up the database for this form.  It was asking me all SORTS of things I had no clue what to put.  The fields read as follows:
Field  TypeDocumentation  Length/Values*  Attributes  Null  Default**  Extra

Could someone help me out with what to put in these?  I've never had to set up a table in MySQL before.

In the above reply, you said 'value' is the value that this variable will get if you select this radio button.  Does that mean that in my table there must be a field/value for each value on my form?

I know this is most certainly remedial stuff for you guys but I really appreciate any 'schooling you can give me.

Thanks!

Nikolas
Wed 21 February 2007, 09:33 am GMT +0100
I don't want to disappoint you but mySql is not something that you can learn from forums. Even if we help you somehow - which I don't think is so possible - you would end up with a very slow and security problematic application.

I would suggest you to look for a book regarding mysql.

Until then use something more automated, a CMS/blog system or something that gives you the ability to do what you want without writing much code.

Archive for SMF v1.00 by N.P. Valid XHTML 1.0 Transitional