Jump to content
Larry Ullman's Book Forums

kbflowers

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by kbflowers

  1. "Just assign the error message to a variable and print the variable where you want the error to appear." Therefore, I did input as below. This is "assign the error message to a variable" what I understand. $firsName =NULL; echo '<p class="error">You forget to enter your first name. Please go back and fill out the form again </p>' if you can, would you mind taking a look at below URL? http://127.0.0.1/ch02/phpPaycheck2.php The error message should be separated pages in php, but this error messages are the same page above the table.
  2. The error echo- $firsName =NULL; -does properly not work. Would you mind taking a look at below code? I would like to know what problem I run into. Thank you for spending time with me. <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Paycheck Calculator</title> <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link rel="stylesheet" href="css/styles.css"/> </head> <body> <!-- PHPPaycheck2.html --> <form action="phpPaycheck2.php", method="post"> <fieldset> <p>Use this form to calculate the Regular Pay. Overtime Pay, Gross Pay and Net Pay for an employee.</p> <p><label>First Name<input type="text" name="firstName" id="firstName"/></label></p> <p><label>Last Name<input type="text" name="lastName" id="lastName"/></label></p> <p><label>Hours Worked(between0and80)<input type="text" name="hWorked" id="hWorked"/></label></p> <p><label>Hourly Rate(between7.25and100.00)<input type="text" name="hRate" id="hRate"/></label></p> <p><input type="submit" value="Calculate" id="submit"/></p> </fieldset> </form> </body> </html> !doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Paycheck Calculator</title> <!--[if lt IE 9]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!--<link rel="stylesheet" href="style.css">--> <style type="text/css" title="text/css" media="all" > </head> <body> <!--phpPaycheck2.php--> <table id= "employee"> <tr> <th colspan ="2">Paycheck Calculator</th> <th> </th> </tr> <tr class ="alt"> <td colspan="2"> First Name</td> <td class="money"> <?php if (!empty($_POST['firstName'])){ $firsName = $_POST['firsName']; }else{ $firsName =NULL; echo '<p class="error">You forget to enter your first name. Please go back and fill out the form again </p>' } ?> </td> </tr> <tr> <td colspan="2"> Last Name</td> <td class="money"> <?php $lastName = $_POST['lastName']; echo $lastName; ?> </td> </tr> <tr> ....... </table> </body> </html>
  3. Hi, I am currently working on 127.0.0.1/ch02/PHPPaycheck2.html and127.0.0.1/ch02/phpPaycheck2.php. <!php if (!empty($_POST['firstName'])){ $firsName = $_POST['firsName']; }else{ $firsName =NULL; echo '<p class="error">You forget to enter your first name. Please go back and fill out the form again </p>' ?> An error message "You forget to enter your first name. Please go back and fill out the form again" displays next to <td colspan="2"> First Name</td> in the table of paycheck2.php. My question is how to make the error massage displaying a separate web page as shown your php textbook page 53-a. but, URL should be in 127.0.0.1/ch02/phpPaycheck2.php. That is an assignment due on this Sunday. If you provide me a clue, that will help me a lot. Thank you.
  4. Yes, I did provide email and comments values, but not displaying both. That is fine with me. More importantly, I am currently working on URL:127.0.0.1/ch02/PHPPaycheck2.html and127.0.0.1/ch02/phpPaycheck2.php. An error message "You forget to enter your first name. Please go back and fill out the form again" displays in the table of paycheck2.php. My question is how to make the error massage displaying a separate web page as shown your php textbook page 53-a. but, URL should be in 127.0.0.1/ch02/phpPaycheck2.php. That is an assignment due on this Sunday. Thank you for replying.
  5. Hi, My handle_form.php' result did properly not display after loading Form through a URL. Would you mind asking you how to display the result of handle_form. php as shown php textbook, page 43 -b? Below are my code, the result of URL, and a note by FirefoxTidyHTMLValidation. <body> <?php # Script 2.2 -handle_form.php // create a shorthand for the form data $name = $_REQUEST['name']; $email = $_REQUEST['email']; $comments = $_REQUEST['comments']; /*not used: $_REQUEST['age']; $_REQUEST['gender']; $_REQUEST['submit']; */ //Print the submityted information: echo "<p>Thank you, <b>$name</b>, for the following comments:<br /> <tt>$comments</tt></p> <p>We will replay to you at <i>$email</i>. </p>\n" ?> </body> URL: http://127.0.0.1/ch02/handle_form.php Notice: Undefined index: email in C:\xampp\htdocs\ch02\handle_form.php on line 12 Notice: Undefined index: comments in C:\xampp\htdocs\ch02\handle_form.php on line 13 Thank you, confucius, for the following comments: We will replay to you at . There is 2 warning by FirefoxTidyHTMLValidation for trimming empty <tt> and <i>. <!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" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Form Feedback</title> </head> <body> <br /> <b>Notice</b>: Undefined index: email in <b>C:\xampp\htdocs\ch02\handle_form.php</b> on line <b>12</b><br /> <br /> <b>Notice</b>: Undefined index: comments in <b>C:\xampp\htdocs\ch02\handle_form.php</b> on line <b>13</b><br /> <p>Thank you, <b>confucius</b>, for the following comments:<br /> <tt></tt></p> <p>We will replay to you at <i></i>. </p> </body> </html>
  6. Hi I tried to display an error message out of "table," as your Form Feedback( php textbook p. 53-a). However, the error message viewed below "table" http://127.0.0.1/ch02/phpPaycheck2.php. If you offer me any suggestion, that will help me a lot. <table id= "employee"> <tr> <th colspan ="2">Paycheck Calculator</th> <th> </th> </tr> <tr class ="alt"> <td colspan="2"> First Name</td> <td class="money"> <?php ?> </td> </tr> <tr> <td colspan="2"> Last Name</td> <td class="money"> <?php $last_name = 'Doe'; // variable echo $last_name; ?> </td> </tr> <tr> <td colspan = "2">Hours Worked (between 0 and 80)</td> <td class="money"> <?php #Script 1 -paycheck.php # Created March 14, 2016 by Kb $regHourWorked = 40; // initializing echo $regHourWorked; // print ?> </td> </tr> <tr> <td colspan = "2">Overtime Hours Worked (between 0 and 40)</td> <td class="money"> <?php $overHourWorked = 10; echo $overHourWorked; ?> </td> </tr> <tr> <td colspan = "2">Hourly Rate (between 0 and 100.00)</td> <td class="money"> <?php $hourRate = 20.00; echo "$" . $hourRate ?> </td> </tr> </table> <?php #Script 1.1 -phpPaycheck2.php # Created March 21, 2016 if(!empty($_POST ['name'])){ $name = $_POST['name']; }else{ $name = NULL; $error = 'You forget to enter your First Name'; #echo '<p class="error">You forget to enter your First Name.</p>' ; } echo $error; ?>
×
×
  • Create New...