how to handle multipe textbox using PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
shseraj
Forum Newbie
Posts: 2
Joined: Thu Jun 02, 2005 12:46 am

how to handle multipe textbox using PHP

Post by shseraj »

Dear all,

I'm facing a problem to handle multiple textbox. I'm using two textbox with the same name. And a button, onclick that button it will take to a php page where i can retrive values given in the textbox in first page. I just want to pass all the data given in the buttonchk.htm to the next page buttonrcv.php by using array. I tried with the name="remark[]" but it says error in page. Please help me out!

buttonchk.htm:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html><head><title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body>

<input name="remarks" type="text" size="20" maxlength="200">

<input name="remarks" type="text" size="20" maxlength="200">

<button style="background:#FFFFFF;width:50" onClick="window.location.href='buttonrcv.php?remarks='+remarks.value">Done</button>

</body></html>


buttonrcv.php:

<html><head><title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>
<?php

$remark[] = $_GET["remarks"];

echo $remark[0];
echo $remark[1];
?>
</body></html>



Reagrds
poor Sahrear
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

first, use php code tags

second, use forms instead of javascript

Code: Select all

&lt;form action=&quote;page2.php&quote; method=&quote;get&quote;&gt;
&lt;input type=&quote;text&quote; name=&quote;some_name&#1111;]&quote;&gt;
&lt;input type=&quote;text&quote; name=&quote;some_name&#1111;]&quote;&gt;
&lt;/form&gt;
then on page2.php

Code: Select all

print_r($_GET[some_name]);
bam there is your array on the 2nd page
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

post your code within code or php tags you should.

much easier to read it is:

buttonchk.htm:

Code: Select all

&lt;!DOCTYPE HTML PUBLIC \&quote;-//W3C//DTD HTML 4.01 Transitional//EN\&quote;&gt; 

&lt;html&gt;&lt;head&gt;&lt;title&gt;Untitled Document&lt;/title&gt; 
&lt;meta http-equiv=\&quote;Content-Type\&quote; content=\&quote;text/html; charset=iso-8859-1\&quote;&gt;&lt;/head&gt;&lt;body&gt; 

&lt;form name=\&quote;MyForm\&quote;&gt;
&lt;input name=\&quote;remarks&#1111;]\&quote; type=\&quote;text\&quote; size=\&quote;20\&quote; maxlength=\&quote;200\&quote;&gt; 

&lt;input name=\&quote;remarks&#1111;]\&quote; type=\&quote;text\&quote; size=\&quote;20\&quote; maxlength=\&quote;200\&quote;&gt; 

&lt;button style=\&quote;background:#FFFFFF;width:50\&quote; onClick=\&quote;location='date.php?remarks='+document.MyForm.remarks&#1111;].value\&quote;&gt;Done&lt;/button&gt; 
&lt;/form&gt;

&lt;/body&gt;&lt;/html&gt;
buttonrcv.php:

Code: Select all

<html><head><title>Untitled Document</title> 
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"></head> 
<body> 
<?php 
echo $_GET['remarks'][0]; 
echo $_GET['remarks'][1]; 
?> 
</body></html>
works this does with FF, tested with IE I have not.

edit: why I want to know does the board now escape all slashes in code tags?
malcolmboston
DevNet Resident
Posts: 1826
Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK

Post by malcolmboston »

sound like yoda, you do :lol:
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Yes, and php-tags shseraj must use!
shseraj
Forum Newbie
Posts: 2
Joined: Thu Jun 02, 2005 12:46 am

Post by shseraj »

Dear Burrito,

I think the solution you posted does not work with IE. I need a solution for IE. And the Web server is IIS. I hope you understand my problem. Please reply me soon.

Kind Regards
Sahrear
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

I don't know what the deal with all this js is. O.o

Code: Select all

<!DOCTYPE HTML PUBLIC \&quote;-//W3C//DTD HTML 4.01 Transitional//EN\&quote;> 
 
<html><head><title>Untitled Document</title> 
<meta http-equiv=\&quote;Content-Type\&quote; content=\&quote;text/html; charset=iso-8859-1\&quote;></head><body> 
 
<form name=\&quote;MyForm\&quote;>
<input name=\&quote;remarks&#1111;]\&quote; type=\&quote;text\&quote; size=\&quote;20\&quote; maxlength=\&quote;200\&quote;> 
 
<input name=\&quote;remarks&#1111;]\&quote; type=\&quote;text\&quote; size=\&quote;20\&quote; maxlength=\&quote;200\&quote;> 

<input style=\&quote;background:#FFFFFF;width:50\&quote; type=\&quote;submit\&quote; value=\&quote;Done\&quote; /> 
</form>
 
</body></html>
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

this worked fine for me in IE

Code: Select all

<?
if(isset($_GET['blah'])){
echo $_GET['bob'][0];
echo "<br>".$_GET['bob'][1];
echo "<br>".$_GET['bob'][2];
}
?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<title>Untitled</title>
</head>

<body>
<form method="get">
<input type="text" name="bob[]">
<input type="text" name="bob[]">
<input type="text" name="bob[]">
<input type="submit" name="blah">
</form>


</body>
</html>
Post Reply