Jump to content

[SOLVED] Need help how to use two submit buttons in the same form


Recommended Posts

Why not just check if the username is not available when they post the data with the main submit button?

 

2 submit buttons is not a viable option in my opinion. Why make them post twice, when once is all that is needed.

pretty weird .. but yeah use different names for buttons and it's ok

..
<input type="submit" name="btnCheckUsername"/>
<input type="submit" name="btnSubmitForm"/>
..

Then you can check which one was clicked

if( isset( $_POST['btnCheckUsername'] ) )
{
    // do some username checks
}
elseif( isset( $_POST['btnSubmitForm'])  )
{
    // process the whole form
}

Thanks for your help.

Anyway i was just trying this because when user clicks check 'username' button if is available it will appear one image and if it is not then different image will appear that's why i was asking, any way thanks for your help

Well, I agree that you HAVE to check the username for uniqueness when the complete form data is ultimately submitted, but you *COULD* have another button to check the username. But, you would want to do so with AJAX - otherwise the user might enter data for the entire form and submit only to have the username checked. But, that gets more complex than just checking it on the complete form submission.

 

If you go with only checking it on the complete form submission (which you have to do anyway) you will have a working solution. You can aways add a feature for the user to check for available usernames at a later time.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.