Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > PHP
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help.

Google
Reply
 
LinkBack Thread Tools Display Modes
Old 07-01-2007, 3:58 PM   #1
Jan V.Pedersen
 
Jan V.Pedersen's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Variables

Hi!

I am a pre-newbie in PHP, and I'm writing my first script. I have
innstalled phpdev 423, and started Apache, php, mysql and all. I use
Dreamwiever MX for my "writing" I have bought a book (PHP for web
professionals, Crhistopher Cosentino), and I just type one of the first,
simple script. But I can't get the results of my variables to show up in
the browser. Here is what I do:

FILE 1: form_entry:
<html>
<head>
<title>Legge informasjon i et skjema</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<form action="form_results.php3" method="get">
<p>First name: <input type="text" name="first_name">
<br>Last name: <input type="text" name="last_name">
<br>Address: <input type="text" name="address">
<br>City: <input type="text" name="city">
<br>State: <input type="text" name="state">
<br>Zip: <input type="text" name="zip">
<br>Home phone: <input type="text" name="home_phone">
<p><input type="submit" name="Submit">
<input type="reset">
</form>
</body>
</html>


FILE 2: form_results.php3
<html>
<head>
<title>Skjema</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<h2>Here is what you typed</h2>
<?php
print ("<p>First Name: <b>$first_name</b>\n");
print ("<br>Last Name: <b>$last_name</b>\n");
print ("<br>Address: <b>$address</b>\n");
print ("<br>City: <b>$city</b>\n");
print ("<br>State: <b>$state</b>\n");
print ("<br>Zip: <b>$zip</b>\n");
?>
</body>
</html>


And, the result (in my browser), when I type in my name, address and
more...:

Here is what you typed
First Name: $first_name\n"); print ("
Last Name: $last_name\n"); print ("
Address: $address\n"); print ("
City: $city\n"); print ("
State: $state\n"); print ("
Zip: $zip\n"); ?>

Does anybody see where I am doing wrong?
--
mvh Jan Vidar
www.janvidar.com
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Advertisements
Old 07-01-2007, 3:58 PM   #2
Marius Mathiesen
 
Marius Mathiesen's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Variables

Jan V.Pedersen wrote:
> Does anybody see where I am doing wrong?


Probably, yes. What you're looking for is the register_globals directive
(just try that on Google...)

In newer versions of PHP, register_globals is by default turned off.
Which means that you whatever variables you submit to your script aren't
directly visible, you have to access them using the
$_GET/$_POST/$_REQUEST arrays, which contain all of the GET/POST/both
GET and POST variables, respectively.

If you expect a variable called first_name to be available in your
script, try checking $_REQUEST["first_name"]. You'll probably find it there.

Do a Google search for register_globals for more info.

Lykke til!

--
Marius

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 3:58 PM   #3
Jan V.Pedersen
 
Jan V.Pedersen's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Variables

Marius Mathiesen:
> Do a Google search for register_globals for more info.
>
> Lykke til!
>
>

Thx!

Did a Google-search, and just changed the register_globals to ON, and
now it works

Thank you very much!
--
mvh Jan Vidar
www.janvidar.com
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 4:17 PM   #4
Jan V.Pedersen
 
Jan V.Pedersen's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Variables

Anthony S:
> Lastly, if you're really hung up on using local variable names you can 1)
> Turn REGISTER_GLOBALS to ON in PHP.INI or you can bring them in by doing
> something like:
>
> $first_name = $_POST['first_name'];
>
> Then you can use your variable just like before.
>
>

Thanks!

How will this work on a server that uses register_globals OFF? Do I have
to rewrite all my previous php-scripts?
--
mvh Jan Vidar
www.janvidar.com
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 07-01-2007, 4:17 PM   #5
matty
 
matty's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Variables

Jan V.Pedersen wrote:

>>
>> $first_name = $_POST['first_name'];
>>
>> Then you can use your variable just like before.
>>
>>

> Thanks!
>
> How will this work on a server that uses register_globals OFF? Do I have
> to rewrite all my previous php-scripts?


$_POST[$varname] will work whether register_globals is OFF or ON.

Also, $_POST, $_SERVER, $_GET, etc are accessible within functions, without
having to declare them as global
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Featured Websites
Free Space
Free Space
Free Space Free Space
Reply
Tags:




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing variables Gilbert Schroeder PHP 7 07-01-2007 3:59 PM
Killing variables Barton PHP 0 07-01-2007 3:31 PM
declaring variables Lothar Geyer PHP 1 07-01-2007 3:30 PM
php dropping variables Dan PHP 3 07-01-2007 3:17 PM
Setting session variables ol'softy Website Reviews And Website Questions 0 05-27-2007 11:14 PM


Featured Websites




All times are GMT +1. The time now is 2:34 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98