Welcome! Log In Create A New Profile

Advanced

PHP

Posted by Tracey 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Re: PHP
January 07, 2008 04:12PM
not the subject, just me. spinning smiley sticking its tongue out
Anonymous User
Re: PHP
January 07, 2008 04:14PM
then they can avoid reading any topics where you have made comments smiling smiley
Re: PHP
January 07, 2008 04:32PM
I was having a frustrating a day so ignore my childish comments please.
Anonymous User
Re: PHP
January 07, 2008 04:42PM
Anonymous User
Re: PHP
January 07, 2008 04:59PM
al lthat is getting me through my really annoying days at work is the thought that in 19 days I never have to see these fckwits again smiling smiley
Re: PHP
January 07, 2008 05:31PM
This is the html file's code:

<html>
<head>
<title>What’s your name?</title>
</head>
<body>
<h1>What’s your name?</h1>
<h3>Writing a form for user input</h3>
<form method="get" action="hiUser.php">
Please type your name:
<input type="text" name="userName" value="">
<br>
<input type="submit">
</form>
</body>
</html>

And this is the php file's code:

<html>
<head>
<title>Hi User</title>
</head>
<body>
<h1>Hi User</h1>
<h3>PHP program that receives a value from "whatsName"</h3>
<?
print "<h3>Hi there, $userName!</h3>";
?>
</body>
</html>
Re: PHP
January 07, 2008 08:18PM
replace $userName with $_GET["userName"];
avatar Re: PHP
January 07, 2008 08:33PM
@Tracy - I never said you were frustrating. Don't put words in my mouth.

 
  ,= ,-_-. =.
 ((_/)o o(\_))
  `-'(. .)`-'
      \_/
http://ilanpillemer.com
Entia non sunt multiplicanda praeter necessitatem
avatar
Mac
Re: PHP
January 07, 2008 09:20PM
As SanozOr correctly points out, (later versions of) PHP requires you to use $_GET["userName"]; on the receiving side - earlier versions did not, automatically creating variables as it went along.

Best is to initially use "post" in your form, then you can see what is posted along with the URL. Then echo/print on the receiving page to ensure it is correctly received. Simple but custom error checking is the best....
Re: PHP
January 07, 2008 10:00PM
Thank you Sanzor and Macso much!

Its not something I would have known on my own. My fault for using an older book I guess.
Re: PHP
January 07, 2008 10:09PM
Ilan, its Tracey.

No you didn't, but somebody else said you did and I thought they were correct.

So why didn't you like my original question?
Re: PHP
January 07, 2008 10:29PM
I left out the " " and just had $_GET[userName] and it works perfectly.

Thanks guys!
Re: PHP
January 08, 2008 08:00AM
but thats just a bunch of tags! why does it need preprocessing? jeez talk about obfuscating.
avatar Re: PHP
January 10, 2008 11:18AM
I never said I didnt like it. I just thought my response was amusing (at least to me). And I like making myself laugh.

 
  ,= ,-_-. =.
 ((_/)o o(\_))
  `-'(. .)`-'
      \_/
http://ilanpillemer.com
Entia non sunt multiplicanda praeter necessitatem
avatar
Mac
Re: PHP
January 16, 2008 07:55AM
**OOPS - I see this was answered already - by me as well spinning smiley sticking its tongue out *** anyway, I have now typed it.

Tracey

best way is to do some simple custom error checking. So if you have a form with say <input type=..... name=sname ...> then use the POST method with your form. POST will append the variable to the URL like nextpage.php?sname=vdmerwe&fname=mac
You can check here if the variable is passed (you should change the form to GET after error checking so this info is not available for everyone to see). Next thing is to see if the variable has arrive on the next page.

Just do an echo as in

$sname=$_POST['"sname"]; //change to $_GET when you change the form method
echo "sname = $sname";

I think your problem, lies with not having the first line - earlier versions of PHP did not require this, so be careful of what you read on the web.
avatar
Mac
Re: PHP
January 16, 2008 08:05AM
PHP not a mere scripting language anymore - you can do anything you want with with it. Our clock system written in PHP does a better job than the Java one. Off course it depends on the programmer, but I'm referring to functionaility.

Do a search for php versus java for some intersting insights. As far as I am concerned, Java is for desktops and PHP for the web. PHP and MySQL goes hand in hand, and mySQL now has stored procedure functionality - no free baby anymore.
Re: PHP
January 24, 2008 11:36AM
thanks Mac so much for that.
I only saw them now.
Sorry, only registered users may post in this forum.

Click here to login