Welcome Guest, Not a member yet? Register   Sign In
Cancel button on a form
#11

[eluser]Aken[/eluser]
Also nothing meant by it, just added information / recommendations. His original issue had suitable answers already, and I figured I'd elaborate on the extended topic.
#12

[eluser]Colin Williams[/eluser]
I wasn't really condemning anyone, but the crux of the issue was:
Quote:The problem is then that the POST array contains an array_key ‘submitOK’, which unlike all other POST entries does not correspond to an a database field for my INSERT action.

It seemed like that had been lost so I'm bringing it back to the fore.
#13

[eluser]Aken[/eluser]
The first four people offered functioning solutions to a cancel button. *shrug*

Oh, and reading the original post again, I'd recommend not doing a straight INSERT query using the raw $_POST array. Specify which columns of data you want to insert and pull the info from the array in the code. Raw $_POST array just seems dirty and cheap (and DEFINITELY bad if you aren't sanitizing the data).
#14

[eluser]xzela[/eluser]
[quote author="JoostV" date="1258372978"]Most Web forms would have improved usability if the Reset button was removed.[/quote]

"The Web is not an application environment...." huh?

I'm no expert on usability but, this article was compiled 9 years ago. The face of the web has changed quite a bit since then. I'm sure he means well but his concepts are starting to show their age.
#15

[eluser]andrewtheandroid[/eluser]
I only suggested a cancel button as a link as it doesn't make sense to me to have it as a button unless you were doing some sort of secure transactions? Maybe you need a confirmation of cancellation? And the other suggestions involved javascript so I was offering a javascript-free alternative.

Also I agree with Aken against dumping the post array inside the database as errors may be generated if you post extra fields to it (maybe someone can manually post things to your site).

I would suggest an array of the values you want to insert into your database
Code:
$params = array('name','email','contact','address'); // desired fields
$insert_values = array(); // pass this into your database
foreach ($params as $key)
{
    $insert_values[$key] = $this->input->post($key);
}

// then instead of where you have $_POST in your database
$this->db->insert('my_table',$insert_values);

Sorry i missed the second part of the question.
#16

[eluser]andrewtheandroid[/eluser]
Hi Dan If you ommit the name fields from the submit and cancel buttons and then they will not be in the post array. I just had a go then and checked using firebug.

[quote author="pancake" date="1257095061"]

Code:
<input type="submit" <?php /*name="submitOK"*/?>      value="Submit Comment" />
<input type="submit" <?php /*name="submitCancel"*/?>  value="Cancel" />
[/quote]




Theme © iAndrew 2016 - Forum software by © MyBB