...

View Full Version : Locked text Box



niko
04-21-2004, 12: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"

ANY IDEAS!!

firepages
04-21-2004, 03: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
?>

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

Just add the i"ndex.php?action=" when you process the form?
Like
$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>

niko
05-11-2004, 03: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?

cpradio
05-11-2004, 04: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}')";
mysql_query($sql);
}

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]}')";
mysql_query($sql);
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum