3 Replies - 428 Views - Last Post: 13 February 2011 - 10:09 AM Rate Topic: -----

#1 polens  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 155
  • Joined: 09-November 09

HELP First timer on PHP

Posted 13 February 2011 - 08:47 AM

Hey guys...
im self studying php because it is not offered in out school...
This is my first time...
<?php 
$aged= 100;
$age=  $_Post["Age"]; 

if ( $_POST["age"] > $aged)
  echo "Invalid Input!";
else
 
?>

Error:
Notice: Undefined variable: _Post in C:\xampp\htdocs\MyProject\FirstPhp\Welcome.php on line 6
Invalid Input!

how can i get the inputed data to a variable?

i manage to solved it thanks for viewing :whistling:

Is This A Good Question/Topic? 0
  • +

Replies To: HELP First timer on PHP

#2 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2990
  • Posts: 10,329
  • Joined: 08-August 08

Re: HELP First timer on PHP

Posted 13 February 2011 - 08:55 AM

PHP is case sensitive.
$_POST != $_Post
Was This Post Helpful? 0
  • +
  • -

#3 e_i_pi  Icon User is offline

  • = -1
  • member icon

Reputation: 795
  • View blog
  • Posts: 1,681
  • Joined: 30-January 09

Re: HELP First timer on PHP

Posted 13 February 2011 - 09:12 AM

[quote name='polens' date='13 February 2011 - 08:47 AM' timestamp='1297612073' post='1250031']
Try this:
<?php 
$aged = 100;
$age =  (int)$_POST["Age"]; 

if ($age > $aged)
{
  echo "Invalid Input!";
} else {
  // The rest of your code here
} 
?>

Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3541
  • View blog
  • Posts: 10,236
  • Joined: 08-June 10

Re: HELP First timer on PHP

Posted 13 February 2011 - 10:09 AM

of course you should also check, if the POST array is already populated. if the PHP page is the same that outputs the according HTML, you won’t get anything on initial page load.
if (!isset($_POST['Age']))
{
    echo "no input given";
    // exit;
    // throw new Exception("first load.");
}

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1