PHP Classes

File: classtest_insert.php

Recommend this page to a friend!
  Classes of Hasin Hayder   phpFormGenerator   classtest_insert.php   Download  
File: classtest_insert.php
Role: Sample output
Content type: text/plain
Description: Example Output
Class: phpFormGenerator
Generate code to process form and insert MySQL row
Author: By
Last change:
Date: 19 years ago
Size: 3,251 bytes
 

Contents

Class file image Download
<?php //include_once('dbinfo.php'); $dbuser = 'root'; $dbhost = 'localhost'; $dbpwd = 'root'; $dbname = 'automation_system'; $suppress = $HTTP_GET_VARS['suppress']; $id = $HTTP_POST_VARS['id']; $course_id = $HTTP_POST_VARS['course_id']; $semester_id = $HTTP_POST_VARS['semester_id']; $teacher_id = $HTTP_POST_VARS['teacher_id']; $test_id = $HTTP_POST_VARS['test_id']; $marks = $HTTP_POST_VARS['marks']; if (!empty($id)){ $dblink = mysql_connect($dbhost,$dbuser,$dbpwd) or die("Cannot Connect To Database"); mysql_select_db($dbname); $query = "INSERT INTO classtest (id,course_id,semester_id,teacher_id,test_id,marks) VALUES ( '$id','$course_id','$semester_id','$teacher_id','$test_id','$marks' )"; $result = mysql_query($query, $dblink); echo ('<p align = "left">Record Successfully Inserted</p>'); } else if(empty($id) && (count($HTTP_POST_VARS)>0)) echo ('<p align = "left">Record Contains Error, Please Check Again</p>'); ?> <HTML> <HEAD><link href='style.css' rel='stylesheet' type='text/css'> </HEAD> <style type="text/css"> <!-- body { background-color: #e4eaf2; } --> </style> <BODY> <BR> <FORM name = 'form1' method = 'POST' action = ''> <table width='100%' border='0' cellspacing='0' cellpadding='1'> <TR> <TD class='row4'> <div align='left'><span class='postdetails'> <B>&nbsp;id</B> </span></div></TD> <TD class='row4'> <div align='left'><span class='postdetails'> <input type ='text' name = 'id' size = '15' maxlength = '10' value = "<? echo $id; ?>"> </span></div></TD> </TR> <TR> <TD class='row4'> <div align='left'><span class='postdetails'> <B>&nbsp;course_id</B> </span></div></TD> <TD class='row4'> <div align='left'><span class='postdetails'> <input type ='text' name = 'course_id' size = '15' maxlength = '10' value = "<? echo $course_id; ?>"> </span></div></TD> </TR> <TR> <TD class='row4'> <div align='left'><span class='postdetails'> <B>&nbsp;semester_id</B> </span></div></TD> <TD class='row4'> <div align='left'><span class='postdetails'> <input type ='text' name = 'semester_id' size = '15' maxlength = '10' value = "<? echo $semester_id; ?>"> </span></div></TD> </TR> <TR> <TD class='row4'> <div align='left'><span class='postdetails'> <B>&nbsp;teacher_id</B> </span></div></TD> <TD class='row4'> <div align='left'><span class='postdetails'> <input type ='text' name = 'teacher_id' size = '15' maxlength = '10' value = "<? echo $teacher_id; ?>"> </span></div></TD> </TR> <TR> <TD class='row4'> <div align='left'><span class='postdetails'> <B>&nbsp;test_id</B> </span></div></TD> <TD class='row4'> <div align='left'><span class='postdetails'> <input type ='text' name = 'test_id' size = '15' maxlength = '10' value = "<? echo $test_id; ?>"> </span></div></TD> </TR> <TR> <TD class='row4'> <div align='left'><span class='postdetails'> <B>&nbsp;marks</B> </span></div></TD> <TD class='row4'> <div align='left'><span class='postdetails'> <input type ='text' name = 'marks' size = '15' maxlength = '10' value = "<? echo $marks; ?>"> </span></div></TD> </TR> <TR> <TD class='darkrow3'> <div align='left'><span class='postdetails'> <B>&nbsp;Submit</B> </span></div></TD> <TD class='darkrow3'> <div align='left'><span class='postdetails'><input type = 'submit' value = 'submit data'></span></div></TD> </TABLE></FORM>