Jump to content

Movies32

Members
  • Posts

    9
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Movies32's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Can anyone help please? I will attach my code. assignment5-2.php form-to-email.php
  2. I was finally able to get the errors to show up, but now my problem is that all the errors show up when the user presses submit. For instance, if the user enters all the necessary information into the Help Form then the errors for the Feedback Form will show up even though the user only wants to enter information into the Help Form. The same goes if the user just wants to enter information into the Feedback Form. Does anyone have a suggestion of how I can code this so only the right errors show up at the right time? Also, how could I check to make sure that one of the checkboxes is checked in the Help Form using the same method? assignment5-2.php form-to-email.php
  3. I'm trying to complete an assignment that has to validate my form when the user presses the submit button. If you go to this website you can see the form that the user has to fill out: http://www2.esc.edu/jvooris/assignment5-2.php?formChoice=1 As you can see there are several required fields that the user needs to fill in, however if the user presses submit without filling out the form there is no error message displayed. My code does not seem to be working correctly and the only error I am getting is: Undefined index: UserName So, my question is how do I get this working correctly so that an error message displays if certain fields are not filled in? Any help would be greatly appreciated. I will attach my php files. I know I have only added the UserName error so far in the form-to-email file because I was trying to get one working before adding all the other errors. Thanks. assignment5-2.php form-to-email.php
  4. I have now gotten the page to work like it's supposed to. However, the next part of my assignment requires me to validate my form. For example, if someone does not enter their name when they click submit, then a message should show up saying that they need to provide one. The error I am getting is: Undefined index: UserName Do I need to link my two pages together somehow in order to stop this error or do I need to change how I am validating the form? Here is my code where the user can enter their name: <div class="myRow"> <label class="labelCol" for="UserName">Name*:</label> <input type="text" name="UserName" id="UserName" size="30" /> </div> Here is my PHP code for validating their entry: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>Form To Email</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> </head> <body> <?php $name = $_POST['UserName']; $tried = ($_POST['tried'] == 'yes'); if ($tried) { $validated = (!empty($name)); if (!$validated) { ?> <p>Name field cannot be empty.</p> <?php } } ?> </body> </html>
  5. Enable error reporting in what?? I am using an HTML editor not a PHP editor and any errors that do come up are only HTML errors not PHP errors. So I really do have no idea if my PHP is correct or not without some help.
  6. So I just tried to change the PHP statements and there is still nothing showing up on the webpage. Does my very first PHP code need to be changed or is it the other two PHP statements that display the forms? I even tried to put in an "elseif" for the other two PHP statements but that did not work. Which part needs to be changed? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>PHP Form</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <link rel="stylesheet" href="styles.css" type="text/css" /> <!--This links the entire page to the CSS style sheet. The font sizes, colors, colors on the page, etc. are all created on the attached style sheet--> </head> <body> <!--This code first appears on the page to allow the user to select an option--> <form action="assignment5-2.php" name="select"> <p><select name="formChoice" size="1"> <option value="0">Please select the form you want to fill out</option> <?php $formChoice=$_GET["formChoice"]; echo $formChoice; if($formChoice==1)echo "<option value=1 selected='selected'>Feedback Form</option>"; else echo "<option value=1>Feedback Form</option>"; if($formChoice==2)echo "<option value=2 selected='selected'>Help Form</option>"; else echo "<option value=2>Help Form</option>"; ?> <input type="submit" value="Submit"/> </select> </form> <?php if ($formChoice == 1): ?> <form id="feedbackForm" action="assignment5-2.php" method="GET"> <h1>User Feedback</h1> <p>Please provide feedback about my website</p> <?php end if; ?> <?php if ($formChoice == 2): ?> <!--This code below will be displayed when a user selects the help option on the website--> <form id="supportForm" action="assignment5-2.php" method="GET"> <h1>Help Request</h1> <?php end if; ?> </body> </html>
  7. Please can anyone help? I'm stuck with nothing showing up on the webpage. Please read my previous post above.
  8. I just made some changes and now nothing is appearing at all on the webpage. Am I nesting the PHP statements the wrong way or what is going on? Here is my code (edited to reduce the length): !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>PHP Form</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <link rel="stylesheet" href="styles.css" type="text/css" /> <!--This links the entire page to the CSS style sheet. The font sizes, colors, colors on the page, etc. are all created on the attached style sheet--> </head> <body> <div id="wrapper"> <!--This statement makes the entire page align to a specific setting as set in the CSS.--> <!--This code first appears on the page to allow the user to select an option--> <form action="assignment5-2.php" name="select"> <p><select name="formChoice" size="1"> <option value="0">Please select the form you want to fill out</option> <?php $formChoice=$_GET["formChoice"]; echo $formChoice; if($formChoice==1)echo "<option value=1 selected='selected'>Feedback Form</option>"; else echo "<option value=1>Feedback Form</option>"; if($formChoice==2)echo "<option value=2 selected='selected'>Help Form</option>"; else echo "<option value=2>Help Form</option>"; ?> <input type="submit" value="Submit"/> </select> </form> <?php if( !isset( $_GET['formChoice'] ) ) if $formChoice==1 ?> <form id="feedbackForm" action="assignment5-2.php" method="GET"> <h1>User Feedback</h1> <p>Please provide feedback about my website</p> <div id="content"> <?php end if ?> <?php if $formChoice==2 ?> <!--This code below will be displayed when a user selects the help option on the website--> <form id="supportForm" action="assignment5-2.php" method="GET"> <h1>Help Request</h1> <p>Enter your help request and a representative will contact you</p> <?php end if ?> </body> </html>
  9. I'm taking this class and we've just started to learn PHP so I am really new to the subject. I have done some coding and have been emailing my instructor (he has not responded yet) so please do not just click the back button thinking all I want is the answer. Here is what I need to accomplish: Create a "self-processing" PHP page that will initially just display a simple form with a drop-down select box that lets the user choose between the feedback and help request forms. When the user makes a selection, instead of using JavaScript to dynamically build or reveal the appropriate submission form, the form will be submitted back to the same page on the server for further processing. The PHP page will use a PHP script to check if the user has submitted a choice, and if so it will dynamically display the appropriate form. This is what my assignment looks like so far: http://www2.esc.edu/jvooris/assignment5-2.php As you can see, the forms are already displayed even without selecting an option from the drop down menu. What I need to have happen is have that drop down menu appear and then have the appropriate form display after the user clicks the submit button. So if the user clicks the submit button when the option is still on "Please select the form you want to fill out" then nothing should be displayed. However, if the user clicks the submit button when they select the option "Feedback Form" then that form will appear on the page and the same goes for the "Help Form". When I emailed my instructor he said that I need to: "Create a PHP page with a form with a drop down menu and a submit button that has a action to post to itself" and "Add PHP code at the top using the isset method to test to see if the page was submitted to itself and if your drop down menu variable was sent." Like I said, I do have some code already written. My problem is trying to figure out how to make it work correctly and I can't tell if I am way off base with the code I already have or if I just need to tweak a few things. I would appreciate any help in this matter and I hope I did not do too much explaining to deter anyone. Thank you. I will post my code below (I have cut out the code for the forms to shorten the code). <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>PHP Form</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <link rel="stylesheet" href="styles.css" type="text/css" /> <!--This links the entire page to the CSS style sheet. The font sizes, colors, colors on the page, etc. are all created on the attached style sheet--> </head> <body> <div id="wrapper"> <!--This statement makes the entire page align to a specific setting as set in the CSS.--> <!--This code first appears on the page to allow the user to select an option--> <form action="assignment5-2.php" name="select"> <p><select name="formChoice" size="1"> <option value="0">Please select the form you want to fill out</option> <?php $formChoice=$_GET["formChoice"]; echo $formChoice; if($formChoice==1)echo "<option value=1 selected='selected'>Feedback Form</option>"; else echo "<option value=1>Feedback Form</option>"; if($formChoice==2)echo "<option value=2> selected='selected'>Help Form</option>"; else echo "<option value=2>Help Form</option>"; ?> <input type="submit" value="Submit"/> </select> </form> <form id="feedbackForm" action="assignment5-2.php" method="GET"> <h1>User Feedback</h1>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.