I am quite new to Dreamewaver CS4 and I am presently working my way through the book by Jeffery Bardzell "training from the source. I have reached lesson 5 "passing data between pages. I have created the first and last name text fields on the form and then run the form through the server. I works fine and displays the first and last names on the form processor ie "thank you ,john smith, for filling out my form" The book then tells me to open the form processor and it should look like "thank you ,, for filling out my form, however it displays:
Thank You, Notice: undifined index:firstName in c:\xampp\htdocs\newland\test_form_processor.php on line 9.
undifined index lastName in c:\xampp\htdocs\newland\test_form_processor.php on line 9
,for filling out my form.
Could someone tell me what i have done wrong. I followed the book word for word and i have also checked the code on my page with the code on the "completed lesson" on the CD. theyr'e both identical.
Any help would be apreciated
Thanks it worked doing that I have just re looked at the code in my page and also the code in the lesson finished and theyre identical.
This is what it should say according to the book:
"thank you ,, for filling out my form"
however it displays:
Thank You, Notice: undifined index:firstName in c:\xampp\htdocs\newland\test_form_processor.php on line 9.
Notice: undifined index lastName in c:\xampp\htdocs\newland\test_form_processor.php on line 9
,for filling out my form.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<p>Thank you,<?php echo $_GET['firstName']; ?> <?php echo $_GET['lastName']; ?>, for filling out my form. </p>
</body>
</html>
When you view the document in a browser, the URL will show
c:\xampp\htdocs\newland\test_form_processor.php
or similar. If we add the URL variables that the document asks for, Bob's your uncle. Add the highlighted as in
c:\xampp\htdocs\newland\test_form_processor.php?firstname=Uncle&lastname=Bob
The result will be
Thank you, Uncle Bob, for filling out my form.
What this means is, that the document that calls this document should include the URL variables in the link.
Gramps
Yes that part of it works fine but the book tells you to open the test_form_processor.php and then press f12 and it should display:
thank you ,, for filling out my form because the form looses its information when you close the test form
I have the same trouble with the test_form_processor_cookies.php. everything works ok you open the test form, enter your first and last name and the form displayes correctly then it said follow the cookies link and that displayes correctly eg Hi Fred Smith ! But then it tells you close the browser, select test_form_processor_cookies.php and press F12.
Earlier when you tried this experiment with test_form_processor.php It didn't work because there was no data in the queerystring that data was lost as soon as you closed your browser. PHP left the text blank but when you try the same experiment using cookies, even though you closed the browser the data persisted because it was saved on your hard drive as a cookie.so when I open the test_form_processor_cookies.php it should still display Hi Fred Smith ! but it doesn't it displayes:
Hi,
Notice: Undefined index: firstName in C:\xampp\htdocs\newland\test_form_processor_cookies.php on line 9
Notice: Undefined index: lastName in C:\xampp\htdocs\newland\test_form_processor_cookies.php on line 9
!
The code for that page is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
Hi, <?php echo $_COOKIE['firstName']; ?> <?php echo $_COOKIE['lastName']; ?> !
</body>
</html>
I just followed the instructions in the book. This is the exact wording:
In the bindings panel click the new binding button, choose cookie variable and type firstName. Repete step 7 to add lastName cookie to the bindings panel.
Thats how it tells me to create the cookies.
The book then goes on:
Click test_form.php in the site panel and press F12 to test. Fill out the form, click submit, then follow the Check Cookie Link.
As you would expect it works. Even though the data started on the first page , you got it to display on the third. The information was pulled not from the URL or the request body as form variables, but rather from your hard drive.
Close your browser. Return to Dreamweaver, Select test_form_processor_cookies.php in the site panel, and press F12
Earlier when you tried this experiment with test_form_processor.php It didn't work because there was no data in the queerystring that data was lost as soon as you closed your browser. PHP left the text blank but when you try the same experiment using cookies, even though you closed the browser the data persisted because it was saved on your hard drive as a cookie
I guess the book is wrong! Try to get your money back. If you want an outcome as you have described the line reading
<p>Thank you,<?php echo $_GET['firstName']; ?> <?php echo $_GET['lastName']; ?>, for filling out my form. </p>
should read
<p>Thank you,<?php echo (isset($_GET['firstName']) && isset($_GET['lastName'])) ? $_GET['firstName'].' '.$_GET['lastName'] : ' '; ?>, for filling out my form. </p>
The result will be
Thank you, , for filling out my form.
Gramps
peterattrsb wrote:
Thanks it worked doing that I have just re looked at the code in my page and also the code in the lesson finished and theyre identical.
This is what it should say according to the book:
"thank you ,, for filling out my form"
however it displays:
Thank You, Notice: undifined index:firstName in c:\xampp\htdocs\newland\test_form_processor.php on line 9.
Notice: undifined index lastName in c:\xampp\htdocs\newland\test_form_processor.php on line 9
,for filling out my form.
But it only displays the 'Notice: undifined index' IF you run it through the browser, right. I think what the book means by 'open' the 'test_form_processor.php' page is open it in Dreamweaver then the page will look like it says:
"thank you ,, for filling out my form"
I tried the same experiment using the completed lessons form on the CD that came with the book and I got the same results. I then changed the code to the one gramps suggested and it worked OK.
I have to say someone new to Dreamweaver and following the book word for word would expect it to work. I think the book could be a little clearer and if there is the possibility that an error could occur then the book should at least have some reference that this could happen. It would save someone like me spending hours looking through the code thinking they had done something wrong when in actual fact they hadn’t. It’s not a cheap book I paid £ 39.33 a few years ago so I think it would have gone up since then.
When I have worked my way through this book I am moving on to Dreamweaver CS5 Training form the source by David Powers. Hope this book is right.
Thanks for all your help with this. It was really appreciated. At lease i know where to come to if i get stuck again.
Thanks
Paul
peterattrsb wrote:
I tried the same experiment using the completed lessons form on the CD that came with the book and I got the same results. I then changed the code to the one gramps suggested and it worked OK.
I have to say someone new to Dreamweaver and following the book word for word would expect it to work. I think the book could be a little clearer and if there is the possibility that an error could occur then the book should at least have some reference that this could happen. It would save someone like me spending hours looking through the code thinking they had done something wrong when in actual fact they hadn’t. It’s not a cheap book I paid £ 39.33 a few years ago so I think it would have gone up since then.
When I have worked my way through this book I am moving on to Dreamweaver CS5 Training form the source by David Powers. Hope this book is right.
Thanks for all your help with this. It was really appreciated. At lease i know where to come to if i get stuck again.
Thanks
Paul
The first instance ("thank you ,, for filling out my form,) was never going to work as the page would never receive the correct information to return anything if just opened in the browser WITHOUT either going through the form or as gramps solution passing the variables firstName & lastName in the url
I'd say you have to set the 'cookie' first:
<?php
setcookie("firstName", "Uncle");
setcookie("lastName", "Bob");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Cookie Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<p>Thank you, <?php echo $_COOKIE['firstName']; ?> <?php echo $_COOKIE['lastName']; ?>for filling out my form. </p>
</body>
</html>
>In the bindings panel click the new binding button, choose cookie
>variable and type firstName. Repete step 7 to add lastName cookie to the bindings panel.
>
>Thats how it tells me to create the cookies.
They don't tell you to set an expiration time? Without a specified expiration, the cookie will expire when the browser is closed. So, it seems everything is working as expected.
>even though you closed the browser the data persisted
>because it was saved on your hard drive as a cookie
This is wrong. If you don't specify an expiration, cookies expire when the browser is closed.
Thanks for all the help. Just one question for Gramps if that’s Ok.
As I am trying to learn what all the various codes mean could you tell me what the code below means, what’s it telling the webpage to do?
,<?php echo (isset($_GET['firstName']) && isset($_GET['lastName'])) ? $_GET['firstName'].' '.$_GET['lastName'] : ' '; ?>,
I am moving on to the next lesson in the book “Sending email from a web form”. The book does say that because I am using Apache and PHP on a local server the email won’t actually go any ware but I should complete the lesson anyway.
<?php echo (isset($_GET['firstName']) && isset($_GET['lastName'])) ? $_GET['firstName'].' '.$_GET['lastName'] : ' '; ?>,
In plain English
echo
print/show following echo. In our case we need a conditional statement to choose what will be shown. The conditional statement that I have used is called a ternary operator. This does the same as if condition is true then else this
(isset($_GET['firstName']) && isset($_GET['lastName']))
Our condition: firstName and lastName values are not empty
?
if true, i.e. there is a value for both of the variables
$_GET['firstName'].' '.$_GET['lastName']
then go ahead and print the above
:
if false, i.e. there is no value for BOTH the variables
' '
then print nothing
The reason why we have to use the conditional statement is probably already clear to you, it is to make sure that we do not get error messages if the condition cannot be met.
Gramps
Just a quick question. Is it possible to use apache / php and asp on the same computer? The reason I ask is the book gives 3 options for developing the site using a local server. When I was trying to choose, apache / php was the easiest to download and configure but asp does allow the site to perform functions on a local server that php doesn’t have.
Sorry I'm confused again. When I upload a form to the server this is what it looks like.
The functionailty of the form works and it does give the right error ehrn you enter a non numeric value. I have also tested the completed lessons and i get the same message.
Newland Tours: Tour Price Calculator
Enter the number of Adults and Children in your party as well as the tour name of the tour you want to calculate.
All fields are required (enter 0 if nessesery)
Notice: Undefined index: error in C:\xampp\htdocs\newland\tourprice.php on line 29
>if ($_GET['error'] == "notnumeric")
I'm not sure if this is the line causing the error, but here you are testing the value of a variable without first testing if it has been set. Always test if an array element is set before trying to access the value. http://us3.php.net/isset
This is really frustrating. I’m trying to follow a book that is supposed to teach you how to do things. It even goes so far as to have a disc with completed lessons that I would assume were right but I get the same errors even with the files on the disk that came with the book. I really feel like I’m trying to swim upstream.
I have got through most of the code but i got stuck again. If I have 2 fields i understand the code is:
<?php echo (isset($_GET['firstName']) && isset($_GET['surName'])) ? $_GET['firstName'].' '.$_GET['surName'] : ' '; ?>
But if I just have one field I have tried taking out the second field ie
<?php echo (isset($_GET['firstName']) ? $_GET['firstName'].' '. ?>
Could someone help please
I have created a contact us form and when the visitor presses submit the site directs them to a message sent page. I have put all the usual stuff on the page ie thanks for contacting us. I have also created a table so the visitor can see the message they sent. I have bound all the fields from the contact form and they work fine, The only problem I have is the text element. When the data is sent to the message sent form the body of the message does not wrap and create new lines in the box. It just widens the box and dissapears off the end of the page. Is there some sort of setting I need to set in the field propoties?
North America
Europe, Middle East and Africa
Asia Pacific