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
https://forums.phpfreaks.com/topic/128484-problem-in-registration-form/
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.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.