Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

basic php issue

Links for php scripts

Moderators: macek, egami, gesf

basic php issue

Postby jwdvd » Fri Feb 17, 2012 2:48 pm

Hi there, Im totally new to php and haven't programmed or played with html for years so please forgive me if im being stupid with this. I am following a few guides to learn mysql and php and im stuck im something that i think looks right. I made a test html file to carry a variable to a php file and its not carrying over the variable...

---HTML PAGE---

<HTML>
<HEAD>
<TITLE>welcome page</TITLE>
</HEAD>
<BODY>

<A HREF="welcome.php?name=john"> Hi, I'm John! </A>

</BODY>
</HTML>

----------------

---PHP PAGE---
<HTML>
<HEAD>
<TITLE>welcome page</TITLE>
</HEAD>
<BODY>

<?php
echo "Welcome to our Web site, $name!" ;
?>

</BODY>
</HEAD>
</HTML>


when i click the link in the welcome page i get the following..

Welcome to our Web site, !

the name john should be in there, the variable is being passed to the url though...

http://192.168.0.12/welcome.php?name=john


I'm running fedora 16 with a yum installed LAMP install. any help would be much appreciated.

thanks.
jwdvd
New php-forum User
New php-forum User
 
Posts: 2
Joined: Fri Feb 17, 2012 2:40 pm

Re: basic php issue

Postby jwdvd » Sat Feb 18, 2012 5:13 am

i solved it with the following in the php file...

echo "<h1>Hello " . $_GET["name"] . "</h1>";

why would th example not pass the variable over?
jwdvd
New php-forum User
New php-forum User
 
Posts: 2
Joined: Fri Feb 17, 2012 2:40 pm

Re: basic php issue

Postby landi » Thu Mar 15, 2012 5:40 pm

Hi,
$_GET[] returns an array of url 'parameters'. It is one way to access the 'query string'. See also $_POST and $_REQUEST.

There is no concept in PHP of url parameters automatically appearing in variables of the same name. A faint bell is ringing that maybe once there was something like this, I know some languages (I think Oracle ApEx) do this, but it can open up security risks and I think is generally considered to be A BAD THING.
landi
New php-forum User
New php-forum User
 
Posts: 135
Joined: Thu Mar 15, 2012 3:59 pm


Return to PHP Scripts

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

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