Jump to content

Dtp1337

Members
  • Posts

    30
  • Joined

  • Last visited

Everything posted by Dtp1337

  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>
  16. I dunno what to do with it now. Heres what I got as a whole... <!DOCTYPE HTML> <?php /********************************************** Author: Dylan T. Patterson* Filname: CISP1720-dpatter3-LAB6.php* Assignment: CISP1720-dpatter3-LAB6.php* Date: 10/3/2012* Description: Displays and validates First and Last Name, ######, and Age. *********************************************/ ?> <html> <head> <meta a http-equiv="Content-Type" content="text/html; charset=utf-8"> <title> CISP1720 Lab 6</title> </head> <h1> Lab 6 </h1> <h3> Information provided.</h3> <body> <p> <?php $Fname = empty($_POST['Fname'], "Enter your first name!"); $Lname = empty($_POST['Lname'], "Enter your last name!"); $###### = ($_POST['######'], "Enter your gender!"); $Age = ($_POST['Age'], "Enter your age!"); if (is_numeric($Fname)) || (is_numeric($Lname)) { echo "'{$Fname}' is numeric"; echo "'{$Lname}' is numeric"; } else { echo "'{$Fname}' is not numeric", PHP_EOL; echo "'{Lname}' is not numeric", PHP_EOL; } if (!filter_input(INPUT_POST, '######', FILTER_SANITIZE_STRING)) { echo "###### is not valid"; } else { echo "###### is valid"; } echo "<p> First Name: $Fname </p> \n"; echo "<p> Last Name: $Lname </p> \n"; echo "<p> ######: $###### </p> \n"; echo "<p> Age: $Age </p> \n"; ?> ---------------------------------------------------------------------------------------------------------- <!DOCTYPE HTML> <?php /********************************************** Author: Dylan T. Patterson* Filname: CISP1720-dpatter3-LAB06-F.php* Assignment: CISP1720-dpatter3-LAB06-F.php* Date: 10/3/2012* Description: Form program passing information to a Php program to process. *********************************************/ ?> <html> <head> <meta a http-equiv="Content-Type" content="text/html; charset=utf-8"> <title> CISP1720 Lab 6</title> </head> <h1> Lab 6 </h1> <h3> Input Form </h3> <body> <form action="CISP1720-dpatter3-Lab06.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/> <p> Please provide your ######. <input name="######" type="text" /><p/> <p> Please provide your Age. <input name="Age" type="text" /><p/> <input type="submit" name="Submit" id="Submit" value="Submit"></body></html>
  17. if (is_numeric($Fname)) || (is_numeric($Lname)) { echo "'{$Fname}' is numeric", PHP_EOL; echo "'{$Lname}' is numeric", PHP_EOL; } else { echo "'{$Fname}' is not numeric", PHP_EOL; echo "'{Lname}' is not numeric", PHP_EOL; } would that be right?
  18. that link i gave http://myphpform.com...ating-forms.php
  19. Would this be considered checking for empty? check_input($_POST['Fname'], "Enter your first name!") It says that this sends an error if the blank is still empty when submitted. ^ ^ ^but this is a function for all variables inputed. Can I make a function that checks them individually or do I have to manually do it, if so what code would i use to do so? example !empty(is_numeric($_POST['yourname'])); ??? < is that close? if yes how do I specify how many characters are allowed^does ! make it "is not empty"?
  20. I'm looking for what to write. What I have found is this http://myphpform.com/validating-forms.php but individually check each input variable with the list I posted above. Or can I use the function to individually validate each variable?
  21. Also the ###### says the normal word for gender is valid check. It is php validation of Form Input. Such as the htmlentities and htmlspecialchars ... How is asking for the code commands that do what I asked, end with him doing any of my work? By that with me being a student, how is me asking for specific code piece any different then googling it. And now that I've took a minute to read his answer I see that he ment to "look up" those words. I didn't understand completely.
  22. Could I get examples of those? please? Your not doing the work. I'm looking up the code to use. If you know a webpage that lists examples of those please post it. Also do I do all the validation like this? check_input($_POST['Fname'], "Enter your first name!")^minus this and + whatever I'm validating the Form information with.
  23. Can anyone provide me with the codes for these validation requirments. Names are not empty strings and are not numeric. They are also less than 20 characters long.###### contains a valid entry.Age is between 0 and 120.Output the data that was entered if all entries are valid, if an entry is invalid, print an error message describing data errors.
  24. Can anyone help me get this first part of my program to work. My form sends Start, End, and Increment... <?php $Start=$_GET["Start"]; $End=$_GET["End"]; $Increment=$_GET["Increment"]; if ($Increment < 0) { if($Start<=$End) { $inc = $Start; echo "<p> Start: $Start </p> \n"; While ($Start <= $End) { <------------ This loop needs to display inbetween output $Start/$End and increment from start to end. echo "<p>Increment = $inc</p> \n"; $inc = $inc + $Increment; echo "<p> Increment: $inc </p> \n"; } echo "<p> End: $End </p> \n"; }else { echo "<p><b> ERROR# The Starting Integer is greater then the Ending Integer. <b></p>" ; } } else { echo "<p><b> ERROR# Your increment number used is a negative. <b></p>" ; } ?>
×
×
  • Create New...