jjinto
05-02-2009, 05:46 PM
Hello everybody.
I've been learning PHP from a few books and Lynda.com tutorial, and I've been doing pretty well until this completely stumped me:
I'm following an example in a book for making a simple address book.
The book has been pretty good up until this.
The code:
function GenerateHTMLForm ($formValues, $actionScript, $submitLabel) {
printf("<form method=post action=\"%s\"><PRE>\n", $actionScript);
printf("Name:
<input type=text size=35 name=cn value=\"%s\">
<br>\n", ($formValues) ? $formValues["cn"] : " ");
printf("E-mail:
<input type=text size=35 name=mail value=\"%s\">
<br>\n", ($formValues) ? $formValues["mail"] : " ");
printf("City:
<input type=text size=35 name=city value=\"%s\">
<br>\n", ($formValues) ? $formValues["city"] : " ");
printf("Description:
<input type=text size=35 name=description value=\"%s\">
<br>\n", ($formValues) ? $formValues["description"] : " ");
printf("Telephone:
<input type=text size=35 name=telephonenumber value=\"%s\">
<br>\n", ($formValues) ? $formValues["telephonenumber"] : " ");
// Generate a button to submit
printf("<input type=submit value=\"%s\">", $submitLabel );
printf("</PRE></form>");
}
My question is simple, I hope. The page runs fine until it hits this block of code, and then nothing happen. No error msg, no text boxes.
Should I rewrite the code using an html <input> form and pass the php variables that way?
In the lines above, I feel like the ternary should begin with (!$formValues) to see if the condition is not met before choosing between the two options.
Anyway, I am open to any advice.
Thanks!
I've been learning PHP from a few books and Lynda.com tutorial, and I've been doing pretty well until this completely stumped me:
I'm following an example in a book for making a simple address book.
The book has been pretty good up until this.
The code:
function GenerateHTMLForm ($formValues, $actionScript, $submitLabel) {
printf("<form method=post action=\"%s\"><PRE>\n", $actionScript);
printf("Name:
<input type=text size=35 name=cn value=\"%s\">
<br>\n", ($formValues) ? $formValues["cn"] : " ");
printf("E-mail:
<input type=text size=35 name=mail value=\"%s\">
<br>\n", ($formValues) ? $formValues["mail"] : " ");
printf("City:
<input type=text size=35 name=city value=\"%s\">
<br>\n", ($formValues) ? $formValues["city"] : " ");
printf("Description:
<input type=text size=35 name=description value=\"%s\">
<br>\n", ($formValues) ? $formValues["description"] : " ");
printf("Telephone:
<input type=text size=35 name=telephonenumber value=\"%s\">
<br>\n", ($formValues) ? $formValues["telephonenumber"] : " ");
// Generate a button to submit
printf("<input type=submit value=\"%s\">", $submitLabel );
printf("</PRE></form>");
}
My question is simple, I hope. The page runs fine until it hits this block of code, and then nothing happen. No error msg, no text boxes.
Should I rewrite the code using an html <input> form and pass the php variables that way?
In the lines above, I feel like the ternary should begin with (!$formValues) to see if the condition is not met before choosing between the two options.
Anyway, I am open to any advice.
Thanks!