Jump to content

New to php. Need help

- - - - -

  • Please log in to reply
13 replies to this topic

#1
thatsme

thatsme

    Programmer

  • Members
  • PipPipPipPip
  • 176 posts
Hi, i created such form.html form:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
<body>

<form action="welcome.php" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>

</body>
</html>
then i created such welcome.php file:
<html>
<body>

Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> years olddd2.

</body>
</html> 
When i fill the fields of form and press submit i get such output:
Welcome !
You are years olddd2.


Could anyone help me to find out why ?

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
Try to view the source code of the page, and allow the form to resubmit if it asks. Does the source code contain the PHP portion of your code as well? Are you running this script through a local server such as with WAMP? If not PHP scripts cannot be processed with the browser alone.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
thatsme

thatsme

    Programmer

  • Members
  • PipPipPipPip
  • 176 posts
Myabe i misunderstood your question, but source code of page is in file form.html (i have posted it). I am using wamp ant netbeans IDE for coding

#4
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
Your code appears to be correct, the only issue I can think of is that you are not running the scripts under http://localhost/
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#5
Megak

Megak

    Newbie

  • Members
  • PipPip
  • 16 posts
Code looks right, I would check to make sure you're using the same IP you define in PHP.ini and that your browser isn't "resetting" the POST data

#6
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200

Megak said:

Code looks right, I would check to make sure you're using the same IP you define in PHP.ini and that your browser isn't "resetting" the POST data
Same IP? I am not sure there is anything network wise that can be defined in there. It would be handled by apache.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#7
zeroradius

zeroradius

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,406 posts
NM did not see file names before
Posted Image

#8
Megak

Megak

    Newbie

  • Members
  • PipPip
  • 16 posts

Alexander said:

Same IP? I am not sure there is anything network wise that can be defined in there. It would be handled by apache.

I don't believe there is either, this problem did sound more server side, but I'll check my file to make sure. Though, I bet this is a content handling problem with apache.

After looking through, you are correct, the only server address defined is for SMTP, so this is likely a problem with apache / iis

#9
Orjan

Orjan

    Writes binary right handed and hex left handed

  • Moderators
  • 3,299 posts
  • Location:Karlstad, Sweden
  • Programming Language:C, Java, C++, C#, PHP, JavaScript, Pascal
  • Learning:Java, C#
try print the content in $_POST using
print_r($_POST);

__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall

#10
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,722 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
Use $_REQUEST["fname"] instead of $_POST["fname"] and so on. See what happens.
sudo rm -rf /

#11
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200

dargueta said:

Use $_REQUEST["fname"] instead of $_POST["fname"] and so on. See what happens.

This would be a direct array merge of most of the input superglobals, and would be contradictory to method="post" in the form (it likely is something else completely)
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#12
dargueta

dargueta

    Writes binary right handed and hex left handed

  • Moderators
  • 4,722 posts
  • Programming Language:C, Java, C++, PHP, Python, Perl, Assembly, Bash, Others
  • Learning:JavaScript
Right, but for beginners' purposes I would imagine it'd work just fine.
sudo rm -rf /




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users