Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Forms in PHP [easy question - please help!]

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Forms in PHP [easy question - please help!]

Postby deerinheadlights » Sat Jun 21, 2003 8:41 pm

Hola,

I just started to learn PHP [probably about a half an hour ago] and I've already run into problems.

My first form isn't working. The variables aren't showing up. This is the same problem as in http://www.php-forum.com/p/viewtopic.php?t=1759.

I have tried Skeletor's suggestion of $_GET['var'] and $_REQUEST['var'] and they haven't worked. Is there some way that I can turn register globals on?

The example is right off of webmonkey. This code has the suggestions in it:

Code: Select all
<?php

$_REQUEST['YourName'];
$_REQUEST['FavoriteWord'];

print(" $YourName");

?>

<p>
You like the word <b> <?php print(" $FavoriteWord"); ?> !?! </b>


I'm very sorry for asking everyone this. It's probably a really simple error, I just don't know very much yet.

Thanks so much :-]
deerinheadlights
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sat Jun 21, 2003 8:26 pm

Postby Oleg Butuzov » Sat Jun 21, 2003 10:20 pm

Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Godiwa » Sun Jun 22, 2003 6:46 am

First of all, why do you go OUT of PHP just to go in it again so shortly after? User something like this:

<?php

$YourName = $_POST['YourName'];
$FavoriteWord = $_POST['FavoriteWord'];

echo $YourName;
echo "<p>You like the word $FavoriteWord !?!</p>";

?>

Here is your old code:

<?php

$_REQUEST['YourName']; //This doesn't really do anything, my guess is you wanted to put it into a var right? thats what I did above since it is easier to type those small vars then the full $_post var every time

$_REQUEST['FavoriteWord']; //same as above nothing happens here

print(" $YourName"); //here you are printing an empty var since $Yourname doesn't exist, it should be $_POST['YourName'] if you wanted to use it directly or it would work if you made the POST vars into normal vars as I did above

?>

<p>
You like the word <b> <?php print(" $FavoriteWord"); ?> !?! // here you out of PHP, why? you can just as easilly do this with php as shown above, and again you are printing a var that doesn't exist, either convert it as I did above or use $_POST['FavoriteWord'] as the var, good luck with it.
</b>



Godiwa
Godiwa
New php-forum User
New php-forum User
 
Posts: 40
Joined: Wed Mar 05, 2003 5:55 am

Postby deerinheadlights » Sun Jun 22, 2003 9:29 am

Thank you both so much. I really appreciate it :-] It's becoming a little more clear, now. The only reason I kept going in and out of PHP was because that's how it was on the Webmonkey tutorial. I thought that that was a little odd, too.

Does anyone know of a good tutorial that is current with the changes?

-[lindsey]-
deerinheadlights
New php-forum User
New php-forum User
 
Posts: 2
Joined: Sat Jun 21, 2003 8:26 pm

Postby Godiwa » Sun Jun 22, 2003 2:50 pm

well I am a noob/newbie myself too, played with it about 6 months now or so, on and off, and I can only recommend you to get the PHP Manual that can be downloaded on the same page you download PHP itself, and you can get different types of files, and I use the Windows Help File version, very handy and informative and if you got questions about a special command, feel free to ask on this forum, lots of very helpful people here and other then that, go on Amazon.com and look for PHP books, there is a PHP for Beginners (not sure of complete title) but it is a big book with a red cover, I was about to order it but the only version they had in the bookshop where I live was the pro version and I needed the beginner version, and they have them in 3-4 level ranges from beginner up to ultra hardcore coders and you can buy the next level of book when you feel confident in knowing most of the book before it.

When you found it on Amazon then go to your local bookshop and see how much they will charge you for it, usually less then what Amazon does, but they have nice reviews and such over the books

Godiwa
Godiwa
New php-forum User
New php-forum User
 
Posts: 40
Joined: Wed Mar 05, 2003 5:55 am


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron