View previous topic :: View next topic |
Author |
Message |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Thu Jun 03, 2004 9:20 pm Post subject: Just a little PHP help for a begainer |
|
|
I have two programs running here one being html and it is refering to the php. I aam not having any problems with the html but I cannot get the php to work like I want it to. What I am trying to do here is to take the number from the html and pick out the month that coensides with the number but it will not work for me. I have eather miss read something or just not read far enough in the book to be doing what I am wanting it to do. Can someone help me with figureing this out?
<html>
<title>Months</title>
<body>
<form action="monthnew.php" method="post">
<p> Please enter an number between 1 and 12
<input type="text" size=3 name="$num" ></p>
<input type="submit" name="Enter" />
</body>
</html>
<?php
$monthName = array(1=>"January", "February", "March", "April",
"May", "June", "July", "August", "September", "October", "November",
"December");
print("Month, $num is $monthName[$num]<br>\n");
?> |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Thu Jun 03, 2004 9:28 pm Post subject: |
|
|
When adding a HTML Form , you don't need to
add the $ sign in front on num like $num , just
use num as the name and everything should work
Code: | <input type="text" size=3 name="num" > |
|
|
Back to top |
|
 |
eznetlinks -
Joined: 27 Sep 2003 Posts: 144
|
Posted: Thu Jun 03, 2004 10:02 pm Post subject: |
|
|
This worked for me after setting register_globals=on in C:\WINDOWS\php.ini .
<html>
<title>Months</title>
<body>
<form action="monthnew.php" method="post">
<p> Please enter an number between 1 and 12
<input type="text" size=3 name="num" ></p>
<input type="submit" name="Enter" />
</body>
</html>
<?php
$monthName = array("None", "January", "February", "March", "April",
"May", "June", "July", "August", "September", "October", "November",
"December");
print("Month, $num is $monthName[$num]<br>\n");
?> |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Fri Jun 04, 2004 12:09 am Post subject: |
|
|
Try to use the new naming convention ($_POST['num']) so you can keep globals off; or is there something else besides the form that needs globals? _________________ Bienvenidos! |
|
Back to top |
 |
 |
cwdlmdd -
Joined: 06 May 2004 Posts: 32 Location: st peters mo
|
Posted: Sat Jun 05, 2004 4:13 am Post subject: php help |
|
|
Thanks for the help!! I guess I wasn't as far off as I thought I was. Once I made the change in the php.ini globle setting it seemed to work. Now I will try changing it and using the $_POST and see if I can get that to work!! |
|
Back to top |
|
 |
|