|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Other > Beginner Programming > Why doesn't my script work? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|