Current location: Hot Scripts Forums » Programming Languages » PHP » Did PHP complete change over the last year or so? or am i just REALLY stupid now?


Did PHP complete change over the last year or so? or am i just REALLY stupid now?

Reply
  #1 (permalink)  
Old 07-15-03, 07:19 PM
playtothebeat playtothebeat is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Did PHP complete change over the last year or so? or am i just REALLY stupid now?

simple script:
PHP Code:

<?php


if ($submit == "click"){ 
  echo 
"Hello, $UserName"

else{ 
  echo 

  <html><body> 

  <form method="post" action="input.php3"> 

  Enter Your Name 
  <input type="text" name="UserName"></input><br> 

  <input type="submit" name="submit" value="click"></input> 

  </form> 

  </body></html> 
  '



?>
i got php 4.whatever.the.latest.is installed on Windows. im just running it on my local server just to mess around with it again.
anyways, the script is supposed to show the input form when accessed directly, and say Hello, whoever when it's submitted.

This is what i get when i run it:
Notice: Undefined variable: submit in C:\Program Files\Abyss Web Server\htdocs\test.php on line 3

Enter Your Name



if i do $_POST['submit'] i get "Notice: Undefined index: submit in C:\Program Files\Abyss Web Server\htdocs\test.php on line 3" and then it shows the form *(and if i click submit it shows the error, then says Hello, "

Last edited by playtothebeat; 07-15-03 at 07:21 PM.
Reply With Quote
  #2 (permalink)  
Old 07-15-03, 09:47 PM
tskweb tskweb is offline
Newbie Coder
 
Join Date: Jul 2003
Location: Plano, TX
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
http://localhost/sub.php?submit=click

<?php

$UserName = "Joe";
if ($submit == 'click'){
echo "Hello, $UserName";
}else{
echo "
<html><body>

<form method=\"post\" action=\"sub.php\">

Enter Your Name
<input type=\"text\" name=\"UserName\"></input><br>

<input type=\"submit\" name=\"submit\" value=\"click\"></input>

</form>

</body></html>
";
}
?>
__________________
Scott
Reply With Quote
  #3 (permalink)  
Old 07-15-03, 10:28 PM
The Wolf's Avatar
The Wolf The Wolf is offline
CMS Developer
 
Join Date: Jun 2003
Posts: 83
Thanks: 0
Thanked 0 Times in 0 Posts
Try this:

Code:
<?php

	if (in_array('submit', $_POST)){ 
		echo "Hello, $_POST[UserName]";
	} else {
		echo ' 
<html>
	<body> 
		<form method="post" action="input.php3">
			Enter Your Name <input type="text" name="UserName"></input><br> 
			<input type="submit" name="submit" value="click"></input> 
		</form> 
	</body>
</html>'; 
	} 

?>

Last edited by The Wolf; 07-15-03 at 10:31 PM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 02:22 AM
PHP Live Support image change Jakenorton Script Requests 2 07-28-03 04:28 AM


All times are GMT -5. The time now is 10:31 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.