php - MySQL Database saving 0 values -


i have form take statistics course registration @ university , 1 of fields "studentid" connecting form database seems successful , primary field auto increment working fine , entering student id , submitting form fails every time , new record added "0" value ...

this html code

     <div class="content">      <form action="connect-mysql.php" method="post" enctype="text/plain" id="form3" name="form3" method="post">      <table width="100%" border="0">       <tr>         <td width="50%" bgcolor="#e3e3e3"><center>         student id :         </center></td>         <td width="50%" bgcolor="#e3e3e3">           <span id="sprytextfield1">           <label for="studentid"></label>           <input name="studentid" type="text" id="studentid" onblur="mm_validateform('studentid','','nisnum');return document.mm_returnvalue" maxlength="11" /> *<span class="textfieldrequiredmsg">a value required.</span></span>         </td> 

php code

<?php $host="fdb7.biz.nf" ;`enter code here` $username="1662822_db1" ; $password="421343" ; $db_name="1662822_db1" ; $tbl_name="courses" ;     $dbcon = mysqli_connect("$host","$username","$password","$db_name") ;                 if (!$dbcon) {     die('error connecting database'); }      echo 'you have connected sucessfully' ;   // escape variables security $studentid = mysqli_real_escape_string($dbcon, $_post['studentid']);  $sql="insert courses (studentid) values ('$studentid')";  if (!mysqli_query($dbcon,$sql)) { die('error: ' . mysqli_error($dbcon));  }  echo "1 record added";      mysqli_close($dbcon);   ?> 

method="post" 

is repeated in form

check studentid way:

$studentid = mysqli_real_escape_string($dbcon, $_post['studentid']); echo $studentid; 

you can print $sql variable after setting it.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -