Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6795997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:24:50+00:00 2026-05-26T18:24:50+00:00

HTML: <form style=margin:5px 0; action=# method=post> Buyer <input type=radio name=addType value=Buyer /> &nbsp;&nbsp;Merchant <input

  • 0

HTML:

<form style="margin:5px 0;" action="#" method="post"> 
            Buyer <input type="radio" name="addType" value="Buyer" />
            &nbsp;&nbsp;Merchant <input type="radio" name="addType" value="Merchant" />
        </form>
        <form id="NewBuyerRegHp" method="post" action="check.php">
            Username or Email: <input type="text" name="userOrEmail" class="UserLogin" value="Username" onFocus="clearText(this)" /> <br />
            Password: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="password" name="userPass" class="UserLogin" value="Password" onFocus="clearText(this)"  /> <br />
            <input type="submit" name="SubmitNewBuyerHp" value="Secure Login" />
        </form>

PHP

$NewBuyerLoginCheck = mysql_query("SELECT uUName, uEmail, uUPass, dynamSalt FROM User WHERE uUName OR uEmail = '".mysql_real_escape_string($_POST['userOrEmail'])."' AND uUPass = sha2(concat(dynamSalt, '".mysql_real_escape_string($_POST['userPass'])."'), 512) ")or die(mysql_error());

$NewMerchLoginCheck = mysql_query("SELECT mUsername, mEmail, mUPass, mdynamSalt FROM Merchant WHERE mUsername OR mEmail = '".mysql_real_escape_string($_POST['userOrEmail'])."' AND mUPass = sha2(concat(dynamSalt, '".mysql_real_escape_string($_POST['userPass'])."'), 512) ")or die(mysql_error());


if(mysql_num_rows == 1){
echo "Success"; 
//then redirect the users homepage
}
else(mysql_num_rows == 0){
echo "Error"; 
// then redirect to original login form, for relogin
}

When radio button: value="Buyer" is chosen, it should run query $NewBuyerLoginCheck

When radio button: value="Merchant" is chosen, it should run query $NewMerchLoginCheck

How do I do this based on the radio button selected upon submit using Ajax?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T18:24:51+00:00Added an answer on May 26, 2026 at 6:24 pm

    html code if you using jQuery, you can do this:

    <script type="text/javascript" src="jquery-1.4.3.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){           
                $('#NewBuyerRegHp').submit(function() {
                    $.ajax({
                        type: 'POST',
                        url: $(this).attr('action'),
                        data: $(this).serialize(),
                        success: function(data) {
                            $('#ajax').html(data);
                        }
                    })
                    return false;
                });
            });
    </script>
    <form id="NewBuyerRegHp" method="post" action="check.php" style="margin:5px 0;">
        Buyer <input type="radio" name="addType" value="Buyer" checked="checked" /> <!-- Default value is checked -->
        Merchant <input type="radio" name="addType" value="Merchant" /><br />
        Username or Email: <input type="text" name="userOrEmail" class="UserLogin" placeholder="Username" /> <br />
        Password: <input type="password" name="userPass" class="UserLogin" placeholder="Password"  /> <br />
        <input type="submit" name="SubmitNewBuyerHp" value="Secure Login" />
    </form>
    <div id="ajax"></div> <!-- Check return value if using ajax -->
    

    Php code:

    <?php
    if (isset($_POST['addType']) && isset($_POST['userOrEmail']) && isset($_POST['userPass'])){
        if($_POST['addType'] == 'Buyer'){
            $NewBuyerLoginCheck = mysql_query("SELECT uUName, uEmail, uUPass, dynamSalt FROM User WHERE uUName OR uEmail = '".mysql_real_escape_string($_POST['userOrEmail'])."' AND uUPass = sha2(concat(dynamSalt, '".mysql_real_escape_string($_POST['userPass'])."'), 512) ") or die(mysql_error());
        } elseif($_POST['addType'] == 'Merchant'){
            $NewMerchLoginCheck = mysql_query("SELECT mUsername, mEmail, mUPass, mdynamSalt FROM Merchant WHERE mUsername OR mEmail = '".mysql_real_escape_string($_POST['userOrEmail'])."' AND mUPass = sha2(concat(dynamSalt, '".mysql_real_escape_string($_POST['userPass'])."'), 512) ") or die(mysql_error());
        }
        if(mysql_num_rows == 1){
            echo "Success";
            //then redirect the users homepage
        } elseif(mysql_num_rows == 0){
            echo "Error";
            // then redirect to original login form, for relogin
        }
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HTML <form style=margin:5px 0; action=# method=post> Buyer <input type=radio name=addType value=Buyer /> &nbsp;&nbsp;Merchant <input
I have following html form: <form method=post action=> <input type=hidden name=userid id=user value=<?php echo
I have an HTML string that has the following form: <tr valign=top><td colspan=2 style=padding-bottom:5px;text-align:
In an HTML form post what are valid characters for creating a multipart boundary?
I am creating an HTML form with some radio button options. I'd like to
I am implementing an HTML form with some checkbox input elements, and I want
I have a HTML form, and I have a Controller Action that accepts the
When I create a html form like this: $form = new Zend_Form(); $form->setMethod('post'); $form2->addElement('textarea',
Why does the following seemingly do nothing? <style> form { margin-left:auto; margin-right:auto; } h1
I want to style a form in html using CSS. It's a really simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.