The Mac Observer

 
   
 
Need some help with PHP
Posted: 04 May 2002 11:00 AM [ Ignore ]
stars_3
Avatar
Total Posts:  396
Joined  2002-03-22

I stated to learn PHP. I really like it but now I have a problem:
With this code I make a html form. 

<html>
<head><title>Test</title>
</head>
<body>
<form action=“act.php” method=“GET”>
<input type=“text” name=“name” value=“Name”>


<textarea name=“email” rows=“1” cols=“40”>eMail</textarea>


<input type=“submit” value=“Click me”>


</form>
</body>
</html>

If the person clicks on the button he comes to the act.php site. Here is the code for it:


<html>
<head>
<title></title>
</head>
<body>
<?php
print “Welcome $name\n\n”;
print “Your eMail is: $email”;
?>
</body>
</html>

When I want to view it with my browser it only says:


Welcome

Your eMail is:

Is that normal because in my book, I am learning from it doesn’t say what the browser should show.
frown
_______________

Sorry for the spelling mistakes my English is not very good(if I made some)

 Signature 

Those signatures are great.

Profile
 
 
Posted: 04 May 2002 11:31 AM [ Ignore ] [ # 1 ]
stars_5
Avatar
Total Posts:  1442
Joined  2001-06-11

Let me preface this by saying that I don’t know PHP, so take this with a rather large grain of salt. wink

Based upon the information here, I would guess that you either need to code your act.php file as:

<html>
<
head>
<
title></title>
</
head>
<
body>
<?php
print "Welcome <b>$HTTP_POST_VARS['name']</b><p>\n\n";
print 
"Your eMail is: <b>$HTTP_POST_VARS['email']</b>";
?>
</body>
</
html

... or the register_globals needs to be set to true in your server’s php.ini file to have your existing code work properly.

 Signature 

Rob

widgets :: music :: photos :: twitter

Profile
 
 
Posted: 04 May 2002 11:16 PM [ Ignore ] [ # 2 ]
stars_3
Avatar
Total Posts:  396
Joined  2002-03-22

... or the register_globals needs to be set to true in your server’s php.ini file to have your existing code work properly.

OK thanks, but how do I register the globals and shouldn’t they already be registered?
And yes, this code:

[color=darkblue]
<?php 
print "Welcome <b>$HTTP_POST_VARS['name']</b><p>\n\n"
print 
"Your eMail is: <b>$HTTP_POST_VARS['email']</b>"
?> 
[
/color] 

Can somebody who has PHP installed on his mac test this please, because maby I need to install my PHP again.
______________
I am sorry for the spelling mistakes (if I made some)

 Signature 

Those signatures are great.

Profile
 
 
Posted: 05 May 2002 03:32 AM [ Ignore ] [ # 3 ]
Administrator
Avatar
Total Posts:  391
Joined  2001-06-11

To be honest, I don’t have PHP installed on my Mac, but we do have it installed on the TMO server, of course, and I tested your scripts here.  They work fine, of course, and generate the output that you would imagine.  We do have register_globals enabled, though, so that’s likely it:

You’ll want to set this on in your php.ini file (check http://www.php.net/manual/fi/html/configuration.html and http://www.php.net/manual/fi/html/configuration.html#ini.register-globals) for information on how to do this.  You’ll likely need to restart your web server once you make this change, and then all will be well.

One thing I noticed—they have you using “GET” as your post method.  GET sends the variables in with the requesting URL, and it can get messy (especially if users cache the data and accidentally come back to it).  A better way is to use POST as your method (method=“POST”).  THis sends them in the header of the users’ requests, and makes it a lot cleaner.

-Dave

 Signature 

-Dave Hamilton / The Mac Observer / Mac Geek Gab / Dave on Twitter

Profile
 
 
Posted: 05 May 2002 09:44 AM [ Ignore ] [ # 4 ]
stars_3
Avatar
Total Posts:  396
Joined  2002-03-22

Mhm, OK, have another problem which is that I can’t find the php.ini on my Mac. I searched with Sherlock but nothing like that was found and neither I was able to find it.
confused
So, mhm. Ok, I am not (yet) very good with stuff like that on Mac.
Does anybody has any ideas or I am just to unable (<= I don’t know if you can say this like that in English, but let’s hope so) for that?

 Signature 

Those signatures are great.

Profile
 
 
Posted: 06 May 2002 09:40 AM [ Ignore ] [ # 5 ]
stars_3
Avatar
Total Posts:  396
Joined  2002-03-22

So, I still didn’t fix the stupid globals thing.
evil
But I found out some stuff and have a few more questions:

<?php
phpinfo
()
?> 

So this code up there list my much information about the php which is installed on my Computer and it says somewhere, wait let my copy, OK:
Configuration File (php.ini) Path   /usr/local/lib
The stupid thing is that I cant find the usr/local/lib (=does this actually stand for user/local/Library. If so it’s bad because the php.ini is not there). I need to know where I can acctually find this php.ini because on an other line from the phpinfo thing it says:

Directive: register_globals    
Local Value: Off              
Master Value: Off

I thing these two Off things should be on On. Or?
Please I need help, I want to read on in my book. You may now thing Johannes is so dum, why doesn’t he just check in his book how to do this. I am not checking in my book because this nice people didn’t write how to do it on a mac.
evil

 Signature 

Those signatures are great.

Profile
 
 
   
 
 

Apple Stock Quote (AAPL)

Loading...

Hot Topics

TMO Express

Join the TMO Express Daily Newsletter to get the latest Mac headlines in your e-mail every weekday. Find out more!

Top Deals From DealBrothers.com

Recent Features

Support The Mac Observer

We noticed you may be running AdBlock on your computer. It takes real money to run this site and to deliver the news, tips, and opinions you love to read.

If you wish to block the ads that pay for the creation of our content, we ask that you instead support TMO Directly, either with a $5 monthly recurring contribution, or a one-time donation of any amount of your choice. Thanks!

Subscribe with Paypal Donate with Paypal