Jump to content

not adding into database


cffood

Recommended Posts

I have a form that posts into the database but not the username.

 

I have for the form <td><input name="username" type="text" disabled="disabled" class="inputbox" value="<?php echo $row['username'];?>" size="45" /></td> to fetch the username from the database so they don't have to insert it as I will be making another code to echo the username's inputs so they can track what they have inserted.

 

but its not inserting the username back in to the database.

 

any while will do

Link to comment
Share on other sites

<?php

 

  define("_VALID_PHP", true);

  require_once("init.php");

    $row = $user->getUserData();

 

?>

 

 <?php include("header.php");?>

 

 

  <?php if($user->checkMembership('1,6')): ?>

 <!-- ============= CONTENT AREA STARTS HERE ============== -->

          <div id="content">

               

                  <!-- SLIDER STARTS HERE -->

      <div id="slider" class="slider2">

        <div >

          

        </div>

        <h2 class="slider-head">Track your Weight</h2><br /><br />

        <div id="whats-hot" > <p> Insert your daily Weight in here. The best time to weigh yourself is within the first hour as you wake up.

</p>

         </div> 

 

                   <!-- end of news div --><!-- end of container div -->

 <div class="w-pet-border">

<script language="javascript">

function calculateWeight(fld)

{

 if(fld.name=="weight_lb" || fld.name=="lose_lb")

 {

  // calculate in kg

  if(isNaN(fld.value) || fld.value=="") w=0;

  else w=fld.value;

  

  wKg=Math.round(w*0.453*10)/10;

  

  if(fld.name=="weight_lb") fld.form.weight_kg.value=wKg;

  else fld.form.lose_kg.value=wKg;

 }

 else

 {

  // calculate in lbs

  if(isNaN(fld.value) || fld.value=="") w=0;

  else w=fld.value;

  

  wP=Math.round(w*2.2);

  

  if(fld.name=='weight_kg') fld.form.weight_lb.value=wP;

  else fld.form.lose_lb.value=wP;

 }

}

</script>

 

<table width="300" border="0" align="center" cellpadding="0" cellspacing="1">

 <tr>

 <td><form name="form1" method="post" action="weighttrack_db.php">

   <table width="100%" border="0" cellspacing="1" cellpadding="3">

   <tr>

     <td><table width="100%" border="0" cellspacing="1" cellpadding="3">

       <tr>

         <td colspan="3"><strong>Insert Data Into mySQL Database </strong></td>

       </tr>

       <tr>

         <th width="180"><strong>Username:</strong></th>

         <td> </td>            <td><input name="username" type="text" disabled="disabled" class="inputbox" value="<?php echo $row['username'];?>" size="45" /></td>

       </tr>

       <tr>

         <td>Lastname</td>

         <td>:</td>

         <td><label>Your weight:</label>

           <br />

           <input type="text" name="pounds" size="4" onkeyup="calculateWeight(this);" value="<?=$_SESSION["calc_weight_lb"]?>" />

           lbs <b>OR</b>

           <input type="text" name="kilo" size="4" onkeyup="calculateWeight(this);" value="<?=$_SESSION["calc_weight_kg"]?>" />

           kg</td>

       </tr>

       <tr>

         <td>Email</td>

         <td>:</td>

         <td><input id="date" name="date" value="<?php echo date("M j, Y - g:i"); ?>"/></td>

       </tr>

       <tr>

         <td colspan="3" align="center"><input type="submit" name="Submit" value="Submit" /></td>

       </tr>

     </table></td>

   </tr>

   </table>

 </form>

 </td>

 </tr>

 </table>

 

</div></div><br /><br /><br />

<!-- ============= CONTAINER AREA ENDS HERE ============== -->

 

  <?php else: ?>

 

  <h2>Please <a href="index.php">Login</a> to view this page. or if you are logged in please weight 24 hour or less so Admin can change your Membership

  </h2>

<?php endif; ?>

 

 

 <?php include("footer.php");?>

 

 

 

Link to comment
Share on other sites

if I take disabled="disabled" of the input then it wokrs fine..but it means they can  change their username. which means if they change it they will never see what they inputted

Disabled INPUT elements are NOT posted with the form. They are disabled.

 

You can use READONLY to display an input that cannot be typed in, it WILL be posted with the form.

 

That being said, it is VERY VERY easy for a user to change the value in ANY INPUT element -- even READONLY and HIDDEN and, yes, DISABLED -- before posting the form. If you have a value that needs to survive from one "page" to another with no chance of being modified by the user, you need to look into sessions

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.