What,s the error? (Insertion in database)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • HUKHAN
    New Member
    • Jul 2013
    • 4

    What,s the error? (Insertion in database)

    Code:
    <?php
    if (isset($_get['submit'])) {
    	$dy=$_get['days'];
    	$pr=$_get['paper'];
    	$tim=$_get['timing'];
    	$con = mysql_connect("localhost","root","");
    	if($con){
    		echo("Connected Successfully");
    		mysql_select_db("datesheet", $con);
    	}else{
    		echo("Connected Successfully");	
    	}
    	$sql ="INSERT INTO  datesheet(Days,Paper,Timing) VALUES('$dy','$pr','$tim')";
    	$check=mysql_query($sql,$con);
    	if($check){
    		echo("Data inserted successfully");
    	}else{
    		echo("their exist some problem");
    	}
    	mysql_close($con);
    }
    ?>
    
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Std</title>
    </head>
    
    <body>
    <form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    	<table border="1" width="170" align="center">
        	<tr>
            	<td>Days</td>
            	<td><input type="text"  id="days"></td>
            </tr>
            <tr>
            	<td>Paper</td><td><input type="text"  id="paper"></td>
            </tr>
            <tr>
            	<td>Timing</td><td><input type="text"  id="timing"></td>
            </tr>
            <tr align="center">
            	<td colspan="2"><input type="submit" id="submit"></td>
            </tr>
        </table>
    </form>
    </body>
    </html>
    Last edited by Rabbit; Jul 13 '13, 11:40 PM. Reason: Please use code tags when posting code.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    what’s $_get?

    Comment

    • Exequiel
      Contributor
      • Jul 2012
      • 288

      #3
      you can use $_GET[''] instead of $_get[''],
      or maybe you must check your form if the method is get or post,

      Comment

      Working...