Jump to content

totxone

New Members
  • Posts

    2
  • Joined

  • Last visited

totxone's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you all for your reply. The version that I am using is 5.3.0. I have tried the above made recommendations, but none seem to work. So I have changed the entire code and here is it. This is also not working. All it does is refresh the page and does not even execute the php code in the first page.Appreciate your replies! Page 1 defining the layout for user input and calling the function to enter the record in database in page 2 <html> <head> <title>Enter Session Details Here</title> <script language="javascript" type="text/javascript" src="datetimepicker.js"> //Date Time Picker script </script> </head> <body> <form method="POST" name="stdFrm" action="sessionDetailsEntry.php3"> <U><B><CENTER>Session Information Entry</CENTER></B></U> <TABLE align="center"> <TR> <TD>Teacher:</TD> <TD><input type=text name="teacherName" size="25" maxlength="25"</TD> </TR> <TR> <TD>Student Name:</TD> <TD><input type=text name="studentName" size="10" maxlength="10" maxlength="10"></TD> </TR> <TR> <TD>Topic Taught:</TD> <TD><input type=text name="topic" size="25" maxlength="25"></TD> </TR> <TR> <TD>Session Date and Time:</TD> <TD><input id="sessionDateTime" name="sessionDateTime" type="text" size="25"><a href="javascript:NewCal('sessionDateTime','ddmmyyyy',true, 12)"><img src="cal.gif" width="16" height="16" border="0" ></a></TD> </TR> <TR> <TD>Assignment Score:</TD> <TD><input type=text name="score" size="10" maxlength="10"></TD> </TR> <TR> <TD>Comments:</TD> <TD><textarea name="comments" cols=80 rows=4 maxlength="500"></textarea></TD> </TR> <TR> <TD>Technical Issues:</TD> <TD><textarea name="technicalIssues" cols=80 rows=4 maxlength="300"></textarea></TD> </TR> <TR> <TD>Next Topic:</TD> <TD><input type=text name="nextTopic" size="25" maxlength="25"></TD> </TR> <TR> <TD align="right"><input type="submit" name='submit' value="Save"></TD> <TD align="left"><input type="reset" value="Clear"></TD> </TR> </TABLE> <? php include 'db_ops.php3'; echo "calling submit"; if (isset($_POST['submit'])) { add_to_db(); } else {echo "Insert attemp failed";} ?> </form> </body> </html> page 2 with the function <?php function add_to_db() { $link = mysql_connect('localhost' , 'root' , '' ); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'connected successfully' . "\n" ; mysql_select_db('etz', $link); $qurSQL = "INSERT INTO session_entry (teacher_id, student_id, topic, assignment_score, comments, session_issues, next_topic, date, timestamp) VALUES (' ".$_POST['teacherName']."', '".$_POST['studentName']."', '".$_POST['topic']."', '".$_POST['score']."', '".$_POST['comments']."', '".$_POST['technicalIssues']."', '".$_POST['nextTopic']."', '".$_POST['sessionDateTime']."', '".$_POST['sessionDateTime']."')"; echo $qurSQL; mysql_query ($qurSQL) or die(mysql_error()); mysql_close($link); echo 'connected close' . "\n" ; }
  2. HI, I have created a form where user can input some values with 2 buttons submit and clear. Then in the same form I have added php code for submit button , if this button is clicked, a seperate php page is called which has some functions written in it. One of the functions in the page include connecting to database, table and command to insert a record from the data entered in the form. However when I run it and click on submit the page just refrehes and nothing is added to my database. Can someone please tell me what could be the problem. Here are the codes for reference. page 1 <html> <head> <title>Enter Session Details Here</title> <script language="javascript" type="text/javascript" src="datetimepicker.js"> //Date Time Picker script </script> <? include("db_ops.php3"); ?> </head> <body> <form method="POST" name="stdFrm" action="sessionDetailsEntry.php3"> <U><B><CENTER>Session Information Entry</CENTER></B></U> <TABLE align="center"> <TR> <TD>Teacher:</TD> <TD><input type=text name="teacherName" size="25" maxlength="25"</TD> </TR> <TR> <TD>Student Name:</TD> <TD><input type=text name="studentName" size="10" maxlength="10" maxlength="10"></TD> </TR> <TR> <TD>Topic Taught:</TD> <TD><input type=text name="topic" size="25" maxlength="25"></TD> </TR> <TR> <TD>Session Date and Time:</TD> <TD><input id="sessionDateTime" type="text" size="25"><a href="javascript:NewCal('sessionDateTime','ddmmyyyy',true, 12)"><img src="cal.gif" width="16" height="16" border="0" ></a></TD> </TR> <TR> <TD>Assignment Score:</TD> <TD><input type=text name="score" size="10" maxlength="10"></TD> </TR> <TR> <TD>Comments:</TD> <TD><textarea name="comments" cols=80 rows=4 maxlength="500"></textarea></TD> </TR> <TR> <TD>Technical Issues:</TD> <TD><textarea name="technicalIssues" cols=80 rows=4 maxlength="300"></textarea></TD> </TR> <TR> <TD>Next Topic:</TD> <TD><input type=text name="nextTopic" size="25" maxlength="25"></TD> </TR> <TR> <TD align="right"><input type="Submit" value="Save"></TD> <TD align="left"><input type="reset" value="Clear"></TD> </TR> </TABLE> </form> <? php if(isset($_POST['Submit'])) { $table_nm = 'session_entry'; add_to_table(table_nm); echo "Back"; } ?> </body> </html> page 2 with functions <html> <body> <?php $link; function add_to_table($table_nm) { connect_to_db(); mysql_select_db('etz', $link); $add_to_table = "INSERT INTO session_entry (teacher_id, student_id, topic, assignment_score, comments, session_issues, next_topic, date, timestamp) VALUES ('$_POST[teacherName]', '$_POST[studentName]', '$_POST','$_POST[score]', '$_POST[comments]', '$_POST[technicalIssues]', '$_POST[nextTopic]', '$_POST[sessionDateTime]', '$_POST[sessionDateTime]')"; echo "Adding the records"; mysql_query ($ad_to_table) or die(mysql_error()); mysql_close($link); } function connect_to_db() { $link = mysql_connect('localhost' , 'root' , '' ); if (!$link) { die('Could not connect: ' . mysql_error()); } echo 'connected successfully' . "\n" ; } ?> TIA
×
×
  • 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.