image
image

Go Back   macosx.com > Design, Media, Programming & Scripting > Software Programming & Web Scripting

Reply
 
Thread Tools
  #1  
Old December 15th, 2005, 04:59 AM
Registered User
 
Join Date: Dec 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Valery1 is on a distinguished road
Angry php woild not pass values

Hello,everybody!
I installed MAMP om my Mac ( running MACOSX 10.3.9),it works ok,but php 5.0 would not pass values.
In case of values to go from a form to php page for processing I am totally lost.IT IS a deadlock. Values entered do not stay.

Page 1.
<html>
<head>
<title>hello</title>

</head>
<body>
<center>

<form method = "post"
action = "process.php">
<h1> please enter your name:</h1>
<input type = "text"
name = "userName"
value = "">
<br>
<input type = "submit">

</center>
</body>
</html>

So here I input something and go to

Page2 (process.php)

<html>
<head>
<title>hello</title>

</head>
<body>
<center>
<h1>Greeting</h1>
<?
print "<h2>Hello,$userName!</h2>";
?>

</center>
</body>
</html>
The result is "Hello,!"
- and no nothing, the name entered in page 1 in gets kicked.
Maybe someone knows what is wrong.
Thanks.
Valery.

Last edited by Valery1; December 16th, 2005 at 01:00 AM.
Reply With Quote
  #2  
Old December 16th, 2005, 07:37 AM
Registered User
 
Join Date: Sep 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
cmcdonal1 is on a distinguished road
your page doesn't know where to get $username from. use something like $userName = $_POST['userName'];
Reply With Quote
  #3  
Old December 16th, 2005, 07:38 AM
Registered User
 
Join Date: Sep 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
cmcdonal1 is on a distinguished road
FYI... the code above needs to be on the recieving page and declared before your print statement
Reply With Quote
  #4  
Old December 17th, 2005, 06:07 PM
Registered User
 
Join Date: Dec 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Valery1 is on a distinguished road
Cmcdonal1, HURRAH. You are helpful. Because your tip helped. Now the pages happily communicate.
You know what? For me this is half of the puzzle.
The school book I have says as HTML page with a form in it goes to PHP page for processing , PHP automatically turns all elements of the form into variables.So in our case userName is turned into $userName. And the value entered in userName is supposed to stay in $userName.
AND IT DOES.If we test the above pages on PC. Everything works fine on my PC with W2K on it.
Whereas on Mac variable userName needs to be specified twice:PHP does it by default, then you enhance with $userName = $_POST['userName'];
And if you don't,it does not work.
Reply With Quote
  #5  
Old December 17th, 2005, 11:25 PM
Captain Code's Avatar
Moderator
 
Join Date: Aug 2001
Location: Ontario, Canada
Posts: 3,108
Thanks: 0
Thanked 1 Time in 1 Post
Captain Code will become famous soon enough
The newer versions of PHP disabled the direct $varname access to POST variables for security reasons.
__________________
MacBook Pro 2.16GHz Core2Duo 3GB RAM, G4 1.4GHz OSX Tiger 1.25GB RAM, Dual 2GHz G5 OSX Tiger 2GB RAM (freakin shweet)
Athlon 64 Windoze XP for school work (programming) 1GB RAM
dferns@macosx.com
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 05:12 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.