• 0

learning php


Question

i just started learning the basics of php about a half hour ago and i can figure out how to post things. ive been using echo but i dont know how to make text actually show up. like im just doing basic things like sending a form with a name and password and trying to get the next page to tell me what i entered but i dont know the command to do it. ive tried echo and $f=fopen. speaking of files im having trouble having them appear also. i uploaded a .txt and set it to read only but nothing is showing up.

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

well if you want to pass just a username and password and have the page display the input you entered its simple.

On one page, just have basic html with two text boxes or woteva for username and pass, and call them say user and pass. Then have this post to a php page, say form.php.

On the form.php page you could have this then

<?php

$user=$HTTP_POST_VARS['user'];

$pass=$HTTP_POST_VARS['pass'];

print "Username: $user<br>";

print "Password: $pass";

?>

Say the username is neo and the password is windows then it would show this

neo

windows

I think thats right, i havent had time to check it but thats basically how to do it.

Link to comment
Share on other sites

  • 0

hmm... ive got this:

<form action="number2.php" method="POST">

hello<input type="text" name="user" />

password<input type="password" name="pass" />

<input type="submit" />

</form>

and your code on a separate page but its not giving me my username and password...

Link to comment
Share on other sites

  • 0

Ok well i tested it and it seemed to work fine here.

Anyway heres the code of the 2 so you can see if it is working for you, if not maybe php isn't installed correctly on the server or pc.

test.html

&lt;form action="test2.php" method="POST"&gt;
Username: &lt;input type="text" name="user" /&gt;&lt;br&gt;
password: &lt;input type="password" name="pass" /&gt;&lt;br&gt;
&lt;input type="submit" /&gt;
&lt;/form&gt;

test2.php

&lt;?php
$user=$HTTP_POST_VARS['user'];
$pass=$HTTP_POST_VARS['pass'];
print "Username: $user&lt;br&gt;";
print "Password: $pass";
?&gt;

Sayin i tested it etc you can see it in action at

www.niteworx.com/test.html

Link to comment
Share on other sites

  • 0

You can also check in the same page whether the form is posted or not, so you won't need 2 seperate pages, and you can inmeadatly continue the

&lt;?php
if(isset($_POST['submit'])) { //submit is the name of the submit button
 ?// executed when form is posted
 ?echo "Hello" . $_POST['username'];
 ?echo "Your password is: " . $_POST['password'];
}
else {
 ?// executed when form is not posted
?&gt;
&lt;form method="POST"&gt;
Username: &lt;input type="text" name="username" /&gt;&lt;br&gt;
password: &lt;input type="password" name="password" /&gt;&lt;br&gt;
&lt;input type="submit" name="submit" /&gt;
&lt;/form&gt;
&lt;?php
}
?&gt;

Hope this hel:)s :)

Link to comment
Share on other sites

  • 0

well after fooling around for a while i realized that i was trying to do it offline so i think that is probably my answer to making text appear also. thanks for the help!

Link to comment
Share on other sites

  • 0

For developing php or any other script langauge I highly encourage you to install some Apache/PHP(/MySQL) setup on your system.

EasyPHP is one for example. Even though EasyPHP is in french one can find one's way quite easy.

If you are using Linux. Setting up a L.A.M.P is easy as cake. There are tutorials on how to set up L.A.M.P's on just about every distribution.

kindest regards,

Moritz "neofeed" Angermann

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.