Jump to content

Recommended Posts

<?phpsession_start();if(isset($_SESSION['userid'])) {  if($_SESSION['level']==1)	 {	 echo "<div id='navbar'></div>";	 header('Refresh: 5; URL=admin.php');	 echo "<div id='content'>";	 echo "<p><br>You are already logged-in as admin, and will be re-directed to your home page.</br>";	 echo "If your browser doesnot redirect you automatically, <a href='admin.php'>click here</a>.</p>";	 include "footer.php";	 exit;	 }  if($_SESSION['level']==2)	 {	 echo "<div id='navbar'></div>";	 header('Refresh: 5; URL=mypage.php');	 echo "<div id='content'>";	 echo "<p><br>You are already logged-in as a contractor, and will be re-directed to your home page.</br>";	 echo "If your browser doesnot redirect you automatically, <a href='mypage.php'>click here</a>.</p>";	 include "footer.php";	 exit;	 } }if($_SERVER['REQUEST_METHOD'] == 'POST')  {   if(strlen($_POST['contractor_name']) !='' && strlen($_POST['contractor_password']) !='' && strlen($_POST['address']) !='' && strlen($_POST['tin_no']) !='')   {    require("db-connect.php");    $db = db_connect();    if($db)	 {	  $contractor_name = mysql_real_escape_string($_POST['contractor_name'], $db);	  $contractor_password = mysql_real_escape_string($_POST['contractor_password'], $db);	  $contractor_type = mysql_real_escape_string($_POST['contractor_type'], $db);	  $address = mysql_real_escape_string($_POST['address'], $db);	  $tin_no = mysql_real_escape_string($_POST['tin_no'], $db);	  $sql = "INSERT INTO contractor (contractor_id, contractor_name, contractor_password, contractor_type, address, tin_no, level)			  VALUES ('', '$contractor_name', '$contractor_password', '$contractor_type', '$address', '$tin_no', 2)";	  mysql_query($sql, $db) or die(mysql_error($db));	  	  $_SESSION['contractor_id'] = mysql_insert_id($db);	  $_SESSION['level'] = 2;	  $_SESSION['contractor_name'] = $contractor_name;	 }	 header('Location: mypage.php');	 exit();    }  }include "header.php";?><body><div id="navbar"><table align="center"> <tr>  <td><a href="index.html">Home</a></td>  <td><a href="about.php">About Us</a></td>  <td><a href="contact.php">Contact us</td>  <td><a href="register.php">Register</a></td>  <td><a href="login.php">Login</a></td> </tr></table></div>  <div id="content"><br><div id="msg">Fill in your details to register. Use lowercase 'username' and 'password'</div><br><form name="register" method="POST" action="register.php"><table align="center"> <tr>  <td>Username:</td><td><input type="text" name="contractor_name" value="<?php if(isset($_POST['submit']) && (strlen($_POST['contractor_name']) > 0 || strlen($_POST['contractor_name']) < 11)) echo $_POST['contractor_name']; ?>"></td><?php if(isset($_POST['submit']) && (strlen($_POST['contractor_name']) < 1 || strlen($_POST['contractor_name']) >10)) echo "<div id='rusr-err'>Username must be 1 to 10 chars<div>"; ?> </tr> <tr>  <td>Password:</td><td><input type="password" name="contractor_password"></td><?php if(isset($_POST['submit']) && (strlen($_POST['contractor_password']) < 1 || strlen($_POST['contractor_password']) > 10)) echo "<div id='rpas-err'>Password must be 1 to 10 chars<div>"; ?> </tr> <tr>  <td>Contractor type:</td><td><input name="contractor_type" type="radio" checked="checked" value="1" style="width: 20px">Firm <input name="contractor_type" type="radio" value="2">Company <input name="contractor_type" type="radio" value="3">Individual </tr> <tr><td>Address:</td>  <td><textarea name="address" cols="20" rows="2"></textarea></td><?php if(isset($_POST['submit']) && strlen($_POST['address']) < 1) echo "<div id='raddress-err'>Address cannot be blank.<div>"; ?> </tr>  <tr>  <td>Tin no:</td><td><input type="text" name="tin_no" value="<?php if(isset($_POST['submit']) && (strlen($_POST['tin_no']) == 18)) echo $_POST['tin_no']; ?>"></td><?php if(isset($_POST['submit']) && (strlen($_POST['tin_no']) != 18)) echo "<div id='rtin-err'>Tin number must be 18 digits.<div>"; ?> </tr> <tr>  <td></td><td align="center"><input name="submit" type="submit" value="Register"> <input type="reset"></td> </tr></table></form></div><?phpinclude "footer.php";?>

This is a register.php page, and what I want is this- "When the user (contractor) selects any of the "contractor_type" radio button a new textbox should be displayed next to the 3rd radio button enabling the contractor to enter the 'company name' or 'firm name' dependind on the selected radio button.

Link to post
Share on other sites

you need to use js. bound function on event click on radio button.that function make the both input field company nama and firm name hidden(it will not let user open two field at a time) then check the value of the radio button where the click event occurs.then check that value with condition if it matches show the related field.

Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...