Jump to content

Dtp1337

Members
  • Posts

    30
  • Joined

  • Last visited

Dtp1337's Achievements

Newbie

Newbie (1/7)

1

Reputation

  1. Still getting an error to my display loop... Lab12.php
  2. On the database connection... I used other previous working programs I wrote and now I can't seem to access the database. They are now providing that I can't use them either... Does that mean my account holding my user/pass is removed? Nevermind I'm down to a problem with my loop and I guess those variables you mentioned. Lab12.php
  3. Notice: Undefined index: City1 in F:\xampp\htdocs\Lab12.php on line 16 Notice: Undefined index: State1 in F:\xampp\htdocs\Lab12.php on line 17Can't connect to MySQL Server. SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it. Fixed the variables lol, and also corrected a couple of otther things I caught in the header and stuff. Does the first if{} if else{} work as for setting those check variables? As for the while loop where would I need to put that variable check? Lab12.php
  4. Could I use "exit" to prevent the loop? And I should place the validation into a If { } elseif stucture?
  5. Is this closer to what your talking about? Lab12.php
  6. I still don't think im getting it right... Lab12.php
  7. I'm also getting a unexpected else on line 24?
  8. Ok then in the loop would I place my loop there? and additionally for each else if?
  9. Yes and where exactly do I need that If statement? I had problems with it in the 1st 2 files I submitted. Of which I did switch them around cause it didn't make sense to me.
  10. I restarted from an example. Is that a little better towards what you described? I also uploaded it to the first post.
  11. Just displaying the City name selected, State selected, and the database for selection of both.
  12. I've been working at this provided that the user/pass are removed. I need to validate a form processing it to where it displays the city and state in the MySQL database. Can anyone help me piece this in order. I think I have 2 copies of what I have but I do not understand how to get it to say if the city is entered and the state is not, process city and request state. Likewise for state and when both are input, do both, Otherwise error and redo. Also its using PDO passing.Heres the 2 horrible ideas I've had so far. Can anyone please help me piece this thing together correctly. Lab12.php
  13. lol found that already lol thanks now I need to validate that the color and the food is selected when submitted. How and where would i palce that in my php form. This is what I have for it. Also something I found that may conflict with validing the use of the drop list, would i need to make an empty entry into the list before "Red" so that it will force the user to select one unless they over look it completely. edit#1-5 : Also I have an extra empty drop box between my droplist and buttons. Why is it there. <!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title> Lab 8-F </title></head><body><form action =" " method="post"><h1> Enter your First and Last name then select your favorite color and food.</h1> <p> First Name: <input name="Fname" type="text" /><p/> <p> Last Name: <input name="Lname" type="text" /><p/><?php $color["R"]="Red"; $color["B"]="Blue"; $color["G"]="Green"; $color["C"]="Cyan"; $color["M"]="Magenta"; $color["Y"]="Yellow"; ?> <select name = "color" id = "color"><?php foreach($color as $pick => $favorite) { echo "<option value=\"$favorite\"> $favorite </option> \n"; }?></select> <?php $food["B"]="Barbeque"; $food["C"]="Chinese"; $food["J"]="Japanese"; $food["T"]="Thai"; $food["S"]="Steak"; $food["V"]="Vegan"; $food["M"]="Mexican"; ?> <select name = "food" id = "food"><?php foreach($food as $pick1 => $favorite1) { echo "<input type=\"radio\" name=\"favorite1\" value=\"favorite1\"> $favorite1\n"; }?> </select> <input type="submit" name="Submit" id="Submit" value="Submit"></form></body></html> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- <html><head><meta a http-equiv="Content-Type" content="text/html; charset=utf-8"><title> CISP1720 Lab 8</title></head> <h1> Lab 8 </h1><h3> </h3><body> <?php$Fname = $_POST['Fname'];$Lname = $_POST['Lname'];$color = $_POST['color'];$food = $_POST['food'];if(empty($Fname) || empty($Lname)) {echo <p> Please do not leave fields blank. </p>; } else if (is_numeric($Fname) || is_numeric(Lname)) { echo <p> Please do not use numbers in your name. </p>; } else if ( ?> </body></html>
  14. ? This is what i've come up so far for the names and first array. It gives me a unexpected end error... !DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title> Lab 8 </title></head><body><form action =" " method="post"><h1> Enter your First and Last name, then select your favorite color and food.</h1> <p> Please provide your First Name. <input name="Fname" type="text" /><p/> <p> Please provide your Last Name. <input name="Lname" type="text" /><p/> <h1> Choose your favorite color. </h1><?php $color["R"]="Red"; $color["B"]="Blue"; $color["G"]="Green"; $color["C"]="Cyan"; $color["M"]="Magenta"; $color["Y"]="Yellow"; ?> <select name = "color" id = "color"><?php foreach($color as $pick => $favorite) { echo "<option value=\"$favorite\"> $favorite </option> /n";?></select> <input type="submit" name="Submit" id="Submit" value="Submit"></form></body></html>
  15. Create an associative array that will be used in a form for a dropdown box for user to pick their favorite color. The entries should be:RedBlueGreenCyanMagentaYellowCreate a second associative array that will populate a set of radio buttons. The buttons should ask the user to choose their favorite type of food from following list.BarbequeChineseJapaneseThaiSteakVeganMexicanThe form should also ask for first and last name. Data should be validated. If invalid data is entered, and error should be displayed, otherwise, output the data. I have to create a form that sends the answers to the php. I don't understand where to put the arrays/ I have this but it don't seem right for the dropdown box.Even so after getting it to work how do I valid the information of a dropbox or radio button. I'm so confused. <body> <?php$color = array( 0=>"Red", 1=>"Blue", 2=>"Green", 3=>"Cyan", 4=>"Magenta", 5=>"Yellow");$food = array(0=>"Barbeque", 1>="Chinese", 2="Japanese", 3=>"Thai", 4=>"Steak", 5=>"Vegan", 6=>"Mexican"); $color = str_repalce(" "," ",$color);$food = str_replace(" "," ", $food);echo '<SELECT name=color>';echo '<SELECT name=food>';foreach ($color as $pick => $value){echo '<OPTION value='.$value.'>'.$value.;}echo '</select>'; ?> <form action="CISP1720-dpatter3-Lab7.php" method="post"> <p> Please provide your First Name. <input name="Fname" type="text" /><p/> <p> Please provide your Last Name. <input name="Lname" type="text" /><p/> <input type="submit" name="Submit" id="Submit" value="Submit"></body></html>
×
×
  • Create New...