0

Im doing a project based on students information. Im looking for the code to add the student details to alumini form when their period of course is completed(based on their date of completion). The below code is registeration of student information.

<?php
	
	$link = mysql_connect('localhost','root','');
	if(!$link) {
		die('Failed to connect to server: ' . mysql_error());
	}
	
	$db = mysql_select_db(priya);
	if(!$db) {
		die("Unable to select database");
	}
	
	

	$sql = "INSERT INTO trade(id,name,tokenno,trade,dateofjoin,dateofcompletion,duration)VALUES('$_POST[id]','$_POST[name]','$_POST[token]','$_POST[trade]','$_POST[doj]','$_POST[doc]','$_POST[duration]')";
	
	
	if (!mysql_query($sql,$link))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($link)
?>
3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by priyadharsinism
0

Im doing a project based on students information. Im looking for the code to add the student details to alumini form when their period of course is completed(based on their date of completion). The below code is registeration of student information.

<?php
	
	$link = mysql_connect('localhost','root','');
	if(!$link) {
		die('Failed to connect to server: ' . mysql_error());
	}
	
        // You missing qoutes around the db name.
        // Should be: $db = mysql_select_db("priya");
	$db = mysql_select_db(priya);
	if(!$db) {
		die("Unable to select database");
	}
	
	

	$sql = "INSERT INTO trade(id,name,tokenno,trade,dateofjoin,dateofcompletion,duration)VALUES('$_POST[id]','$_POST[name]','$_POST[token]','$_POST[trade]','$_POST[doj]','$_POST[doc]','$_POST[duration]')";
	
	
	if (!mysql_query($sql,$link))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($link)
?>

Notice, you missing qoutes around your db name.
$db = mysql_select_db(priya);
Should be: $db = mysql_select_db("priya");

Edited by shaiang: n/a

0
// Registerationform.php

<?php

    $link = mysql_connect('localhost','root','');
    if(!$link) {
        die('Failed to connect to server: ' . mysql_error());
    }

    $db = mysql_select_db(priya);
    if(!$db) {
        die("Unable to select database");
    }

    $sql = "INSERT INTO trade(tokenno,contractno,name,trade,doj,doc,batch)VALUES('$_POST[tokenno]','$_POST[contractno]','$_POST[name]','$_POST[trade]','$_POST[doj]','$_POST[doc]','$_POST[batch]')"; // doj refers to date of join and doc to date of completion


    if (!mysql_query($sql,$link))
  {
  die('Error: ' . mysql_error());
  }
echo "1 record added";

mysql_close($link)
?>

//Aluminiform.html(This form should retrive the details automatically from the above form when the date of completion equals to the current date)

<html></head><body bgcolor="skyblue">
<br><center><font face="Times New Roman" size="4" color="">ALUMINI DETAILS</font></center><br><form id="aluminiform" name="alumini" method="post" action="alumini.php"> <table width="539" border="0" align="center" cellpadding="2" cellspacing="5">
<tr>      <th>&nbsp;</th>      <td>&nbsp;</td>      <td>&nbsp;</td>    </tr><tr>      <td>Id </td>      <td><input name="id" type="text" class="textfield" id="id" maxlength="30" /></td>      <td rowspan="6"></td>    </tr> <tr>      <td>Name </td>      <td><input name="name" type="text" class="textfield" id="name" maxlength="30" /></td>      <td rowspan="6"></td>    </tr>    <tr>      <td>Token_no </td>      <td><input name="token" type="text" class="textfield" id="token" maxlength="30" /></td>      <td rowspan="6"></td>    </tr>
 <tr>
      <td>Trade </td><br>
<td><select name="trade">
  <option value="fitter">fitter</option>
  <option value="carpenter">carpenter</option>
  <option value="painter">painter</option>
  <option value="machinist">machinist</option>
</select></td>

<br>
    </tr>
<tr>      <td>Batch </td>      <td><input name="batch" type="text" class="textfield" id="batch" maxlength="30" /></td>      <td rowspan="6"></td>    </tr>
    <tr>      <th>&nbsp;</th>      <td>&nbsp;</td>      <td>&nbsp;</td>    </tr>    <tr>      <th height="24">        <div align="right">          <input type="submit" name="Submit" value="Register" id="but"/>        </div></th>      <td><div align="center">        <input type="reset" name="Submit2" value="Reset" id="but"/>      </div></td>
<td><div align="center">
        <p><a href="regform1.html">Home</a></p>
         </div></td>
<td><div align="center">
        <p><a href="hostelform6.html">Back</a></p>
         </div></td><td><div align="center">
        <p><a href="aluminisearchform.html">search</a></p>
         </div></td>    </tr>  </table></form>  </body></html>

Edited by Dani: Formatting fixed

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.