WiredWX Christian Hobby Weather Tools
Would you like to react to this message? Create an account in a few clicks or log in to continue.

WiredWX Christian Hobby Weather ToolsLog in

 


descriptionform problems Emptyform problems

more_horiz
im trying to make something like phpmyadmin.

how to create database in phpmyadmin

my problem lies on the 3rd step. when the button "save" is clicked, all data will be sent to "another php page", and that page will be responsible for placing all data into the database.

when i'm on the "another php page" i can access all the data by using POST right?
but then the number of fields depend on the input of the user, so each "text area" "text box" "drop down" should have different name so i can access them, and place them on the database.


when the user inputs 3 in the number of fields, i use a for loop to create 3 rows with 8 columns.

so how can i validate all the data and send them to the database?

i know my explanation is not good im sorry, any help would really be appreciated. :smile2:

............................................................................................

form problems Charvi10

THIS SIGNATURE IS BY::: AGENT COSMIC ----------QUOTE BY:::TECHY

descriptionform problems EmptyRe: form problems

more_horiz
Yes, you need to give each input field a different name, so for example one of your text boxes for someone to enter their last name might look like this:

Code:


echo "<input type='text' name='surname' value='$surname' />";

Then when you retrieve the data from the form, you validate it like so:

Code:


if(isset($_POST['surname']))
  $surname = trim($_POST['surname']); // trim removes leading and trailing whitespace
else
  $surname = "";
if(strlen($surname) < 2)
{
  echo "Please enter a valid surname";
  die;
}
// if you get to here you have a valid surname, so it can be entered into the database using $surname

............................................................................................



There are no stupid questions, only those too stupid to ask for help.

descriptionform problems EmptyRe: form problems

more_horiz
thank you for your help, but i still don't know how to change the name of each textbox after the loop.... Indifferent or Blank

............................................................................................

form problems Charvi10

THIS SIGNATURE IS BY::: AGENT COSMIC ----------QUOTE BY:::TECHY

descriptionform problems EmptyRe: form problems

more_horiz
So if your for loop look like this:

Code:


for($i=0; $i<$number; $i++)

where $number is the number entered by the user, you can do this for your text boxes:

Code:


echo "<input type='text' name='first_field_name_$i' value='$somevalue' />";

This way, on each iteration, each field will have the suffix 0, 1, 2 etc. $i is evaluated because it is inside the double quotes in php. Does this help?

............................................................................................



There are no stupid questions, only those too stupid to ask for help.

descriptionform problems EmptyRe: form problems

more_horiz
privacy_tip Permissions in this forum:
You cannot reply to topics in this forum