Jump to content

problem in registration form


amit_n

Recommended Posts

Hi,

 

I have "registration form" in Html. This form has text fields like loginid, password, email, address, zip, etc.

I want to check the loginid is available or not before submitting the form. For that i have given following link in html form just below to the loginid text field.

<div align="left"><a href="checkid.php?action=CheckID">Check the availability</a></div>

 

And checkid.php has following code.

 

<?php $loginid = $_POST['loginid'];mysql_connect("localhost", "root") or die("Cannot connect to DB!");mysql_select_db("loginsys") or die("Cannot select DB!");$r = mysql_query("SELECT * FROM login_tbl where loginid='$loginid';");$numrow = mysql_num_rows($r);if ($numrow == 0){print "This UserID is available";include "register1.html";}else{print "This UserID is not available";} ?>

But the problem is after selecting the link for  checkid.php the $_POST['loginid'] is considered as blank. This is may be because I am not submitting the form.

Is there any other way to get $_POST['loginid'] value without choosing the submit button?

Can i pass the value of $_POST['loginid'] without choosing the submit button?

 

[/]

Link to comment
Share on other sites

yeah you could use ajax.  If you would lik to stick with php for nw u can do that too witha little bit of javascript.

 

The form can be divided into two. have the login filed in a separate form and the rest of the fields in another form

eg:

 

 

        <?php
                 if(isset($_POST["check"]))
                      {
                           $user   = $_POST["user"];
                             }

?>
<form action="register.php" method="POST" name="form1">

       <tr> 
      <td class="textsr">Username*</td><td><input name="user" type="text" class="textbox" value="<?php echo $user;?>">
          <input name="check" type="submit" value="check availability" class="button">
                           </td>
  <tr>
     
   <td></td>
      
      <td class="textsr">
        <?php
if(isset($_POST["check"]) && ($_POST["user"]!="") && (trim($_POST["user"])!=''))
{$user=trim($_POST["user"]);

$res=mysql_query("select * from table where username='$user'");
$trows=mysql_num_rows($res);
if($trows==0)
{
  echo "<font color='green'>The username is available</font>";
  
  }
  else
  {
     echo "<font color='red'>The username is not available.<br>Please select another one</font>";
 }
}else
{
echo "";
} ?>
      </td>
  
</form>

 

This way you can have the message appear right under the username box.

 

 

Link to comment
Share on other sites

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.