Discussing Html . Code , Software , other
Moderators: macek, egami, gesf
by Kshitiz » Tue Dec 21, 2010 7:21 pm
HI,
I am trying to retrieve the posted data in form but POST array is empty after posting the form.
Here's the code:
<?php
if(isset($_POST['txtUserName']))
{
//Put Your code Here
$userService = $_POST['txtUserName'];
}
?>
<form name="login" action="../Forms/Login.php" method="post" onsubmit="javascript: alert('form submitted');">
<table class="tableWithBorder" width="100%" align="center" cellpadding="5" cellspacing="5">
<tr>
<td class="bold">User Name </td>
<td><input name="txtUserName" id="txtUserName" type="text" /></td>
</tr>
<tr>
<td class="bold">Password </td>
<td><input name="txtPassword" id="txtPassword" type="password" /></td>
</tr>
<tr>
<td colspan="2" align="center">
<input onclick="javascript: return Validate();" name="btnLogin" id="btnLogin" type="submit" value="Login" /> </td>
</tr>
</table>
</form>
What cud be the possble solution for this problem. Please help
-
Kshitiz
- New php-forum User

-
- Posts: 1
- Joined: Tue Dec 21, 2010 7:15 pm
by lokanath7 » Wed Dec 22, 2010 7:31 am
hey Kshitiz,
u r getting the form posted value bt u hv nt printed it and instead of txtbox name use submit btn name.
try this
<?php
if(isset($_POST['btnLogin']))
{
//Put Your code Here
echo $userService = $_POST['txtUserName'];
echo $txtPassword = $_POST['txtPassword'];
}
?>
<form name="login" action="" method="post" onsubmit="javascript: alert('form submitted');">
<table class="tableWithBorder" width="100%" align="center" cellpadding="5" cellspacing="5">
<tr>
<td class="bold">User Name </td>
<td><input name="txtUserName" id="txtUserName" type="text" /></td>
</tr>
<tr>
<td class="bold">Password </td>
<td><input name="txtPassword" id="txtPassword" type="password" /></td>
</tr>
<tr>
<td colspan="2" align="center">
<input onclick="javascript: return Validate();" name="btnLogin" id="btnLogin" type="submit" value="Login" /> </td>
</tr>
</table>
</form>
-
lokanath7
- New php-forum User

-
- Posts: 139
- Joined: Mon Nov 15, 2010 12:11 am
Return to HTML Basics
Who is online
Users browsing this forum: No registered users and 1 guest