View Full Version : Locked text Box

04-21-2004, 01:50 PM
Ive created a insert form behaviour in php to mysql database, i one text box i want to let the user insert text and submit the form.

However i want to insert "index.php?action=", before the users entered text, and submit the whole thing as one field,

eg, "index.php?action=ENTEREDTEXT"


04-21-2004, 04:18 PM
just add the string before you put it into the db

$_POST[$textfield] = 'index.php?action=' . $_POST[$textfield] ;
$sql = "INSERT INTO $table SET $textfield='{$_POST[$textfield]}'";// etc

04-21-2004, 04:20 PM
Welcome here !

Just add the i"ndex.php?action=" when you process the form?
$text= 'index.php?action='. $_POST['text'];

or if the text you want to prefix isn't always the same, then store that inside a hidden formfield, and dosomething like

$text= $_POST['prefix'] . $_POST['text'];

<edit>posts crossed. Seams we're both on the same track</edit>

05-11-2004, 04:50 PM
I have a list box which is set up for multiple selections. I have the insert Server Behavior set up for the list box fields. If the user selects more than one item from the list box and then submits only the first item selected is being inserted into the table. Can I do multiple inserts into a table using a list box?

05-11-2004, 05:35 PM
Yes, the easiest way in my opinion is to make the HTML form names arrays:

ie: name="whatever[]"

Then in your PHP code, best way to insert or update is using a foreach function:

foreach($_POST['whatever'] as $key => $val) {
$sql = "INSERT into Table (`first_column`) VALUES ('{$val}')";

Of course you will have several arrays and so you can reference them all in the same foreach by doing the following:

foreach($_POST['whatever'] as $key => $val) {
$sql = "INSERT into Table (`first_column`,`second_column`) VALUES ('{$val}','{$_POST['second_form_field'][$key]}')";