php - mysql post from html table -


i trying sql post information html form database keep getting:

( ! ) scream: error suppression ignored ( ! ) notice: undefined index: firstname in c:\wamp\www\insert.php on line 29 call stack #   time    memory  function    location 1   0.0005  247624  {main}( )   ..\insert.php:0 

the code using is:

<form action="insert.php" method="post">    name: <input type="text" name="firstname">    <input type="submit" value="submit"> </form>  <?php // connection database $con = mysql_connect('127.0.0.1', 'shane', 'diamond89'); if (!$con){    die('could not connect: ' . mysql_error()); }  // selects database want connect $selected = mysql_select_db("shane",$con); if (!$con){    die("could not select data"); }  // inserts new information database $name = $_post['name'];  $query = "insert test1 values('id', '$name')"; mysql_query($query) or die('error' . mysql_error());  // closes connection mysql_close($con) ?> 

your form has input named firstname not name, $_post['name'] should $_post['firstname']

change

    // inserts new information database     $name = $_post['name']; 

to

   // inserts new information database    $name = $_post['firstname']; 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -