The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > Web Programming > PHP


Welcome to the The ProgrammersTalk Community 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.
Tags: , , ,

Reply
 
LinkBack Thread Tools    Display Modes   
  #1 (permalink)  
Old 06-26-2007, 11:04 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,109
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Icon13 PHP Setup & Configuration - HELP!!!

Ok, I have no clue why all of these happen... I really do need help from Gurus in PHP and ASP.NET I'm not sure to what exactly wrong.. I'm pretty sure that there's nothing wrong with my code, but it doesn't print the name as I expected it's suppose to be...

form.php
PHP Code:
<html>
<
head>
<
title>What's your name?</title>
</head>
<body>
<h1>What'
s your name?</h1>
<
h3>Writing a form for user input</h3>
<
form method "post"
      
action "process.php">
Please type your name:
<
input type "text"
       
name "userName"
       
value "">
<
br>
<
input type "submit">

</
form>
</
body>
</
html
process.php
PHP Code:
<html>
<head>
<title>Hi User</title>
</head>
<body>
<h1>Hi User</h1>
<h3>PHP program that receives a value from "whatsName"</h3>

<?php

  
print "<h3>Hi there, $userName!</h3>";

?>
My output:
Code:
Hi User
PHP program that receives a value from "whatsName"
Hi there, !
$userName is suppose to be right after space in front of the coma... I'm not sure why is this happened? In fact, it happened when I tried ASP.NET too in my laptop. (My latop doesn't have XAMPP installed, however, I installed both XAMPP and .NET Framework 2.0 in this PC..) So that shouldn't be a problem right? I'm dying..............

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #2 (permalink)  
Old 06-26-2007, 11:37 PM
siLenTz's Avatar
siLenTz siLenTz is offline
Jr. Programmer
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jun 2007
Posts: 87
iTrader: (0)
siLenTz will become famous soon enoughsiLenTz will become famous soon enough
Only register_global is turned on that would allow you to do like this. If the
register_global is turned off, the $userName would not get the data from
the form.php. To solve this you should change your process.php code
to something like this and it will surely work:

PHP Code:
<?php 
  $userName 
$_REQUEST['userName'];
  print 
"<h3>Hi there, $userName!</h3>"
?>
But if you don't like to use $_REQUEST['userName'] everytimes. You can
turn register_global on in php.ini.

From siLenTz
Good luck with your PHP....

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to siLenTz For This Useful Post:
HelloWorld (06-27-2007)
  #3 (permalink)  
Old 06-27-2007, 12:18 AM
siLenTz's Avatar
siLenTz siLenTz is offline
Jr. Programmer
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jun 2007
Posts: 87
iTrader: (0)
siLenTz will become famous soon enoughsiLenTz will become famous soon enough
I forgot to tell you that using register_global is consider as insecure code.
Because register_global will get and declare variable from HTML form
directly, or session... and somethimes it will make you confusing and
messing. Here is simple example that prove that register_global is not
secure. I create an administrator page.

admin.php
PHP Code:
<?php
   
if ($admin) {
      print 
"you're an administrator";
   } else {
     print 
"you're not an administrator";   
   }
?>
I could simply using GET action to crack in your code by using this link
admin.php?admin=1. I know this is very simple example and it will never
happen in real time. But just example to know it is unsecure to use
register_global. Much of PHP sever disable it.

From siLenTz
Piece of pizza information...

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
The Following User Says Thank You to siLenTz For This Useful Post:
HelloWorld (06-27-2007)
  #4 (permalink)  
Old 06-27-2007, 07:29 AM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,109
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
TESTED and INDEED it works beautifully!!! This is apply even I put the whole code in one form.php right? Unless if I enable the register_global as you said...

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #5 (permalink)  
Old 06-27-2007, 07:37 AM
siLenTz's Avatar
siLenTz siLenTz is offline
Jr. Programmer
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jun 2007
Posts: 87
iTrader: (0)
siLenTz will become famous soon enoughsiLenTz will become famous soon enough
Let me explain you by examples which is more easy to understad.
If register_global is off the your code would be like this:

Code:
<form method="post" action=".">
   <input type="text" name="userName">
   <input type="submit">
</form>

<?php
   $userName = $_REQUEST['userName'];
   print $userName;
?>
But with register_global turned on you can do like this:
Code:
<form method="post" action=".">
   <input type="text" name="userName">
   <input type="submit">
</form>

<?php
   print $userName;
?>
From siLenTz
Hope you are understand....

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
Reply


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



All times are GMT -7. The time now is 05:57 PM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


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