Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 2nd, 2001, 05:49 PM
David Graham David Graham is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: cheshire
Posts: 52 David Graham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Why doesn't my script work?

Can anyone tell me why the script below doesn't work. The script does the first bit OK in that when a visitor opens the page for the first time there is no value for $name so the visitor gets a form asking for their name. On submitting, their name should go off to another page(a nearly identical page) which as its getting a value for $name should display some text and the link - however, it doesn't behave as it should, its like its not recieving $name because it displays the html form asking for a name?- although I can see in the URL address location that it has recieved the value for $name. What is going on please, its driving me nuts. Oh yes, nearly forgot, earlier versions I did seemed to pass on not just a name but also the string 'urlencode(Rob Smith)'
Thanks
David

<HTML>
<HEAD>
<TITLE> Sample Page </TITLE>
</HEAD>
<BODY>
<?php
if ( isset($name) )
{

print(" <P>Your name is: $name </P> \n");
$name = urlencode ($name);
print("<P>This paragraph contains a <A HREF= \"secondpage.php?name = $name \">link</A>\n");
print(" that passes the name variable on to the next document.</P>\n");
}

else
{
print(" <!-- No name has been provided, so we
prompt the user for one. -->");

print(" <FORM ACTION = $PHP_SELF METHOD = GET><br>\n");
print(" Please enter your name: <INPUT TYPE = TEXT NAME = \"name\"><br>\n");
print(" <INPUT TYPE = SUBMIT VALUE = \"GO\">\n");
print(" </FORM><br>\n");
print("Wellcome to our website $name!");
}
?>
</body>
</html>
__________________
Dave Graham

Reply With Quote
  #2  
Old August 3rd, 2001, 02:36 PM
Captain Zig Captain Zig is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: CT, USA
Posts: 7 Captain Zig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation If $name is not set, $name won't print out

Hi, David

What error message(s) are you getting?

I see one problem in your code, near the bottom.

...
else
{
print(" <!-- No name has been provided, so we
prompt the user for one. -->");

print(" <FORM ACTION = $PHP_SELF METHOD = GET><br>\n");
print(" Please enter your name: <INPUT TYPE = TEXT NAME = \"name\"><br>\n");
print(" <INPUT TYPE = SUBMIT VALUE = \"GO\">\n");
print(" </FORM><br>\n");
print("Wellcome to our website $name!");
}
?>
</body>
</html>

The line:print("Wellcome to our website $name!"); could be problematic b/c to be in this part of the code $name is not set.

Take that line out. Then see how it runs.

-Zig

Reply With Quote
  #3  
Old August 4th, 2001, 05:44 AM
David Graham David Graham is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2001
Location: cheshire
Posts: 52 David Graham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Smile script problem

Thanks but that doesn't seem to cause an error. The problem was identified as being due to the stupid way I leave spaces around this bit:

$name = name
shoud be
$name=name
works OK now!
only a little thing but it makes a big difference
Bye
David

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > Why doesn't my script work?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway