Just a little PHP help for a begainer

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
cwdlmdd
-


Joined: 06 May 2004
Posts: 32
Location: st peters mo

PostPosted: Thu Jun 03, 2004 9:20 pm    Post subject: Just a little PHP help for a begainer Reply with quote

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 View user's profile Send private message Visit poster's website
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Thu Jun 03, 2004 9:28 pm    Post subject: Reply with quote

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 View user's profile Send private message Visit poster's website
eznetlinks
-


Joined: 27 Sep 2003
Posts: 144

PostPosted: Thu Jun 03, 2004 10:02 pm    Post subject: Reply with quote

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 View user's profile Send private message Visit poster's website
iNaNimAtE
-


Joined: 05 Nov 2003
Posts: 2381
Location: Everywhere you're not.

PostPosted: Fri Jun 04, 2004 12:09 am    Post subject: Reply with quote

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 View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
cwdlmdd
-


Joined: 06 May 2004
Posts: 32
Location: st peters mo

PostPosted: Sat Jun 05, 2004 4:13 am    Post subject: php help Reply with quote

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 View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group