how to handle multipe textbox using PHP
Moderator: General Moderators
how to handle multipe textbox using PHP
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
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
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
first, use php code tags
second, use forms instead of javascript
then on page2.php
bam there is your array on the 2nd page
second, use forms instead of javascript
Code: Select all
<form action="e;page2.php"e; method="e;get"e;>
<input type="e;text"e; name="e;some_nameї]"e;>
<input type="e;text"e; name="e;some_nameї]"e;>
</form>Code: Select all
print_r($_GET[some_name]);post your code within code or php tags you should.
much easier to read it is:
buttonchk.htm:
buttonrcv.php:
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?
much easier to read it is:
buttonchk.htm:
Code: Select all
<!DOCTYPE HTML PUBLIC \"e;-//W3C//DTD HTML 4.01 Transitional//EN\"e;>
<html><head><title>Untitled Document</title>
<meta http-equiv=\"e;Content-Type\"e; content=\"e;text/html; charset=iso-8859-1\"e;></head><body>
<form name=\"e;MyForm\"e;>
<input name=\"e;remarksї]\"e; type=\"e;text\"e; size=\"e;20\"e; maxlength=\"e;200\"e;>
<input name=\"e;remarksї]\"e; type=\"e;text\"e; size=\"e;20\"e; maxlength=\"e;200\"e;>
<button style=\"e;background:#FFFFFF;width:50\"e; onClick=\"e;location='date.php?remarks='+document.MyForm.remarksї].value\"e;>Done</button>
</form>
</body></html>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>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
I don't know what the deal with all this js is. O.o
Code: Select all
<!DOCTYPE HTML PUBLIC \"e;-//W3C//DTD HTML 4.01 Transitional//EN\"e;>
<html><head><title>Untitled Document</title>
<meta http-equiv=\"e;Content-Type\"e; content=\"e;text/html; charset=iso-8859-1\"e;></head><body>
<form name=\"e;MyForm\"e;>
<input name=\"e;remarksї]\"e; type=\"e;text\"e; size=\"e;20\"e; maxlength=\"e;200\"e;>
<input name=\"e;remarksї]\"e; type=\"e;text\"e; size=\"e;20\"e; maxlength=\"e;200\"e;>
<input style=\"e;background:#FFFFFF;width:50\"e; type=\"e;submit\"e; value=\"e;Done\"e; />
</form>
</body></html>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>