I have the following HTML form
<form id="form2" name="form2" method="post" action="process.php">
<table width="271" border="1">
<tr>
<td width="5"><input name="txtIdone2" type="text" id="txtIdone2" value="Richard" /></td>
<td width="250">
<label for="txtIdone"></label>
<input name="txtIdone" type="text" id="txtIdone" value="Hopes" />
</td>
</tr>
<tr>
<td><input name="txtIdone3" type="text" id="txtIdone3" value="Testing" /></td>
<td><input name="txtIdone4" type="text" id="txtIdone4" value="this" /></td>
</tr>
<tr>
<td><input name="txtIdone5" type="text" id="txtIdone5" value="it" /></td>
<td><input name="txtIdone6" type="text" id="txtIdone6" value="works" /></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="btnTest" id="btnTest" value="Submit" />
</td>
</tr>
</table>
</form>
That submits to process.php that has the following code:
$data = array($_POST);
print_r ($data);
Simple. However, instead of a regular array being returned, i'm receiving a multi array. Here is an example:
Array
(
[0] => Array
(
[txtIdone2] => Richard
[txtIdone] => Hopes
[txtIdone3] => Testing
[txtIdone4] => this
[txtIdone5] => it
[txtIdone6] => works
)
)
I just want a regular array returned. What am I doing wrong?
Thanks.
$_POST is already an array.
By doing $data = array($_POST); you are making the array multidimensional.
Try doing simply:
print_r($_POST);
Related
I started writing html code and when I view it on chrome, the table is displayed after a long white space. When I inspect the element, on chrome, I get a lot of br tags but I have not given any br tags in the code
How come?
<!DOCTYPE html>
<head>
<title> Practice </title>
</head>
<body>
<table border="0.00001" align="center" bgcolor="silver">
<caption align="center"> <big><big><b> Registration Form </b><big><big> </caption><br><br>
<form name="My Form" action="" method="">
<tr>
<td> Username </td>
<td> <input type="text" name="t1" size="6"/> </td>
</tr><br><br>
<tr>
<td> Password </td>
<td> <input type="password" name="t2" size="6"/> </td>
</tr><br><br>
<tr>
<td> Name </td>
<td> <input type="text" name="t3" size="30"/> </td>
</tr><br><br>
<tr>
<td> Address </td>
<td> <input type="text" name="t4" size="30"/> </td>
</tr><br><br>
<tr>
<td> Country </td>
<td><select name="s1">
<option> Select Your Country </option>
<option> Afghanistan </option>
<option> Bangladesh </option>
<option> China </option>
<option> India </option>
<option> Russia </option>
</select></td>
</tr><br><br>
<tr>
<td> Zip Code </td>
<td> <input type="text" name="t5" size="6"/> </td>
</tr><br><br>
<tr>
<td> Email </td>
<td> <input type="text" name="t6" size="30"/> </td>
</tr><br><br>
<tr>
<td>Sex</td>
<td><input type="radio" name="r1" value="100" checked/>Male
<input type="radio" name="r1" value="102"/>Female</td>
</tr><br><br>
<tr>
<td>Language</td>
<td><input type="checkbox" name="r1" value="100" checked/>English
<input type="checkbox" name="r2" value="102"/>Non English</td>
</tr><br><br>
<tr>
<td> About </td>
<td><textarea name="a1" rows="5" cols="32"> </textarea></td>
</tr><br><br>
<tr align="centre">
<td><input type="submit" name="b2" value="submit here"/></td>
</tr><br><br>
</form>
</table>
I don't think this is <br>. Use Inspect Element to check what's causing so much gap before table. There might be some kind of margin before table.
You have a lot of unnecessary "br" tags in your code, inside your table. Remove them all and all will be fine! Cheers.
Use this code, This might solve your issues
<table border="0.00001" align="center" bgcolor="silver" cellpadding="10">
<caption align="center"><b> Registration Form </b> </caption><br><br>
<form name="My Form" action="" method="">
<tr>
<td> Username </td>
<td> <input type="text" name="t1" size="6"/> </td>
</tr>
<tr>
<td> Password </td>
<td> <input type="password" name="t2" size="6"/> </td>
</tr>
<tr>
<td> Name </td>
<td> <input type="text" name="t3" size="30"/> </td>
</tr>
<tr>
<td> Address </td>
<td> <input type="text" name="t4" size="30"/> </td>
</tr>
<tr>
<td> Country </td>
<td><select name="s1">
<option> Select Your Country </option>
<option> Afghanistan </option>
<option> Bangladesh </option>
<option> China </option>
<option> India </option>
<option> Russia </option>
</select></td>
</tr>
<tr>
<td> Zip Code </td>
<td> <input type="text" name="t5" size="6"/> </td>
</tr>
<tr>
<td> Email </td>
<td> <input type="text" name="t6" size="30"/> </td>
</tr>
<tr>
<td>Sex</td>
<td><input type="radio" name="r1" value="100" checked/>Male
<input type="radio" name="r1" value="102"/>Female</td>
</tr>
<tr>
<td>Language</td>
<td><input type="checkbox" name="r1" value="100" checked/>English
<input type="checkbox" name="r2" value="102"/>Non English</td>
</tr>
<tr>
<td> About </td>
<td><textarea name="a1" rows="5" cols="32"> </textarea></td>
</tr>
<tr align="centre">
<td><input type="submit" name="b2" value="submit here"/></td>
</tr>
</form>
</table>
Just removed some un-necessary tags, that might be causing issues. Please try
You had a lot of LF in your page. You need to check your editor
Also you had invalid tags and missed CSS
Here is a fixed version that validates
<!DOCTYPE html>
<html>
<head>
<title> Practice </title>
<style>
table {
border: 0.00001px;
background-color: silver;
margin: 0px auto;
}
caption {
text-align: center;
font-size: x-large;
}
.center {
text-align: center;
}
</style>
</head>
<body>
<form name="MyForm">
<table>
<caption>Registration Form</caption>
<tr>
<td>Username</td>
<td>
<input type="text" name="t1" size="6" /> </td>
</tr>
<tr>
<td>Password</td>
<td>
<input type="password" name="t2" size="6" /> </td>
</tr>
<tr>
<td>Name</td>
<td>
<input type="text" name="t3" size="30" /> </td>
</tr>
<tr>
<td>Address</td>
<td>
<input type="text" name="t4" size="30" /> </td>
</tr>
<tr>
<td>Country</td>
<td>
<select name="s1">
<option> Select Your Country </option>
<option> Afghanistan </option>
<option> Bangladesh </option>
<option> China </option>
<option> India </option>
<option> Russia </option>
</select>
</td>
</tr>
<tr>
<td>Zip Code</td>
<td>
<input type="text" name="t5" size="6" /> </td>
</tr>
<tr>
<td>Email</td>
<td>
<input type="text" name="t6" size="30" /> </td>
</tr>
<tr>
<td>Gender</td>
<td>
<input type="radio" name="r1" value="100" checked/>Male
<input type="radio" name="r1" value="102" />Female</td>
<input type="radio" name="r1" value="103" />Irrelevant</td>
</tr>
<tr>
<td>Language</td>
<td>
<input type="checkbox" name="r1" value="100" checked/>English
<input type="checkbox" name="r2" value="102" />Non English</td>
</tr>
<tr>
<td>About</td>
<td>
<textarea name="a1" rows="5" cols="32"> </textarea>
</td>
</tr>
<tr>
<td class="center" colspan="2">
<input type="submit" name="b2" value="submit here" />
</td>
</tr>
</table>
</form>
</body>
</html>
I am new to wordpress, and I have build a plugin that just saves settings on the admin menu.
But when I click on the save button it just takes me to the options.php page and doesn't do anything. I have looked over my code a couple of times, and I can't seem to find why its not saving, and just stays at the options.php page.
Any help would be really appreciated!! Thanks
function fflOptionsMenuLink(){
add_options_page("Facebook Footer Link Options", "Facebook Footer Link","manage_options","ffl-options","fflOptionsContent" );
}
function fflOptionsContent(){
$opt = get_option("ffl_settings");
$output = "<div class='wrap'>
<h2>Facebook footer link settings </h2>
<form method='post' action='options.php' id='ffl_settings_group'>";
settings_fields('ffl_settings_group');
$output .= "<table class='form-table'>
<tbody>
<tr>
<th scope='row'><label for='ffl_settings[enable]'>Enable</label> </th>
<td><input name='ffl_settings[enable]' type='checkbox' id='ffl_settings[enable]' value='1' ></td>
</tr>
<tr>
<th scope='row'><label for='ffl_settings[facebook_url]'>Facebook Profile </label> </th>
<td><input name='ffl_settings[facebook_url]' type='text' id='ffl_settings[facebook_url]' value='{$opt["ffl_settings"]}' class='regular-text' ></td>
</tr>
<tr>
<th scope='row'><label for='ffl_settings[link_color]'>Enter color or hex value</label> </th>
<td><input name='ffl_settings[link_color]' type='text' id='ffl_settings[link_color]' value='{$opt["link_color"]}' class='regular-text' ></td>
</tr>
<tr>
<th scope='row'><label for='ffl_settings[show_in_feed]'>Show in feed</label> </th>
<td><input name='ffl_settings[show_in_feed]' type='checkbox' id='ffl_settings[show_in_feed]' value='1' ></td>
</tr>
</tbody>
</table>
<p class='submit'><input type='submit' name='submit' id='submit' class='button button-primary' value='Submit'> </p>
";
$output .= "</form>";
$output.="</div>";
echo $output;
}
add_action("admin_menu","fflOptionsMenuLink");
//Register Settings
function fflRegisterSetting(){
register_setting("ffl_settings_group","ffl_settings");
}
add_action("admin_init","ffl_register_setting");
Few Things...
ISSUE - Your function name for registering settings fflRegisterSetting not ffl_register_setting as in your hook.
ISSUE - You are not outputting submit button by wp function
Reminder - facebook_url field has value wrong $opt["link_color"], but since checkboxes are not ready either so I'll consider this a WIP ;)
So your code should look something like this -
function fflOptionsMenuLink(){
add_options_page("Facebook Footer Link Options", "Facebook Footer Link","manage_options","ffl-options","fflOptionsContent" );
}
function fflOptionsContent(){
$opt = get_option("ffl_settings");
echo "<div class='wrap'>
<h2>Facebook footer link settings </h2>
<form method='post' action='options.php' id='ffl_settings_group'>";
settings_fields('ffl_settings_group');
echo "<table class='form-table'>
<tbody>
<tr>
<th scope='row'><label for='ffl_settings[enable]'>Enable</label> </th>
<td><input name='ffl_settings[enable]' type='checkbox' id='ffl_settings[enable]' value='1' ></td>
</tr>
<tr>
<th scope='row'><label for='ffl_settings[facebook_url]'>Facebook Profile </label> </th>
<td><input name='ffl_settings[facebook_url]' type='text' id='ffl_settings[facebook_url]' value='{$opt["facebook_url"]}' class='regular-text' ></td>
</tr>
<tr>
<th scope='row'><label for='ffl_settings[link_color]'>Enter color or hex value</label> </th>
<td><input name='ffl_settings[link_color]' type='text' id='ffl_settings[link_color]' value='{$opt["link_color"]}' class='regular-text' ></td>
</tr>
<tr>
<th scope='row'><label for='ffl_settings[show_in_feed]'>Show in feed</label> </th>
<td><input name='ffl_settings[show_in_feed]' type='checkbox' id='ffl_settings[show_in_feed]' value='1' ></td>
</tr>
</tbody>
</table>
";
submit_button(); // Get the submit button from this function
echo "</form>";
echo "</div>";
}
add_action("admin_menu","fflOptionsMenuLink");
//Register Settings
function fflRegisterSetting(){
register_setting("ffl_settings_group","ffl_settings");
}
add_action("admin_init","fflRegisterSetting");
I am trying to have my form in a table but it generates a table and makes it a mess.
the generated table is as following:
<div>
<s:form action="myaction" >
<table border="1">
<tr>
<td><s:textfield name="name" label="Name" /></td>
<td><s:textfield name="family" label="Family" /></td>
<td><s:submit/></td>
</tr>
</table>
</s:form>
</div>
Source code :
<div>
<form id="myaction" name="myaction" action="/application/myaction.action" method="post">
<table class="wwFormTable"> <<<generated table
<table border="1">
<tr>
<td><tr>
<td class="tdLabel"><label for="Search_Name" class="label">Name:</label></td>
<td
><input type="text" name="Name" value="" id="Search_Name"/></td>
</tr>
</td>
<td><tr>
<td class="tdLabel"><label for="Search_Family" class="label">Family:</label></td>
<td
><input type="text" name="Family" value="" id="Search_Family"/></td>
</tr>
</td>
<td><tr>
<td colspan="2"><div align="right"><input type="submit" id="Search_0" value="Submit"/>
</div></td>
</tr>
</td>
</tr>
</table>
</table></form>
Use the "simple" theme if you do not want to use S2's default "xhtml" theme.
You'll lose S2's automatic error reporting. You may wish to consider creating your own theme.
Alternatively, you can use the "simple" theme on individual controls.
See the "Themes and templates" docs to get started.
Try to use any theme in struts form tag
eg:
<s:form action="Courses" theme="css_xhtml">
<table border="0">
<tr>
<td><s:textfield name="courseAbbr" /></td>
</tr>
</table>
</s:form>
May Be you should use this code instead...
<sp:form >
<tr>
<td>
<table>
<sp:textfield name="name"></sp:textfield>
</table>
</td>
<td>
<table>
<sp:textfield name="family"></sp:textfield>
</table>
</td>
<td>
<table>
<sp:submit/>
</table>
</td>
</tr>
</sp:form>
My engine is Aspx.
I am currently having trouble editing one of my columns(Question Answer) in my table because it has html tags in it. Is there a way I can decode only that specific row/column in the value area?
<form id="updateFreqQuestionsUser" action="<%=Url.Action("SaveFreqQuestionsUser","Prod")%>" method="post">
<table>
<tr>
<td colspan="3" class="tableHeader">Freq Questions User Details <input type ="hidden" value="<%=freqQuestionsUser.freqQuestionsUserId%>" name="freqQuestionsUserId"/> </td>
</tr>
<tr>
<td colspan="2" class="label">Question Description:</td>
<td class="content">
<input type="text" maxlength="2000" name="QuestionDescription" value="<%=freqQuestionsUser.questionDescription%>" />
</td>
</tr>
<tr>
<td colspan="2" class="label">QuestionAnswer:</td>
<td class="content">
<input type="text" maxlength="2000" name="QuestionAnswer" value="<%=freqQuestionsUser.questionAnswer%>" />
</td>
</tr>
<tr>
<td colspan="3" class="tableFooter">
<br />
<a id="freqQuestionsUserUpdateButton" href="#" class="regularButton">Save</a>
Cancel
</td>
</tr>
</table>
Yes, you can do this:
<input type="text" maxlength="2000" name="QuestionAnswer"
value="<%=Server.HtmlDecode(freqQuestionsUser.questionAnswer)%>" />
Reference
The browser is displaying "System.Web.Mvc.Html.MvcForm" next to my form. How can I hide it?
Here is the form code.
#Html.BeginForm("NewComment", "Difficultes", FormMethod.Post)
{
#Html.HiddenFor(m => m.diff.id_diff)
<table>
<tr><label><b>Nouveau commentaire</b></label></tr>
<tr>
<td><b>Nom :</b></td><td>#Html.TextBoxFor(m=>m.pseudo)</td>
</tr>
<tr>
<td><b>Commentaire :</b></td><td>#Html.TextAreaFor(m=>m.nouveau)</td>
</tr>
</table>
<input type="submit" value="Ajouter" />
}
Change your code to (Add the #using):
#using (Html.BeginForm("NewComment", "Difficultes", FormMethod.Post))
{
#Html.HiddenFor(m => m.diff.id_diff)
<table>
<tr><label><b>Nouveau commentaire</b></label></tr>
<tr>
<td><b>Nom :</b></td><td>#Html.TextBoxFor(m=>m.pseudo)</td>
</tr>
<tr>
<td><b>Commentaire :</b></td><td>#Html.TextAreaFor(m=>m.nouveau)</td>
</tr>
</table>
<input type="submit" value="Ajouter" />
}
Change the line #Html.BeginForm("NewComment", "Difficultes", FormMethod.Post)
to #using(Html.BeginForm("NewComment", "Difficultes", FormMethod.Post))