![]() |
|
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. |
| |||||||
| 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. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| 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" 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 | |||
|
| Advertisements |
| | #2 | ||
| 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 | |||
|
| | #3 | ||
| 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 | |||
|
| | #4 | ||
| 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 | |||
|
| | #5 | ||
| 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 | |||
|
| Featured Websites | ||||
|
![]() |
| Tags: variables |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
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 | ||||
|